Merge pull request #30233 from frappe/mergify/copy/develop/pr-30216

fix: max_qty validation condition in WO (copy #30216)
This commit is contained in:
Ankush Menat 2022-03-14 17:22:30 +05:30 committed by GitHub
commit 07712af357
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -655,6 +655,17 @@ class TestProductionPlan(FrappeTestCase):
]
self.assertFalse(pp.all_items_completed())
def test_production_plan_planned_qty(self):
pln = create_production_plan(item_code="_Test FG Item", planned_qty=0.55)
pln.make_work_order()
work_order = frappe.db.get_value('Work Order', {'production_plan': pln.name}, 'name')
wo_doc = frappe.get_doc('Work Order', work_order)
wo_doc.update({
'wip_warehouse': 'Work In Progress - _TC',
'fg_warehouse': 'Finished Goods - _TC'
})
wo_doc.submit()
self.assertEqual(wo_doc.qty, 0.55)
def create_production_plan(**args):
"""

View File

@ -647,12 +647,12 @@ class WorkOrder(Document):
if self.production_plan and self.production_plan_item:
qty_dict = frappe.db.get_value("Production Plan Item", self.production_plan_item, ["planned_qty", "ordered_qty"], as_dict=1)
allowance_qty =flt(frappe.db.get_single_value("Manufacturing Settings",
allowance_qty = flt(frappe.db.get_single_value("Manufacturing Settings",
"overproduction_percentage_for_work_order"))/100 * qty_dict.get("planned_qty", 0)
max_qty = qty_dict.get("planned_qty", 0) + allowance_qty - qty_dict.get("ordered_qty", 0)
if max_qty < 1:
if not max_qty > 0:
frappe.throw(_("Cannot produce more item for {0}")
.format(self.production_item), OverProductionError)
elif self.qty > max_qty: