From 7be942db54cf83d34c7e0357e0d31c505626b4ad Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Wed, 16 Nov 2016 11:14:33 +0530 Subject: [PATCH] [Fix] Status updater for sales order in purchase order (#6944) --- .../doctype/purchase_order/purchase_order.py | 1 + erpnext/controllers/status_updater.py | 24 +++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index 54ca07b5dc..197928a34a 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -231,6 +231,7 @@ class PurchaseOrder(BuyingController): "target_parent_dt": "Sales Order", "target_dt": "Sales Order Item", 'target_field': 'ordered_qty', + "join_field": "sales_order_item", "target_parent_field": '' }) diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index fcddc8fb3d..da09e26dd5 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -271,19 +271,19 @@ class StatusUpdater(Document): %(update_modified)s where name='%(name)s'""" % args) - # update field - if args.get('status_field'): - frappe.db.sql("""update `tab%(target_parent_dt)s` - set %(status_field)s = if(%(target_parent_field)s<0.001, - 'Not %(keyword)s', if(%(target_parent_field)s>=99.99, - 'Fully %(keyword)s', 'Partly %(keyword)s')) - where name='%(name)s'""" % args) + # update field + if args.get('status_field'): + frappe.db.sql("""update `tab%(target_parent_dt)s` + set %(status_field)s = if(%(target_parent_field)s<0.001, + 'Not %(keyword)s', if(%(target_parent_field)s>=99.99, + 'Fully %(keyword)s', 'Partly %(keyword)s')) + where name='%(name)s'""" % args) - if update_modified: - target = frappe.get_doc(args["target_parent_dt"], args["name"]) - target.set_status(update=True) - target.notify_update() - notify_status(target) + if update_modified: + target = frappe.get_doc(args["target_parent_dt"], args["name"]) + target.set_status(update=True) + target.notify_update() + notify_status(target) def _update_modified(self, args, update_modified): args['update_modified'] = ''