From c040015bb5e17b233c343702b82a040b5d43f5df Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 31 Mar 2017 11:58:01 +0530 Subject: [PATCH] Used db_update in patch to bypass validate and on_update method --- .../v8_0/manufacturer_childtable_migrate.py | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/erpnext/patches/v8_0/manufacturer_childtable_migrate.py b/erpnext/patches/v8_0/manufacturer_childtable_migrate.py index 6d566b45bb..87a3431578 100644 --- a/erpnext/patches/v8_0/manufacturer_childtable_migrate.py +++ b/erpnext/patches/v8_0/manufacturer_childtable_migrate.py @@ -6,20 +6,19 @@ import frappe def execute(): - # reading from json and writing it to mariadb - # reload_doc needed here with information because new table introduced - frappe.reload_doc('stock', 'doctype', 'item_manufacturer') - # reload_doctype is a simpler concept of reload_doc - frappe.reload_doctype('Item') + # reading from json and writing it to mariadb + # reload_doc needed here with information because new table introduced + frappe.reload_doc('stock', 'doctype', 'item_manufacturer') + # reload_doctype is a simpler concept of reload_doc + frappe.reload_doctype('Item') - item_manufacturers = frappe.get_all("Item", fields=["name", "manufacturer", "manufacturer_part_no"]) - for item in item_manufacturers: - if item.manufacturer or item.manufacturer_part_no: - item_doc = frappe.get_doc("Item", item.name) - item_doc.append("manufacturers", { - "manufacturer": item.manufacturer, - "manufacturer_part_no": item.manufacturer_part_no - }) - item_doc.flags.ignore_validate = True - item_doc.flags.ignore_mandatory = True - item_doc.save() + item_manufacturers = frappe.get_all("Item", fields=["name", "manufacturer", "manufacturer_part_no"]) + for item in item_manufacturers: + if item.manufacturer or item.manufacturer_part_no: + item_doc = frappe.get_doc("Item", item.name) + item_doc.append("manufacturers", { + "manufacturer": item.manufacturer, + "manufacturer_part_no": item.manufacturer_part_no + }) + + item_doc.get("manufacturers")[0].db_update() \ No newline at end of file