fix: min order qty optional in production plan (#38956)
* fix: min order qty optional in production plan * fix: test cases
This commit is contained in:
parent
d00f6672a8
commit
b09c9354fb
@ -218,6 +218,7 @@
|
|||||||
"options": "\nWork Order\nJob Card"
|
"options": "\nWork Order\nJob Card"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"default": "1",
|
||||||
"fieldname": "conversion_rate",
|
"fieldname": "conversion_rate",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"label": "Conversion Rate",
|
"label": "Conversion Rate",
|
||||||
@ -636,7 +637,7 @@
|
|||||||
"image_field": "image",
|
"image_field": "image",
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-08-07 11:38:08.152294",
|
"modified": "2023-12-26 19:34:08.159312",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "BOM",
|
"name": "BOM",
|
||||||
|
@ -305,6 +305,8 @@ frappe.ui.form.on('Production Plan', {
|
|||||||
frappe.throw(__("Select the Warehouse"));
|
frappe.throw(__("Select the Warehouse"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frm.set_value("consider_minimum_order_qty", 0);
|
||||||
|
|
||||||
if (frm.doc.ignore_existing_ordered_qty) {
|
if (frm.doc.ignore_existing_ordered_qty) {
|
||||||
frm.events.get_items_for_material_requests(frm);
|
frm.events.get_items_for_material_requests(frm);
|
||||||
} else {
|
} else {
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
"material_request_planning",
|
"material_request_planning",
|
||||||
"include_non_stock_items",
|
"include_non_stock_items",
|
||||||
"include_subcontracted_items",
|
"include_subcontracted_items",
|
||||||
|
"consider_minimum_order_qty",
|
||||||
"include_safety_stock",
|
"include_safety_stock",
|
||||||
"ignore_existing_ordered_qty",
|
"ignore_existing_ordered_qty",
|
||||||
"column_break_25",
|
"column_break_25",
|
||||||
@ -423,13 +424,19 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Sub Assembly Warehouse",
|
"label": "Sub Assembly Warehouse",
|
||||||
"options": "Warehouse"
|
"options": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "consider_minimum_order_qty",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Consider Minimum Order Qty"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-calendar",
|
"icon": "fa fa-calendar",
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-11-03 14:08:11.928027",
|
"modified": "2023-12-26 16:31:13.740777",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Production Plan",
|
"name": "Production Plan",
|
||||||
|
@ -67,6 +67,7 @@ class ProductionPlan(Document):
|
|||||||
combine_items: DF.Check
|
combine_items: DF.Check
|
||||||
combine_sub_items: DF.Check
|
combine_sub_items: DF.Check
|
||||||
company: DF.Link
|
company: DF.Link
|
||||||
|
consider_minimum_order_qty: DF.Check
|
||||||
customer: DF.Link | None
|
customer: DF.Link | None
|
||||||
for_warehouse: DF.Link | None
|
for_warehouse: DF.Link | None
|
||||||
from_date: DF.Date | None
|
from_date: DF.Date | None
|
||||||
@ -1211,7 +1212,14 @@ def get_subitems(
|
|||||||
|
|
||||||
|
|
||||||
def get_material_request_items(
|
def get_material_request_items(
|
||||||
row, sales_order, company, ignore_existing_ordered_qty, include_safety_stock, warehouse, bin_dict
|
doc,
|
||||||
|
row,
|
||||||
|
sales_order,
|
||||||
|
company,
|
||||||
|
ignore_existing_ordered_qty,
|
||||||
|
include_safety_stock,
|
||||||
|
warehouse,
|
||||||
|
bin_dict,
|
||||||
):
|
):
|
||||||
total_qty = row["qty"]
|
total_qty = row["qty"]
|
||||||
|
|
||||||
@ -1220,8 +1228,14 @@ def get_material_request_items(
|
|||||||
required_qty = total_qty
|
required_qty = total_qty
|
||||||
elif total_qty > bin_dict.get("projected_qty", 0):
|
elif total_qty > bin_dict.get("projected_qty", 0):
|
||||||
required_qty = total_qty - bin_dict.get("projected_qty", 0)
|
required_qty = total_qty - bin_dict.get("projected_qty", 0)
|
||||||
if required_qty > 0 and required_qty < row["min_order_qty"]:
|
|
||||||
|
if (
|
||||||
|
doc.get("consider_minimum_order_qty")
|
||||||
|
and required_qty > 0
|
||||||
|
and required_qty < row["min_order_qty"]
|
||||||
|
):
|
||||||
required_qty = row["min_order_qty"]
|
required_qty = row["min_order_qty"]
|
||||||
|
|
||||||
item_group_defaults = get_item_group_defaults(row.item_code, company)
|
item_group_defaults = get_item_group_defaults(row.item_code, company)
|
||||||
|
|
||||||
if not row["purchase_uom"]:
|
if not row["purchase_uom"]:
|
||||||
@ -1559,6 +1573,7 @@ def get_items_for_material_requests(doc, warehouses=None, get_parent_warehouse_d
|
|||||||
|
|
||||||
if details.qty > 0:
|
if details.qty > 0:
|
||||||
items = get_material_request_items(
|
items = get_material_request_items(
|
||||||
|
doc,
|
||||||
details,
|
details,
|
||||||
sales_order,
|
sales_order,
|
||||||
company,
|
company,
|
||||||
|
@ -1499,6 +1499,29 @@ class TestProductionPlan(FrappeTestCase):
|
|||||||
after_qty = flt(frappe.db.get_value("Bin", bin_name, "reserved_qty_for_production_plan"))
|
after_qty = flt(frappe.db.get_value("Bin", bin_name, "reserved_qty_for_production_plan"))
|
||||||
self.assertAlmostEqual(after_qty, before_qty)
|
self.assertAlmostEqual(after_qty, before_qty)
|
||||||
|
|
||||||
|
def test_min_order_qty_in_pp(self):
|
||||||
|
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
|
||||||
|
from erpnext.stock.utils import get_or_make_bin
|
||||||
|
|
||||||
|
fg_item = make_item(properties={"is_stock_item": 1}).name
|
||||||
|
rm_item = make_item(properties={"is_stock_item": 1, "min_order_qty": 1000}).name
|
||||||
|
|
||||||
|
rm_warehouse = create_warehouse("RM Warehouse", company="_Test Company")
|
||||||
|
|
||||||
|
make_bom(item=fg_item, raw_materials=[rm_item], source_warehouse="_Test Warehouse - _TC")
|
||||||
|
|
||||||
|
pln = create_production_plan(item_code=fg_item, planned_qty=10, do_not_submit=1)
|
||||||
|
|
||||||
|
pln.for_warehouse = rm_warehouse
|
||||||
|
mr_items = get_items_for_material_requests(pln.as_dict())
|
||||||
|
for d in mr_items:
|
||||||
|
self.assertEqual(d.get("quantity"), 10.0)
|
||||||
|
|
||||||
|
pln.consider_minimum_order_qty = 1
|
||||||
|
mr_items = get_items_for_material_requests(pln.as_dict())
|
||||||
|
for d in mr_items:
|
||||||
|
self.assertEqual(d.get("quantity"), 1000.0)
|
||||||
|
|
||||||
|
|
||||||
def create_production_plan(**args):
|
def create_production_plan(**args):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user