diff --git a/crm/fcrm/doctype/fcrm_settings/fcrm_settings.py b/crm/fcrm/doctype/fcrm_settings/fcrm_settings.py index 08a0a4b7e..1ccbfe1c1 100644 --- a/crm/fcrm/doctype/fcrm_settings/fcrm_settings.py +++ b/crm/fcrm/doctype/fcrm_settings/fcrm_settings.py @@ -12,6 +12,20 @@ class FCRMSettings(Document): def restore_defaults(self, force=False): after_install(force) + def validate(self): + self.do_not_allow_to_delete_if_standard() + + def do_not_allow_to_delete_if_standard(self): + if not self.has_value_changed("dropdown_items"): + return + old_items = self.get_doc_before_save().get("dropdown_items") + standard_new_items = [d.name1 for d in self.dropdown_items if d.is_standard] + standard_old_items = [d.name1 for d in old_items if d.is_standard] + deleted_standard_items = set(standard_old_items) - set(standard_new_items) + if deleted_standard_items: + frappe.throw(frappe._("Cannot delete standard items {0}").format(", ".join(deleted_standard_items))) + + def after_migrate(): sync_table("dropdown_items", "standard_dropdown_items") diff --git a/frontend/src/components/Settings/GeneralSettings.vue b/frontend/src/components/Settings/GeneralSettings.vue index f590310aa..cc70234a3 100644 --- a/frontend/src/components/Settings/GeneralSettings.vue +++ b/frontend/src/components/Settings/GeneralSettings.vue @@ -106,28 +106,32 @@ -
+