fix(patch): update status and set auto repeat as not submittable

This commit is contained in:
Rucha Mahabal 2019-11-03 15:36:22 +05:30
parent 6d9d110a6a
commit 5c64fbdb20
2 changed files with 26 additions and 0 deletions

View file

@ -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

View file

@ -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()