From d0c9d422af705bdf9abceb25c87c1e9b8fe6a97a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 20 Oct 2011 19:21:03 +0530 Subject: [PATCH] patch for project changes in pur cycle --- erpnext/patches/project_patch.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 erpnext/patches/project_patch.py diff --git a/erpnext/patches/project_patch.py b/erpnext/patches/project_patch.py new file mode 100644 index 0000000000..c5473a0fac --- /dev/null +++ b/erpnext/patches/project_patch.py @@ -0,0 +1,18 @@ +def execute(): + import webnotes + from webnotes.modules.module_manager import reload_doc + sql = webnotes.conn.sql + + # Reload item table + reload_doc('accounts', 'doctype', 'pv_detail') + reload_doc('buying', 'doctype', 'po_detail') + reload_doc('stock', 'doctype', 'purchase_receipt_detail') + + # copy project value from parent to child + sql("update `tabPO Detail` t1, `tabPurchase Order` t2 set t1.project_name = t2.project_name where t1.parent = t2.name and ifnull(t1.project_name, '') = ''") + sql("update `tabPV Detail` t1, `tabPayable Voucher` t2 set t1.project_name = t2.project_name where t1.parent = t2.name and ifnull(t1.project_name, '') = ''") + sql("update `tabPurchase Receipt Detail` t1, `tabPurchase Receipt` t2 set t1.project_name = t2.project_name where t1.parent = t2.name and ifnull(t1.project_name, '') = ''") + + # delete project from parent + sql("delete from `tabDocField` where fieldname = 'project_name' and parent in ('Purchase Order', 'Purchase Receipt', 'Payable Voucher')") +