fix: UOM needs to be whole number not being checked in quotations

(cherry picked from commit aaf83da3e9a28244c0f57f01a86b98257bdf503b)
This commit is contained in:
Rohit Waghchaure 2024-01-22 16:43:54 +05:30 committed by Mergify
parent b53e072082
commit c7d5857014
2 changed files with 18 additions and 1 deletions

View File

@ -127,7 +127,8 @@ class Quotation(SellingController):
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:

View File

@ -581,6 +581,22 @@ class TestQuotation(FrappeTestCase):
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")