Merge pull request #23688 from rohitwaghchaure/fixed-overproduction-issue-develop
fix: overproduction issue develop
This commit is contained in:
commit
b74d17b1e3
@ -636,7 +636,7 @@ erpnext.work_order = {
|
|||||||
description: __('Max: {0}', [max]),
|
description: __('Max: {0}', [max]),
|
||||||
default: max
|
default: max
|
||||||
}, data => {
|
}, data => {
|
||||||
max += (max * (frm.doc.__onload.overproduction_percentage || 0.0)) / 100;
|
max += (frm.doc.qty * (frm.doc.__onload.overproduction_percentage || 0.0)) / 100;
|
||||||
|
|
||||||
if (data.qty > max) {
|
if (data.qty > max) {
|
||||||
frappe.msgprint(__('Quantity must not be more than {0}', [max]));
|
frappe.msgprint(__('Quantity must not be more than {0}', [max]));
|
||||||
|
@ -96,7 +96,7 @@ class StockEntry(StockController):
|
|||||||
self.update_quality_inspection()
|
self.update_quality_inspection()
|
||||||
if self.work_order and self.purpose == "Manufacture":
|
if self.work_order and self.purpose == "Manufacture":
|
||||||
self.update_so_in_serial_number()
|
self.update_so_in_serial_number()
|
||||||
|
|
||||||
if self.purpose == 'Material Transfer' and self.add_to_transit:
|
if self.purpose == 'Material Transfer' and self.add_to_transit:
|
||||||
self.set_material_request_transfer_status('In Transit')
|
self.set_material_request_transfer_status('In Transit')
|
||||||
if self.purpose == 'Material Transfer' and self.outgoing_stock_entry:
|
if self.purpose == 'Material Transfer' and self.outgoing_stock_entry:
|
||||||
@ -849,6 +849,8 @@ class StockEntry(StockController):
|
|||||||
frappe.throw(_("Posting date and posting time is mandatory"))
|
frappe.throw(_("Posting date and posting time is mandatory"))
|
||||||
|
|
||||||
self.set_work_order_details()
|
self.set_work_order_details()
|
||||||
|
self.flags.backflush_based_on = frappe.db.get_single_value("Manufacturing Settings",
|
||||||
|
"backflush_raw_materials_based_on")
|
||||||
|
|
||||||
if self.bom_no:
|
if self.bom_no:
|
||||||
|
|
||||||
@ -865,14 +867,16 @@ class StockEntry(StockController):
|
|||||||
item["to_warehouse"] = self.pro_doc.wip_warehouse
|
item["to_warehouse"] = self.pro_doc.wip_warehouse
|
||||||
self.add_to_stock_entry_detail(item_dict)
|
self.add_to_stock_entry_detail(item_dict)
|
||||||
|
|
||||||
elif (self.work_order and (self.purpose == "Manufacture" or self.purpose == "Material Consumption for Manufacture")
|
elif (self.work_order and (self.purpose == "Manufacture"
|
||||||
and not self.pro_doc.skip_transfer and backflush_based_on == "Material Transferred for Manufacture"):
|
or self.purpose == "Material Consumption for Manufacture") and not self.pro_doc.skip_transfer
|
||||||
|
and self.flags.backflush_based_on == "Material Transferred for Manufacture"):
|
||||||
self.get_transfered_raw_materials()
|
self.get_transfered_raw_materials()
|
||||||
|
|
||||||
elif (self.work_order and backflush_based_on== "BOM" and
|
elif (self.work_order and (self.purpose == "Manufacture" or
|
||||||
(self.purpose == "Manufacture" or self.purpose == "Material Consumption for Manufacture")
|
self.purpose == "Material Consumption for Manufacture") and self.flags.backflush_based_on== "BOM"
|
||||||
and frappe.db.get_single_value("Manufacturing Settings", "material_consumption")== 1):
|
and frappe.db.get_single_value("Manufacturing Settings", "material_consumption")== 1):
|
||||||
self.get_unconsumed_raw_materials()
|
self.get_unconsumed_raw_materials()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if not self.fg_completed_qty:
|
if not self.fg_completed_qty:
|
||||||
frappe.throw(_("Manufacturing Quantity is mandatory"))
|
frappe.throw(_("Manufacturing Quantity is mandatory"))
|
||||||
@ -1111,7 +1115,6 @@ class StockEntry(StockController):
|
|||||||
for d in backflushed_materials.get(item.item_code):
|
for d in backflushed_materials.get(item.item_code):
|
||||||
if d.get(item.warehouse):
|
if d.get(item.warehouse):
|
||||||
if (qty > req_qty):
|
if (qty > req_qty):
|
||||||
qty = req_qty
|
|
||||||
qty-= d.get(item.warehouse)
|
qty-= d.get(item.warehouse)
|
||||||
|
|
||||||
if qty > 0:
|
if qty > 0:
|
||||||
@ -1137,12 +1140,24 @@ class StockEntry(StockController):
|
|||||||
item_dict = self.get_pro_order_required_items(backflush_based_on)
|
item_dict = self.get_pro_order_required_items(backflush_based_on)
|
||||||
|
|
||||||
max_qty = flt(self.pro_doc.qty)
|
max_qty = flt(self.pro_doc.qty)
|
||||||
|
|
||||||
|
allow_overproduction = False
|
||||||
|
overproduction_percentage = flt(frappe.db.get_single_value("Manufacturing Settings",
|
||||||
|
"overproduction_percentage_for_work_order"))
|
||||||
|
|
||||||
|
to_transfer_qty = flt(self.pro_doc.material_transferred_for_manufacturing) + flt(self.fg_completed_qty)
|
||||||
|
transfer_limit_qty = max_qty + ((max_qty * overproduction_percentage) / 100)
|
||||||
|
|
||||||
|
if transfer_limit_qty >= to_transfer_qty:
|
||||||
|
allow_overproduction = True
|
||||||
|
|
||||||
for item, item_details in iteritems(item_dict):
|
for item, item_details in iteritems(item_dict):
|
||||||
pending_to_issue = flt(item_details.required_qty) - flt(item_details.transferred_qty)
|
pending_to_issue = flt(item_details.required_qty) - flt(item_details.transferred_qty)
|
||||||
desire_to_transfer = flt(self.fg_completed_qty) * flt(item_details.required_qty) / max_qty
|
desire_to_transfer = flt(self.fg_completed_qty) * flt(item_details.required_qty) / max_qty
|
||||||
|
|
||||||
if (desire_to_transfer <= pending_to_issue or
|
if (desire_to_transfer <= pending_to_issue
|
||||||
(desire_to_transfer > 0 and backflush_based_on == "Material Transferred for Manufacture")):
|
or (desire_to_transfer > 0 and backflush_based_on == "Material Transferred for Manufacture")
|
||||||
|
or allow_overproduction):
|
||||||
item_dict[item]["qty"] = desire_to_transfer
|
item_dict[item]["qty"] = desire_to_transfer
|
||||||
elif pending_to_issue > 0:
|
elif pending_to_issue > 0:
|
||||||
item_dict[item]["qty"] = pending_to_issue
|
item_dict[item]["qty"] = pending_to_issue
|
||||||
@ -1370,7 +1385,7 @@ class StockEntry(StockController):
|
|||||||
if self.outgoing_stock_entry:
|
if self.outgoing_stock_entry:
|
||||||
parent_se = frappe.get_value("Stock Entry", self.outgoing_stock_entry, 'add_to_transit')
|
parent_se = frappe.get_value("Stock Entry", self.outgoing_stock_entry, 'add_to_transit')
|
||||||
|
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
material_request = item.material_request or None
|
material_request = item.material_request or None
|
||||||
if self.purpose == "Material Transfer" and material_request not in material_requests:
|
if self.purpose == "Material Transfer" and material_request not in material_requests:
|
||||||
if self.outgoing_stock_entry and parent_se:
|
if self.outgoing_stock_entry and parent_se:
|
||||||
@ -1430,7 +1445,7 @@ def make_stock_in_entry(source_name, target_doc=None):
|
|||||||
if add_to_transit:
|
if add_to_transit:
|
||||||
warehouse = frappe.get_value('Material Request Item', source_doc.material_request_item, 'warehouse')
|
warehouse = frappe.get_value('Material Request Item', source_doc.material_request_item, 'warehouse')
|
||||||
target_doc.t_warehouse = warehouse
|
target_doc.t_warehouse = warehouse
|
||||||
|
|
||||||
target_doc.s_warehouse = source_doc.t_warehouse
|
target_doc.s_warehouse = source_doc.t_warehouse
|
||||||
target_doc.qty = source_doc.qty - source_doc.transferred_qty
|
target_doc.qty = source_doc.qty - source_doc.transferred_qty
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user