Merge pull request #831 from anandpdoshi/anand-september-9
Don't allow to set 'Allow on Submit' for standard fields. Fixes frappe/erpnext#956
This commit is contained in:
commit
eb846fb38d
5 changed files with 31 additions and 0 deletions
|
|
@ -117,6 +117,11 @@ class CustomizeForm(Document):
|
|||
if property == "fieldtype":
|
||||
self.validate_fieldtype_change(df, meta_df[0].get(property), df.get(property))
|
||||
|
||||
elif property == "allow_on_submit" and df.get(property):
|
||||
frappe.msgprint(_("Row {0}: Not allowed to enable Allow on Submit for standard fields")\
|
||||
.format(df.idx))
|
||||
continue
|
||||
|
||||
self.make_property_setter(property=property, value=df.get(property),
|
||||
property_type=self.docfield_properties[property], fieldname=df.fieldname)
|
||||
|
||||
|
|
|
|||
|
|
@ -159,3 +159,17 @@ class TestCustomizeForm(unittest.TestCase):
|
|||
|
||||
frappe.local.test_objects["Property Setter"] = []
|
||||
make_test_records_for_doctype("Property Setter")
|
||||
|
||||
def test_set_allow_on_submit(self):
|
||||
d = self.get_customize_form("User")
|
||||
d.get("customize_form_fields", {"fieldname": "first_name"})[0].allow_on_submit = 1
|
||||
d.get("customize_form_fields", {"fieldname": "test_custom_field"})[0].allow_on_submit = 1
|
||||
d.run_method("save_customization")
|
||||
|
||||
d = self.get_customize_form("User")
|
||||
|
||||
# don't allow for standard fields
|
||||
self.assertEquals(d.get("customize_form_fields", {"fieldname": "first_name"})[0].allow_on_submit or 0, 0)
|
||||
|
||||
# allow for custom field
|
||||
self.assertEquals(d.get("customize_form_fields", {"fieldname": "test_custom_field"})[0].allow_on_submit, 1)
|
||||
|
|
|
|||
|
|
@ -54,3 +54,4 @@ execute:frappe.reload_doc('website', 'doctype', 'web_form') #2014-09-04
|
|||
execute:frappe.reload_doc('website', 'doctype', 'web_form_field') #2014-09-04
|
||||
frappe.patches.v4_2.refactor_website_routing
|
||||
frappe.patches.v4_2.set_assign_in_doc
|
||||
frappe.patches.v4_3.remove_allow_on_submit_customization
|
||||
|
|
|
|||
0
frappe/patches/v4_3/__init__.py
Normal file
0
frappe/patches/v4_3/__init__.py
Normal file
11
frappe/patches/v4_3/remove_allow_on_submit_customization.py
Normal file
11
frappe/patches/v4_3/remove_allow_on_submit_customization.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# MIT License. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
for d in frappe.get_list("Property Setter", fields=["name", "doc_type"],
|
||||
filters={"doctype_or_field": "DocField", "property": "allow_on_submit", "value": "1"}, ignore_permissions=True):
|
||||
frappe.delete_doc("Property Setter", d.name)
|
||||
frappe.clear_cache(doctype=d.doc_type)
|
||||
Loading…
Add table
Reference in a new issue