mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 18:59:08 +00:00
Production cleanup with linking with sales order
This commit is contained in:
@@ -154,25 +154,13 @@ class DocType(TransactionBase):
|
||||
|
||||
|
||||
|
||||
def get_raw_materials(self, bom_no, fg_qty, consider_sa_items_as_rm):
|
||||
def get_raw_materials(self, bom_no, fg_qty, use_multi_level_bom):
|
||||
"""
|
||||
get all items from flat bom except
|
||||
child items of sub-contracted and sub assembly items
|
||||
and sub assembly items itself.
|
||||
"""
|
||||
if consider_sa_items_as_rm == 'Yes':
|
||||
# Get all raw materials considering SA items as raw materials,
|
||||
# so no childs of SA items
|
||||
fl_bom_sa_items = sql("""
|
||||
select item_code, ifnull(sum(qty_consumed_per_unit), 0) * '%s', description, stock_uom
|
||||
from `tabBOM Item`
|
||||
where parent = '%s' and docstatus < 2
|
||||
group by item_code
|
||||
""" % (fg_qty, bom_no))
|
||||
|
||||
self.make_items_dict(fl_bom_sa_items)
|
||||
|
||||
else:
|
||||
if use_multi_level_bom:
|
||||
# get all raw materials with sub assembly childs
|
||||
fl_bom_sa_child_item = sql("""
|
||||
select
|
||||
@@ -187,6 +175,17 @@ class DocType(TransactionBase):
|
||||
group by item_code,stock_uom
|
||||
""" , (fg_qty, bom_no))
|
||||
self.make_items_dict(fl_bom_sa_child_item)
|
||||
else:
|
||||
# Get all raw materials considering multi level BOM,
|
||||
# if multi level bom consider childs of Sub-Assembly items
|
||||
fl_bom_sa_items = sql("""
|
||||
select item_code, ifnull(sum(qty_consumed_per_unit), 0) * '%s', description, stock_uom
|
||||
from `tabBOM Item`
|
||||
where parent = '%s' and docstatus < 2
|
||||
group by item_code
|
||||
""" % (fg_qty, bom_no))
|
||||
|
||||
self.make_items_dict(fl_bom_sa_items)
|
||||
|
||||
# Update only qty remaining to be issued for production
|
||||
if self.doc.process == 'Material Transfer':
|
||||
@@ -214,12 +213,8 @@ class DocType(TransactionBase):
|
||||
if self.doc.bom_no:
|
||||
if not self.doc.fg_completed_qty:
|
||||
msgprint("Please enter FG Completed Qty", raise_exception=1)
|
||||
if not self.doc.consider_sa_items_as_raw_materials:
|
||||
msgprint("Please confirm whether you want to consider sub assembly item as raw materials", raise_exception=1)
|
||||
|
||||
|
||||
# get items
|
||||
#------------------
|
||||
def get_items(self):
|
||||
if self.doc.purpose == 'Production Order':
|
||||
pro_obj = self.doc.production_order and get_obj('Production Order', self.doc.production_order) or ''
|
||||
@@ -227,14 +222,14 @@ class DocType(TransactionBase):
|
||||
|
||||
bom_no = pro_obj.doc.bom_no
|
||||
fg_qty = (self.doc.process == 'Backflush') and flt(self.doc.fg_completed_qty) or flt(pro_obj.doc.qty)
|
||||
consider_sa_items_as_rm = pro_obj.doc.consider_sa_items
|
||||
use_multi_level_bom = pro_obj.doc.use_multi_level_bom
|
||||
elif self.doc.purpose == 'Other':
|
||||
self.validate_bom_no()
|
||||
bom_no = self.doc.bom_no
|
||||
fg_qty = self.doc.fg_completed_qty
|
||||
consider_sa_items_as_rm = self.doc.consider_sa_items_as_raw_materials
|
||||
use_multi_level_bom = self.doc.use_multi_level_bom
|
||||
|
||||
self.get_raw_materials(bom_no, fg_qty, consider_sa_items_as_rm)
|
||||
self.get_raw_materials(bom_no, fg_qty, use_multi_level_bom)
|
||||
self.doclist = self.doc.clear_table(self.doclist, 'mtn_details', 1)
|
||||
|
||||
sw = (self.doc.process == 'Backflush') and cstr(pro_obj.doc.wip_warehouse) or ''
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
{
|
||||
"owner": "Administrator",
|
||||
"docstatus": 0,
|
||||
"creation": "2012-11-02 17:16:56",
|
||||
"creation": "2012-11-28 11:26:22",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-11-26 11:51:08"
|
||||
"modified": "2012-11-30 14:10:02"
|
||||
},
|
||||
{
|
||||
"is_submittable": 1,
|
||||
@@ -195,14 +195,13 @@
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "Select \"Yes\" if stock is maintained and tracked for sub-assembly items. Select \"No\" if you want child items of sub-assembly for material transfer.",
|
||||
"description": "If checked, BOM for sub-assembly items will be considered for getting raw materials. Otherwise, all sub-assembly items will be treated as a raw material.",
|
||||
"depends_on": "eval:doc.purpose == 'Other'",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Consider SA Items as Raw Materials",
|
||||
"options": "\nNo\nYes",
|
||||
"fieldname": "consider_sa_items_as_raw_materials",
|
||||
"fieldtype": "Select",
|
||||
"label": "Use Multi-Level BOM",
|
||||
"fieldname": "use_multi_level_bom",
|
||||
"fieldtype": "Check",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user