Skip to content

Commit

Permalink
fix: use ceil in case of whole uoms for reorder qty (#27834)
Browse files Browse the repository at this point in the history
* fix: use ceil in case of whole uoms for reorder qty

* fix: cache uom query
  • Loading branch information
18alantom authored Oct 6, 2021
1 parent d36849e commit d4b2471
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion erpnext/stock/reorder_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import unicode_literals

import json
from math import ceil

import frappe
from frappe import _
Expand Down Expand Up @@ -149,11 +150,16 @@ def _log_exception():
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,
Expand Down

0 comments on commit d4b2471

Please sign in to comment.