Merge pull request #2387 from shreyasp/set-only-once-issue

[Minor] convert date type to string when field is set as 'set_only_once' or constant
This commit is contained in:
Nabin Hait 2016-11-30 12:10:06 +05:30 committed by GitHub
commit 579713e901

View file

@ -504,7 +504,16 @@ class BaseDocument(object):
values = frappe.db.get_value(self.doctype, self.name, constants, as_dict=True)
for fieldname in constants:
if self.get(fieldname) != values.get(fieldname):
df = self.meta.get_field(fieldname)
# This conversion to string only when fieldtype is Date
if df.fieldtype == 'Date':
value = str(values.get(fieldname))
else:
value = values.get(fieldname)
if self.get(fieldname) != value:
frappe.throw(_("Value cannot be changed for {0}").format(self.meta.get_label(fieldname)),
frappe.CannotChangeConstantError)