[Fix] Making of production order from so, system not fetched the items from the sales order item if packing list has items and vice versa (#10453)
This commit is contained in:
parent
6b1624cfee
commit
0d9ab86496
@ -179,7 +179,7 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
|
|||||||
doc: this.frm.doc,
|
doc: this.frm.doc,
|
||||||
method: 'get_production_order_items',
|
method: 'get_production_order_items',
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if(!r.message.every(function(d) { return !!d.bom })) {
|
if(!r.message) {
|
||||||
frappe.msgprint({
|
frappe.msgprint({
|
||||||
title: __('Production Order not created'),
|
title: __('Production Order not created'),
|
||||||
message: __('No Items with Bill of Materials to Manufacture'),
|
message: __('No Items with Bill of Materials to Manufacture'),
|
||||||
|
@ -330,18 +330,19 @@ class SalesOrder(SellingController):
|
|||||||
def get_production_order_items(self):
|
def get_production_order_items(self):
|
||||||
'''Returns items with BOM that already do not have a linked production order'''
|
'''Returns items with BOM that already do not have a linked production order'''
|
||||||
items = []
|
items = []
|
||||||
for i in self.packed_items or self.items:
|
|
||||||
bom = frappe.get_all('BOM', dict(item=i.item_code, is_active=True),
|
for table in [self.items, self.packed_items]:
|
||||||
order_by='is_default desc')
|
for i in table:
|
||||||
bom = bom[0].name if bom else None
|
bom = get_default_bom_item(i.item_code)
|
||||||
stock_qty = i.qty if self.packed_items else i.stock_qty
|
if bom:
|
||||||
items.append(dict(
|
stock_qty = i.qty if i.doctype == 'Packed Item' else i.stock_qty
|
||||||
item_code= i.item_code,
|
items.append(dict(
|
||||||
bom = bom,
|
item_code= i.item_code,
|
||||||
warehouse = i.warehouse,
|
bom = bom,
|
||||||
pending_qty= stock_qty - flt(frappe.db.sql('''select sum(qty) from `tabProduction Order`
|
warehouse = i.warehouse,
|
||||||
where production_item=%s and sales_order=%s''', (i.item_code, self.name))[0][0])
|
pending_qty= stock_qty - flt(frappe.db.sql('''select sum(qty) from `tabProduction Order`
|
||||||
))
|
where production_item=%s and sales_order=%s''', (i.item_code, self.name))[0][0])
|
||||||
|
))
|
||||||
|
|
||||||
return items
|
return items
|
||||||
|
|
||||||
@ -774,3 +775,10 @@ def make_production_orders(items, sales_order, company, project=None):
|
|||||||
def update_status(status, name):
|
def update_status(status, name):
|
||||||
so = frappe.get_doc("Sales Order", name)
|
so = frappe.get_doc("Sales Order", name)
|
||||||
so.update_status(status)
|
so.update_status(status)
|
||||||
|
|
||||||
|
def get_default_bom_item(item_code):
|
||||||
|
bom = frappe.get_all('BOM', dict(item=item_code, is_active=True),
|
||||||
|
order_by='is_default desc')
|
||||||
|
bom = bom[0].name if bom else None
|
||||||
|
|
||||||
|
return bom
|
||||||
|
Loading…
Reference in New Issue
Block a user