[BUG] Fixes make Production Order from Sales Order

This commit is contained in:
Neil Lasrado 2017-09-14 18:32:27 +05:30 committed by Neil Trini Lasrado
parent 5fa2adcca9
commit 5afc194742
2 changed files with 10 additions and 9 deletions

View File

@ -193,7 +193,7 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
}); });
return; return;
} }
else if(!r.message.every(function(d) { return !!d.pending_qty })) { else if(!r.message) {
frappe.msgprint({ frappe.msgprint({
title: __('Production Order not created'), title: __('Production Order not created'),
message: __('Production Order already created for all items with BOM'), message: __('Production Order already created for all items with BOM'),

View File

@ -336,14 +336,15 @@ class SalesOrder(SellingController):
bom = get_default_bom_item(i.item_code) bom = get_default_bom_item(i.item_code)
if bom: if bom:
stock_qty = i.qty if i.doctype == 'Packed Item' else i.stock_qty stock_qty = i.qty if i.doctype == 'Packed Item' else i.stock_qty
items.append(dict( pending_qty= stock_qty - flt(frappe.db.sql('''select sum(qty) from `tabProduction Order`
item_code= i.item_code, where production_item=%s and sales_order=%s and docstatus<2''', (i.item_code, self.name))[0][0])
bom = bom, if pending_qty:
warehouse = i.warehouse, items.append(dict(
pending_qty= stock_qty - flt(frappe.db.sql('''select sum(qty) from `tabProduction Order` item_code= i.item_code,
where production_item=%s and sales_order=%s''', (i.item_code, self.name))[0][0]) bom = bom,
)) warehouse = i.warehouse,
pending_qty = pending_qty
))
return items return items
def on_recurring(self, reference_doc, subscription_doc): def on_recurring(self, reference_doc, subscription_doc):