Merge pull request #32923 from deepeshgarg007/rate_quotation
fix: Maintain same rate between Quotation and Sales Order
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index 60d98fb..484b8c9 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -247,7 +247,7 @@
"Quotation": {"doctype": "Sales Order", "validation": {"docstatus": ["=", 1]}},
"Quotation Item": {
"doctype": "Sales Order Item",
- "field_map": {"parent": "prevdoc_docname"},
+ "field_map": {"parent": "prevdoc_docname", "name": "quotation_item"},
"postprocess": update_item,
"condition": lambda doc: doc.qty > 0,
},
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 5fadfcb..78e2370 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -193,6 +193,9 @@
{"Quotation": {"ref_dn_field": "prevdoc_docname", "compare_fields": [["company", "="]]}}
)
+ if cint(frappe.db.get_single_value("Selling Settings", "maintain_same_sales_rate")):
+ self.validate_rate_with_reference_doc([["Quotation", "prev_docname", "quotation_item"]])
+
def update_enquiry_status(self, prevdoc, flag):
enq = frappe.db.sql(
"select t2.prevdoc_docname from `tabQuotation` t1, `tabQuotation Item` t2 where t2.parent = t1.name and t1.name=%s",
diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.json b/erpnext/selling/doctype/sales_order_item/sales_order_item.json
index ea0b25f..8c7c552 100644
--- a/erpnext/selling/doctype/sales_order_item/sales_order_item.json
+++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.json
@@ -70,6 +70,7 @@
"warehouse",
"target_warehouse",
"prevdoc_docname",
+ "quotation_item",
"col_break4",
"against_blanket_order",
"blanket_order",
@@ -838,12 +839,20 @@
"label": "Purchase Order Item",
"print_hide": 1,
"read_only": 1
+ },
+ {
+ "fieldname": "quotation_item",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "label": "quotation_item",
+ "no_copy": 1,
+ "read_only": 1
}
],
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2022-10-26 16:05:02.712705",
+ "modified": "2022-11-10 18:20:30.137455",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order Item",