[BUG] Map Production Order with the exact Sales Order line item

This commit is contained in:
Neil Lasrado 2017-09-15 21:06:04 +05:30 committed by Neil Trini Lasrado
parent 5afc194742
commit af091ac5dd
3 changed files with 37 additions and 3 deletions

View File

@ -1314,6 +1314,36 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "sales_order_item",
"fieldtype": "Data",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Sales Order Item",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
@ -1358,7 +1388,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2017-07-10 14:29:00.457874", "modified": "2017-09-15 11:34:10.018611",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Manufacturing", "module": "Manufacturing",
"name": "Production Order", "name": "Production Order",

View File

@ -213,6 +213,8 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
}}, }},
{fieldtype:'Float', fieldname:'pending_qty', reqd: 1, {fieldtype:'Float', fieldname:'pending_qty', reqd: 1,
label: __('Qty'), in_list_view:1}, label: __('Qty'), in_list_view:1},
{fieldtype:'Data', fieldname:'sales_order_item', reqd: 1,
label: __('Sales Order Item'), hidden:1}
], ],
get_data: function() { get_data: function() {
return r.message return r.message

View File

@ -337,13 +337,14 @@ class SalesOrder(SellingController):
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
pending_qty= stock_qty - flt(frappe.db.sql('''select sum(qty) from `tabProduction Order` pending_qty= stock_qty - flt(frappe.db.sql('''select sum(qty) from `tabProduction Order`
where production_item=%s and sales_order=%s and docstatus<2''', (i.item_code, self.name))[0][0]) where production_item=%s and sales_order=%s and sales_order_item = %s and docstatus<2''', (i.item_code, self.name, i.name))[0][0])
if pending_qty: if pending_qty:
items.append(dict( items.append(dict(
item_code= i.item_code, item_code= i.item_code,
bom = bom, bom = bom,
warehouse = i.warehouse, warehouse = i.warehouse,
pending_qty = pending_qty pending_qty = pending_qty,
sales_order_item = i.name
)) ))
return items return items
@ -768,6 +769,7 @@ def make_production_orders(items, sales_order, company, project=None):
qty=i['pending_qty'], qty=i['pending_qty'],
company=company, company=company,
sales_order=sales_order, sales_order=sales_order,
sales_order_item=i['sales_order_item'],
project=project, project=project,
fg_warehouse=i['warehouse'] fg_warehouse=i['warehouse']
)).insert() )).insert()