[fix] maintain same rate throughout purchase cycle optional
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py
index 52a4316..fac976e 100644
--- a/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -195,8 +195,7 @@
},
"Purchase Order Item": {
"ref_dn_field": "po_detail",
- "compare_fields": [["import_rate", "="], ["project_name", "="], ["item_code", "="],
- ["uom", "="]],
+ "compare_fields": [["project_name", "="], ["item_code", "="], ["uom", "="]],
"is_child_table": True
},
"Purchase Receipt": {
@@ -205,11 +204,25 @@
},
"Purchase Receipt Item": {
"ref_dn_field": "pr_detail",
- "compare_fields": [["import_rate", "="], ["project_name", "="], ["item_code", "="],
- ["uom", "="]],
+ "compare_fields": [["project_name", "="], ["item_code", "="], ["uom", "="]],
"is_child_table": True
}
})
+
+ if cint(webnotes.defaults.get_global_default('maintain_same_rate')):
+ super(DocType, self).validate_with_previous_doc(self.tname, {
+ "Purchase Order Item": {
+ "ref_dn_field": "po_detail",
+ "compare_fields": [["import_rate", "="]],
+ "is_child_table": True
+ },
+ "Purchase Receipt Item": {
+ "ref_dn_field": "pr_detail",
+ "compare_fields": [["import_rate", "="]],
+ "is_child_table": True
+ }
+ })
+
def set_aging_date(self):
if self.doc.is_opening != 'Yes':
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py
index 744130a..62b7a4f 100644
--- a/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -94,11 +94,21 @@
},
"Purchase Order Item": {
"ref_dn_field": "prevdoc_detail_docname",
- "compare_fields": [["import_rate", "="], ["project_name", "="], ["warehouse", "="],
+ "compare_fields": [["project_name", "="], ["warehouse", "="],
["uom", "="], ["item_code", "="]],
"is_child_table": True
}
})
+
+ if cint(webnotes.defaults.get_global_default('maintain_same_rate')):
+ super(DocType, self).validate_with_previous_doc(self.tname, {
+ "Purchase Order Item": {
+ "ref_dn_field": "prevdoc_detail_docname",
+ "compare_fields": [["import_rate", "="]],
+ "is_child_table": True
+ }
+ })
+
def po_required(self):
if webnotes.conn.get_single_value("Buying Settings", "po_required") == 'Yes':