Skip to content

Commit

Permalink
Merge pull request #33281 from tundebabzy/29976
Browse files Browse the repository at this point in the history
fix: maintain same rate throughout sales cycle doesn't work with quotation
  • Loading branch information
rohitwaghchaure authored Dec 12, 2022
2 parents 915e034 + 71aa8c5 commit 5c0f8ee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions erpnext/selling/doctype/quotation/test_quotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ def test_make_sales_order_terms_copied(self):

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

maintain_rate = frappe.db.get_single_value("Selling Settings", "maintain_same_sales_rate")
frappe.db.set_single_value("Selling Settings", "maintain_same_sales_rate", 1)

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)

frappe.db.set_single_value("Selling Settings", "maintain_same_sales_rate", maintain_rate)

def test_make_sales_order_with_different_currency(self):
from erpnext.selling.doctype.quotation.quotation import make_sales_order

Expand Down
2 changes: 1 addition & 1 deletion erpnext/selling/doctype/sales_order/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def validate_with_previous_doc(self):
)

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(
Expand Down

0 comments on commit 5c0f8ee

Please sign in to comment.