fix: use ceil in case of whole uoms for reorder qty (#27834)

* fix: use ceil in case of whole uoms for reorder qty

* fix: cache uom query
This commit is contained in:
Alan 2021-10-06 18:16:33 +05:30 committed by GitHub
parent d36849e4f8
commit d4b2471cea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import json
from math import ceil
import frappe
from frappe import _
@ -149,11 +150,16 @@ def create_material_request(material_requests):
conversion_factor = frappe.db.get_value("UOM Conversion Detail",
{'parent': item.name, 'uom': uom}, 'conversion_factor') or 1.0
must_be_whole_number = frappe.db.get_value("UOM", uom, "must_be_whole_number", cache=True)
qty = d.reorder_qty / conversion_factor
if must_be_whole_number:
qty = ceil(qty)
mr.append("items", {
"doctype": "Material Request Item",
"item_code": d.item_code,
"schedule_date": add_days(nowdate(),cint(item.lead_time_days)),
"qty": d.reorder_qty / conversion_factor,
"qty": qty,
"uom": uom,
"stock_uom": item.stock_uom,
"warehouse": d.warehouse,