diff --git a/frappe/patches.txt b/frappe/patches.txt index 621a2107df..e107449dea 100644 --- a/frappe/patches.txt +++ b/frappe/patches.txt @@ -255,3 +255,4 @@ frappe.patches.v12_0.set_default_incoming_email_port frappe.patches.v12_0.update_global_search execute:frappe.reload_doc('desk', 'doctype', 'notification_settings') frappe.patches.v12_0.setup_tags +frappe.patches.v12_0.update_auto_repeat_status_and_not_submittable diff --git a/frappe/patches/v12_0/update_auto_repeat_status_and_not_submittable.py b/frappe/patches/v12_0/update_auto_repeat_status_and_not_submittable.py new file mode 100644 index 0000000000..3f23d08c9a --- /dev/null +++ b/frappe/patches/v12_0/update_auto_repeat_status_and_not_submittable.py @@ -0,0 +1,25 @@ +from __future__ import unicode_literals +import frappe +from frappe.custom.doctype.custom_field.custom_field import create_custom_field + +def execute(): + #auto repeat is not submittable in v12 + frappe.reload_doc("automation", "doctype", "Auto Repeat") + frappe.db.sql("update `tabDocPerm` set submit=0, cancel=0, amend=0 where parent='Auto Repeat'") + frappe.db.sql("update `tabAuto Repeat` set docstatus=0 where docstatus=1 or docstatus=2") + + for entry in frappe.get_all("Auto Repeat"): + doc = frappe.get_doc("Auto Repeat", entry.name) + + #create custom field for allow auto repeat + fields = frappe.get_meta(doc.reference_doctype).fields + insert_after = fields[len(fields) - 1].fieldname + df = dict(fieldname="auto_repeat", label="Auto Repeat", fieldtype="Link", insert_after=insert_after, + options="Auto Repeat", hidden=1, print_hide=1, read_only=1) + create_custom_field(doc.reference_doctype, df) + + if doc.status in ['Draft', 'Stopped', 'Cancelled']: + doc.disabled = 1 + + #updates current status as Active, Disabled or Completed on validate + doc.save() \ No newline at end of file