fix: Maintain Same Rate Throughout Sales Cycle doesn't work
Issue #29976 was partly fixed by #32923 but the problem still persists.
The reason is because an incorrect fieldname was passed to the
`validate_rate_with_reference_doc` method.
This commit fixes it
diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py
index 6f0b381..5cd6545 100644
--- a/erpnext/selling/doctype/quotation/test_quotation.py
+++ b/erpnext/selling/doctype/quotation/test_quotation.py
@@ -30,6 +30,19 @@
self.assertTrue(sales_order.get("payment_schedule"))
+ def test_maintain_rate_in_sales_cycle_is_enforced(self):
+ from erpnext.selling.doctype.quotation.quotation import make_sales_order
+
+ quotation = frappe.copy_doc(test_records[0])
+ quotation.transaction_date = nowdate()
+ quotation.valid_till = add_months(quotation.transaction_date, 1)
+ quotation.insert()
+ quotation.submit()
+
+ sales_order = make_sales_order(quotation.name)
+ sales_order.items[0].rate = 1
+ self.assertRaises(frappe.ValidationError, sales_order.save)
+
def test_make_sales_order_with_different_currency(self):
from erpnext.selling.doctype.quotation.quotation import make_sales_order
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 78e2370..0013c95 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -194,7 +194,7 @@
)
if cint(frappe.db.get_single_value("Selling Settings", "maintain_same_sales_rate")):
- self.validate_rate_with_reference_doc([["Quotation", "prev_docname", "quotation_item"]])
+ self.validate_rate_with_reference_doc([["Quotation", "prevdoc_docname", "quotation_item"]])
def update_enquiry_status(self, prevdoc, flag):
enq = frappe.db.sql(