Skip to content

Commit

Permalink
Merge pull request #39488 from rohitwaghchaure/fixed-validate-stock-u…
Browse files Browse the repository at this point in the history
…om-integer-value

fix: UOM needs to be whole number not being checked in quotations
  • Loading branch information
rohitwaghchaure authored Jan 22, 2024
2 parents 4c20a47 + aaf83da commit 60809ce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion erpnext/selling/doctype/quotation/quotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ def set_indicator(self):
def validate(self):
super(Quotation, self).validate()
self.set_status()
self.validate_uom_is_integer("stock_uom", "qty")
self.validate_uom_is_integer("stock_uom", "stock_qty")
self.validate_uom_is_integer("uom", "qty")
self.validate_valid_till()
self.set_customer_name()
if self.items:
Expand Down
16 changes: 16 additions & 0 deletions erpnext/selling/doctype/quotation/test_quotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,22 @@ def test_alternative_items_sales_order_mapping_with_stock_items(self):
quotation.reload()
self.assertEqual(quotation.status, "Ordered")

def test_uom_validation(self):
from erpnext.stock.doctype.item.test_item import make_item

item = "_Test Item FOR UOM Validation"
make_item(item, {"is_stock_item": 1})

if not frappe.db.exists("UOM", "lbs"):
frappe.get_doc({"doctype": "UOM", "uom_name": "lbs", "must_be_whole_number": 1}).insert()
else:
frappe.db.set_value("UOM", "lbs", "must_be_whole_number", 1)

quotation = make_quotation(item_code=item, qty=1, rate=100, do_not_submit=1)
quotation.items[0].uom = "lbs"
quotation.items[0].conversion_factor = 2.23
self.assertRaises(frappe.ValidationError, quotation.save)


test_records = frappe.get_test_records("Quotation")

Expand Down

0 comments on commit 60809ce

Please sign in to comment.