Fix: Backflush issue due to missing BOM
This commit is contained in:
parent
c95bad917b
commit
2bc9423cd1
@ -86,8 +86,8 @@ class DocType:
|
|||||||
|
|
||||||
|
|
||||||
#------------- Wrapper Code --------------
|
#------------- Wrapper Code --------------
|
||||||
def calculate_cost( self, bom_no):
|
def calculate_cost(self, bom_no):
|
||||||
main_bom_list = get_obj(dt = 'Production Control').traverse_bom_tree( bom_no = bom_no, qty = 1, calculate_cost = 1)
|
main_bom_list = get_obj('Production Control').traverse_bom_tree( bom_no = bom_no, qty = 1, calculate_cost = 1)
|
||||||
main_bom_list.reverse()
|
main_bom_list.reverse()
|
||||||
for bom in main_bom_list:
|
for bom in main_bom_list:
|
||||||
bom_obj = get_obj('Bill Of Materials', bom, with_children = 1)
|
bom_obj = get_obj('Bill Of Materials', bom, with_children = 1)
|
||||||
|
|||||||
@ -87,7 +87,7 @@ class DocType:
|
|||||||
|
|
||||||
# get incoming rate
|
# get incoming rate
|
||||||
if not flt(d.incoming_rate):
|
if not flt(d.incoming_rate):
|
||||||
d.incoming_rate = self.get_incoming_rate(d.item_code, d.s_warehouse, self.doc.posting_date, self.doc.posting_time, d.transfer_qty, d.serial_no, d.fg_item, bom_no)
|
d.incoming_rate = self.get_incoming_rate(d.item_code, d.s_warehouse, self.doc.posting_date, self.doc.posting_time, d.transfer_qty, d.serial_no, d.fg_item, d.bom_no or bom_no)
|
||||||
|
|
||||||
|
|
||||||
# Get stock qty on any date
|
# Get stock qty on any date
|
||||||
@ -104,7 +104,7 @@ class DocType:
|
|||||||
# -------------------
|
# -------------------
|
||||||
def get_incoming_rate(self, item, wh, dt, tm, qty = 0, serial_no = '', fg_item = 0, bom_no = ''):
|
def get_incoming_rate(self, item, wh, dt, tm, qty = 0, serial_no = '', fg_item = 0, bom_no = ''):
|
||||||
in_rate = 0
|
in_rate = 0
|
||||||
if fg_item:
|
if fg_item and bom_no:
|
||||||
# re-calculate cost for production item from bom
|
# re-calculate cost for production item from bom
|
||||||
get_obj('BOM Control').calculate_cost(bom_no)
|
get_obj('BOM Control').calculate_cost(bom_no)
|
||||||
in_rate = flt(get_value('Bill Of Materials', bom_no, 'total_cost'))
|
in_rate = flt(get_value('Bill Of Materials', bom_no, 'total_cost'))
|
||||||
@ -203,7 +203,7 @@ class DocType:
|
|||||||
se_child.qty = flt(item_dict[d][0])
|
se_child.qty = flt(item_dict[d][0])
|
||||||
se_child.transfer_qty = flt(item_dict[d][0])
|
se_child.transfer_qty = flt(item_dict[d][0])
|
||||||
se_child.conversion_factor = 1.00
|
se_child.conversion_factor = 1.00
|
||||||
|
if fg_item: se_child.bom_no = pro_obj.doc.bom_no
|
||||||
|
|
||||||
|
|
||||||
# get items
|
# get items
|
||||||
@ -305,6 +305,7 @@ class DocType:
|
|||||||
self.get_stock_and_rate(pro_obj and pro_obj.doc.bom_no or '')
|
self.get_stock_and_rate(pro_obj and pro_obj.doc.bom_no or '')
|
||||||
self.validate_warehouse(pro_obj)
|
self.validate_warehouse(pro_obj)
|
||||||
self.validate_incoming_rate()
|
self.validate_incoming_rate()
|
||||||
|
self.validate_bom_belongs_to_item()
|
||||||
self.calc_amount()
|
self.calc_amount()
|
||||||
get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Posting Date')
|
get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Posting Date')
|
||||||
|
|
||||||
@ -315,6 +316,15 @@ class DocType:
|
|||||||
for d in getlist(self.doclist, 'mtn_details'):
|
for d in getlist(self.doclist, 'mtn_details'):
|
||||||
if not flt(d.incoming_rate) and d.t_warehouse:
|
if not flt(d.incoming_rate) and d.t_warehouse:
|
||||||
msgprint("Rate is mandatory for Item: %s at row %s" % (d.item_code, d.idx), raise_exception=1)
|
msgprint("Rate is mandatory for Item: %s at row %s" % (d.item_code, d.idx), raise_exception=1)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_bom_belongs_to_item(self):
|
||||||
|
for d in getlist(self.doclist, 'mtn_details'):
|
||||||
|
if d.bom_no and not webnotes.conn.sql("""\
|
||||||
|
SELECT name FROM `tabBill Of Materials`
|
||||||
|
WHERE item = %s and name = %s
|
||||||
|
""", (d.item_code, d.bom_no)):
|
||||||
|
msgprint("BOM %s does not belong to Item: %s at row %s" % (d.bom_no, d.item_code, d.idx), raise_exception=1)
|
||||||
|
|
||||||
|
|
||||||
# Validate warehouse
|
# Validate warehouse
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
{
|
{
|
||||||
'creation': '2010-08-08 17:09:25',
|
'creation': '2010-08-08 17:09:25',
|
||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'modified': '2011-04-26 11:47:18',
|
'modified': '2012-01-12 11:51:57',
|
||||||
'modified_by': 'Administrator',
|
'modified_by': 'Administrator',
|
||||||
'owner': 'Administrator'
|
'owner': 'Administrator'
|
||||||
},
|
},
|
||||||
@ -14,6 +14,7 @@
|
|||||||
{
|
{
|
||||||
'autoname': 'MTND/.######',
|
'autoname': 'MTND/.######',
|
||||||
'colour': 'White:FFF',
|
'colour': 'White:FFF',
|
||||||
|
'default_print_format': 'Standard',
|
||||||
'doctype': 'DocType',
|
'doctype': 'DocType',
|
||||||
'istable': 1,
|
'istable': 1,
|
||||||
'module': 'Stock',
|
'module': 'Stock',
|
||||||
@ -21,7 +22,7 @@
|
|||||||
'section_style': 'Tray',
|
'section_style': 'Tray',
|
||||||
'server_code_error': ' ',
|
'server_code_error': ' ',
|
||||||
'show_in_menu': 0,
|
'show_in_menu': 0,
|
||||||
'version': 24
|
'version': 26
|
||||||
},
|
},
|
||||||
|
|
||||||
# These values are common for all DocField
|
# These values are common for all DocField
|
||||||
@ -44,13 +45,12 @@
|
|||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 's_warehouse',
|
'fieldname': 's_warehouse',
|
||||||
'fieldtype': 'Link',
|
'fieldtype': 'Link',
|
||||||
'idx': 1,
|
|
||||||
'in_filter': 1,
|
'in_filter': 1,
|
||||||
'label': 'Source Warehouse',
|
'label': 'Source Warehouse',
|
||||||
'oldfieldname': 's_warehouse',
|
'oldfieldname': 's_warehouse',
|
||||||
'oldfieldtype': 'Link',
|
'oldfieldtype': 'Link',
|
||||||
'options': 'Warehouse',
|
'options': 'Warehouse',
|
||||||
'permlevel': 2
|
'permlevel': 0
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
@ -58,13 +58,12 @@
|
|||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 't_warehouse',
|
'fieldname': 't_warehouse',
|
||||||
'fieldtype': 'Link',
|
'fieldtype': 'Link',
|
||||||
'idx': 2,
|
|
||||||
'in_filter': 1,
|
'in_filter': 1,
|
||||||
'label': 'Target Warehouse',
|
'label': 'Target Warehouse',
|
||||||
'oldfieldname': 't_warehouse',
|
'oldfieldname': 't_warehouse',
|
||||||
'oldfieldtype': 'Link',
|
'oldfieldtype': 'Link',
|
||||||
'options': 'Warehouse',
|
'options': 'Warehouse',
|
||||||
'permlevel': 2
|
'permlevel': 0
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
@ -72,12 +71,11 @@
|
|||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 'fg_item',
|
'fieldname': 'fg_item',
|
||||||
'fieldtype': 'Check',
|
'fieldtype': 'Check',
|
||||||
'idx': 3,
|
|
||||||
'in_filter': 1,
|
'in_filter': 1,
|
||||||
'label': 'FG Item',
|
'label': 'FG Item',
|
||||||
'oldfieldname': 'fg_item',
|
'oldfieldname': 'fg_item',
|
||||||
'oldfieldtype': 'Check',
|
'oldfieldtype': 'Check',
|
||||||
'permlevel': 2,
|
'permlevel': 0,
|
||||||
'print_hide': 1
|
'print_hide': 1
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -86,7 +84,6 @@
|
|||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 'item_code',
|
'fieldname': 'item_code',
|
||||||
'fieldtype': 'Link',
|
'fieldtype': 'Link',
|
||||||
'idx': 4,
|
|
||||||
'in_filter': 1,
|
'in_filter': 1,
|
||||||
'label': 'Item Code',
|
'label': 'Item Code',
|
||||||
'oldfieldname': 'item_code',
|
'oldfieldname': 'item_code',
|
||||||
@ -98,24 +95,11 @@
|
|||||||
'trigger': 'Client'
|
'trigger': 'Client'
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': 'DocField',
|
|
||||||
'fieldname': 'item_name',
|
|
||||||
'fieldtype': 'Data',
|
|
||||||
'idx': 5,
|
|
||||||
'in_filter': 1,
|
|
||||||
'label': 'Item Name',
|
|
||||||
'permlevel': 0,
|
|
||||||
'search_index': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 'description',
|
'fieldname': 'description',
|
||||||
'fieldtype': 'Text',
|
'fieldtype': 'Text',
|
||||||
'idx': 6,
|
|
||||||
'label': 'Description',
|
'label': 'Description',
|
||||||
'oldfieldname': 'description',
|
'oldfieldname': 'description',
|
||||||
'oldfieldtype': 'Text',
|
'oldfieldtype': 'Text',
|
||||||
@ -128,14 +112,12 @@
|
|||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 'batch_no',
|
'fieldname': 'batch_no',
|
||||||
'fieldtype': 'Link',
|
'fieldtype': 'Link',
|
||||||
'idx': 7,
|
|
||||||
'label': 'Batch No',
|
'label': 'Batch No',
|
||||||
'oldfieldname': 'batch_no',
|
'oldfieldname': 'batch_no',
|
||||||
'oldfieldtype': 'Link',
|
'oldfieldtype': 'Link',
|
||||||
'options': 'Batch',
|
'options': 'Batch',
|
||||||
'permlevel': 0,
|
'permlevel': 0,
|
||||||
'print_hide': 1,
|
'print_hide': 1,
|
||||||
'search_index': 0,
|
|
||||||
'trigger': 'Client'
|
'trigger': 'Client'
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -144,7 +126,6 @@
|
|||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 'actual_qty',
|
'fieldname': 'actual_qty',
|
||||||
'fieldtype': 'Read Only',
|
'fieldtype': 'Read Only',
|
||||||
'idx': 8,
|
|
||||||
'in_filter': 1,
|
'in_filter': 1,
|
||||||
'label': 'Actual Qty (at source)',
|
'label': 'Actual Qty (at source)',
|
||||||
'no_copy': 1,
|
'no_copy': 1,
|
||||||
@ -153,7 +134,7 @@
|
|||||||
'permlevel': 1,
|
'permlevel': 1,
|
||||||
'print_hide': 1,
|
'print_hide': 1,
|
||||||
'reqd': 0,
|
'reqd': 0,
|
||||||
'search_index': 0
|
'search_index': 1
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
@ -161,7 +142,6 @@
|
|||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 'qty',
|
'fieldname': 'qty',
|
||||||
'fieldtype': 'Currency',
|
'fieldtype': 'Currency',
|
||||||
'idx': 9,
|
|
||||||
'label': 'Qty',
|
'label': 'Qty',
|
||||||
'oldfieldname': 'qty',
|
'oldfieldname': 'qty',
|
||||||
'oldfieldtype': 'Currency',
|
'oldfieldtype': 'Currency',
|
||||||
@ -175,7 +155,6 @@
|
|||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 'reqd_qty',
|
'fieldname': 'reqd_qty',
|
||||||
'fieldtype': 'Currency',
|
'fieldtype': 'Currency',
|
||||||
'idx': 10,
|
|
||||||
'in_filter': 0,
|
'in_filter': 0,
|
||||||
'label': 'Reqd Qty',
|
'label': 'Reqd Qty',
|
||||||
'oldfieldname': 'reqd_qty',
|
'oldfieldname': 'reqd_qty',
|
||||||
@ -190,14 +169,12 @@
|
|||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 'uom',
|
'fieldname': 'uom',
|
||||||
'fieldtype': 'Link',
|
'fieldtype': 'Link',
|
||||||
'idx': 11,
|
|
||||||
'label': 'UOM',
|
'label': 'UOM',
|
||||||
'oldfieldname': 'uom',
|
'oldfieldname': 'uom',
|
||||||
'oldfieldtype': 'Link',
|
'oldfieldtype': 'Link',
|
||||||
'options': 'UOM',
|
'options': 'UOM',
|
||||||
'permlevel': 0,
|
'permlevel': 0,
|
||||||
'reqd': 1,
|
'reqd': 1,
|
||||||
'search_index': 0,
|
|
||||||
'trigger': 'Client'
|
'trigger': 'Client'
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -206,7 +183,6 @@
|
|||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 'conversion_factor',
|
'fieldname': 'conversion_factor',
|
||||||
'fieldtype': 'Currency',
|
'fieldtype': 'Currency',
|
||||||
'idx': 12,
|
|
||||||
'label': 'Conversion Factor',
|
'label': 'Conversion Factor',
|
||||||
'oldfieldname': 'conversion_factor',
|
'oldfieldname': 'conversion_factor',
|
||||||
'oldfieldtype': 'Currency',
|
'oldfieldtype': 'Currency',
|
||||||
@ -219,7 +195,6 @@
|
|||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 'stock_uom',
|
'fieldname': 'stock_uom',
|
||||||
'fieldtype': 'Link',
|
'fieldtype': 'Link',
|
||||||
'idx': 13,
|
|
||||||
'in_filter': 0,
|
'in_filter': 0,
|
||||||
'label': 'Stock UOM',
|
'label': 'Stock UOM',
|
||||||
'oldfieldname': 'stock_uom',
|
'oldfieldname': 'stock_uom',
|
||||||
@ -235,7 +210,6 @@
|
|||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 'transfer_qty',
|
'fieldname': 'transfer_qty',
|
||||||
'fieldtype': 'Currency',
|
'fieldtype': 'Currency',
|
||||||
'idx': 14,
|
|
||||||
'label': 'Stock Qty',
|
'label': 'Stock Qty',
|
||||||
'oldfieldname': 'transfer_qty',
|
'oldfieldname': 'transfer_qty',
|
||||||
'oldfieldtype': 'Currency',
|
'oldfieldtype': 'Currency',
|
||||||
@ -248,7 +222,6 @@
|
|||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 'serial_no',
|
'fieldname': 'serial_no',
|
||||||
'fieldtype': 'Text',
|
'fieldtype': 'Text',
|
||||||
'idx': 15,
|
|
||||||
'label': 'Serial No',
|
'label': 'Serial No',
|
||||||
'no_copy': 1,
|
'no_copy': 1,
|
||||||
'oldfieldname': 'serial_no',
|
'oldfieldname': 'serial_no',
|
||||||
@ -262,7 +235,6 @@
|
|||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 'incoming_rate',
|
'fieldname': 'incoming_rate',
|
||||||
'fieldtype': 'Currency',
|
'fieldtype': 'Currency',
|
||||||
'idx': 16,
|
|
||||||
'label': 'Incoming Rate',
|
'label': 'Incoming Rate',
|
||||||
'oldfieldname': 'incoming_rate',
|
'oldfieldname': 'incoming_rate',
|
||||||
'oldfieldtype': 'Currency',
|
'oldfieldtype': 'Currency',
|
||||||
@ -275,10 +247,20 @@
|
|||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 'amount',
|
'fieldname': 'amount',
|
||||||
'fieldtype': 'Currency',
|
'fieldtype': 'Currency',
|
||||||
'idx': 17,
|
|
||||||
'label': 'Amount',
|
'label': 'Amount',
|
||||||
'oldfieldname': 'amount',
|
'oldfieldname': 'amount',
|
||||||
'oldfieldtype': 'Currency',
|
'oldfieldtype': 'Currency',
|
||||||
'permlevel': 1
|
'permlevel': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'description': 'BOM No. for a Finished Good Item',
|
||||||
|
'doctype': 'DocField',
|
||||||
|
'fieldname': 'bom_no',
|
||||||
|
'fieldtype': 'Link',
|
||||||
|
'label': 'BOM No.',
|
||||||
|
'options': 'Bill Of Materials',
|
||||||
|
'permlevel': 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Loading…
x
Reference in New Issue
Block a user