Merge pull request #13965 from deepeshgarg007/custom_doctype_length
fix: Length change for docfield not updated in Database
This commit is contained in:
commit
56fcd3cfab
2 changed files with 30 additions and 0 deletions
|
|
@ -193,6 +193,16 @@ class CustomizeForm(Document):
|
|||
if prop == "fieldtype":
|
||||
self.validate_fieldtype_change(df, meta_df[0].get(prop), df.get(prop))
|
||||
|
||||
elif prop == "length":
|
||||
old_value_length = cint(meta_df[0].get(prop))
|
||||
new_value_length = cint(df.get(prop))
|
||||
|
||||
if new_value_length and (old_value_length > new_value_length):
|
||||
self.check_length_for_fieldtypes.append({'df': df, 'old_value': meta_df[0].get(prop)})
|
||||
self.validate_fieldtype_length()
|
||||
else:
|
||||
self.flags.update_db = True
|
||||
|
||||
elif prop == "allow_on_submit" and df.get(prop):
|
||||
if not frappe.db.get_value("DocField",
|
||||
{"parent": self.doc_type, "fieldname": df.fieldname}, "allow_on_submit"):
|
||||
|
|
|
|||
|
|
@ -188,6 +188,26 @@ class TestCustomizeForm(unittest.TestCase):
|
|||
def test_core_doctype_customization(self):
|
||||
self.assertRaises(frappe.ValidationError, self.get_customize_form, 'User')
|
||||
|
||||
def test_save_customization_length_field_property(self):
|
||||
# Using Notification Log doctype as it doesn't have any other custom fields
|
||||
d = self.get_customize_form("Notification Log")
|
||||
|
||||
document_name = d.get("fields", {"fieldname": "document_name"})[0]
|
||||
document_name.length = 255
|
||||
d.run_method("save_customization")
|
||||
|
||||
self.assertEqual(frappe.db.get_value("Property Setter",
|
||||
{"doc_type": "Notification Log", "property": "length", "field_name": "document_name"}, "value"), '255')
|
||||
|
||||
self.assertTrue(d.flags.update_db)
|
||||
|
||||
length = frappe.db.sql("""SELECT character_maximum_length
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'tabNotification Log'
|
||||
AND column_name = 'document_name'""")[0][0]
|
||||
|
||||
self.assertEqual(length, 255)
|
||||
|
||||
def test_custom_link(self):
|
||||
try:
|
||||
# create a dummy doctype linked to Event
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue