소스 검색

get the default value of check field if none, for insert / update

version-14
Nabin Hait 8 년 전
부모
커밋
b2908df91b
1개의 변경된 파일7개의 추가작업 그리고 6개의 파일을 삭제
  1. +7
    -6
      frappe/model/base_document.py

+ 7
- 6
frappe/model/base_document.py 파일 보기

@@ -189,8 +189,13 @@ class BaseDocument(object):


df = self.meta.get_field(fieldname) df = self.meta.get_field(fieldname)
if df: if df:
if df.fieldtype=="Check" and (not isinstance(d[fieldname], int) or d[fieldname] > 1):
d[fieldname] = 1 if cint(d[fieldname]) else 0
if df.fieldtype=="Check":
if (not isinstance(d[fieldname], int) or d[fieldname] > 1):
d[fieldname] = 1 if cint(d[fieldname]) else 0

# get the default value if none, for insert / update
elif d[fieldname]==None:
d[fieldname] = df.get('default')


elif df.fieldtype=="Int" and not isinstance(d[fieldname], int): elif df.fieldtype=="Int" and not isinstance(d[fieldname], int):
d[fieldname] = cint(d[fieldname]) d[fieldname] = cint(d[fieldname])
@@ -208,10 +213,6 @@ class BaseDocument(object):
if isinstance(d[fieldname], list) and df.fieldtype != 'Table': if isinstance(d[fieldname], list) and df.fieldtype != 'Table':
frappe.throw(_('Value for {0} cannot be a list').format(_(df.label))) frappe.throw(_('Value for {0} cannot be a list').format(_(df.label)))


# get the default value if none, for insert / update
if d[fieldname]==None and df.get('default'):
d[fieldname] = df.get('default')

return d return d


def init_valid_columns(self): def init_valid_columns(self):


불러오는 중...
취소
저장