From 2957a631db9c4ed3c9d417aaabedf8e7b4722cfb Mon Sep 17 00:00:00 2001 From: P-Froggy <60393001+P-Froggy@users.noreply.github.com> Date: Mon, 15 Jun 2020 10:11:16 +0200 Subject: [PATCH 1/2] fix: Validation of Purchase Order against Material Request missing (#22192) Validation of Purchase Order and Purchase Order Item against the linked Material Request Item was missing, so it was possible to exchange items in the purcahse order against others and still fullfill the material request. Co-authored-by: Marica --- erpnext/buying/doctype/purchase_order/purchase_order.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index f62df20ae1..c7efb8a1a1 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -71,6 +71,15 @@ class PurchaseOrder(BuyingController): "compare_fields": [["project", "="], ["item_code", "="], ["uom", "="], ["conversion_factor", "="]], "is_child_table": True + }, + "Material Request": { + "ref_dn_field": "material_request", + "compare_fields": [["company", "="]], + }, + "Material Request Item": { + "ref_dn_field": "material_request_item", + "compare_fields": [["project", "="], ["item_code", "="]], + "is_child_table": True } }) From 8a0058787ed054f2951815b2c297df9212675706 Mon Sep 17 00:00:00 2001 From: marination Date: Mon, 15 Jun 2020 14:40:39 +0530 Subject: [PATCH 2/2] fix: Wrong key sent to gte_valuation_rate --- erpnext/controllers/buying_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 608e537e1b..89b48f07ee 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -349,7 +349,7 @@ class BuyingController(StockController): }) if not rm.rate: - rm.rate = get_valuation_rate(raw_material_data.item_code, self.supplier_warehouse, + rm.rate = get_valuation_rate(raw_material_data.rm_item_code, self.supplier_warehouse, self.doctype, self.name, currency=self.company_currency, company=self.company) rm.amount = qty * flt(rm.rate)