mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-05 05:09:11 +00:00
stock entry: new purpose others added
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
{
|
{
|
||||||
'creation': '2010-08-08 17:09:35',
|
'creation': '2010-08-08 17:09:35',
|
||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'modified': '2012-03-01 17:58:16',
|
'modified': '2012-03-20 14:24:12',
|
||||||
'modified_by': u'Administrator',
|
'modified_by': u'Administrator',
|
||||||
'owner': u'Administrator'
|
'owner': u'Administrator'
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -23,12 +23,16 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
|||||||
|
|
||||||
var cfn_set_fields = function(doc, cdt, cdn) {
|
var cfn_set_fields = function(doc, cdt, cdn) {
|
||||||
lst = ['supplier','supplier_name','supplier_address','customer','customer_name','customer_address'];
|
lst = ['supplier','supplier_name','supplier_address','customer','customer_name','customer_address'];
|
||||||
if (doc.purpose == 'Production Order'){
|
hide_field(lst);
|
||||||
unhide_field(['production_order', 'process', 'Get Items']);
|
|
||||||
hide_field(['from_warehouse', 'to_warehouse','purchase_receipt_no','delivery_note_no', 'sales_invoice_no','Warehouse HTML']);
|
if (doc.purpose == 'Production Order' || doc.purpose == 'Others'){
|
||||||
doc.from_warehouse = '';
|
unhide_field('Get Items');
|
||||||
|
hide_field(['from_warehouse', 'to_warehouse','purchase_receipt_no','delivery_note_no', 'sales_invoice_no','Warehouse HTML', 'transporter', 'is_excisable_goods', 'excisable_goods']);
|
||||||
|
if (doc.purpose=='Production Order') unhide_field(['production_order', 'process']);
|
||||||
|
|
||||||
|
doc.from_warehouse = '';
|
||||||
doc.to_warehosue = '';
|
doc.to_warehosue = '';
|
||||||
if (doc.process == 'Backflush'){
|
if (doc.process == 'Backflush' || doc.purpose == 'Others'){
|
||||||
unhide_field('fg_completed_qty');
|
unhide_field('fg_completed_qty');
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -39,7 +43,6 @@ var cfn_set_fields = function(doc, cdt, cdn) {
|
|||||||
else{
|
else{
|
||||||
unhide_field(['from_warehouse', 'to_warehouse']);
|
unhide_field(['from_warehouse', 'to_warehouse']);
|
||||||
hide_field(['production_order', 'process', 'Get Items', 'fg_completed_qty','purchase_receipt_no','delivery_note_no', 'sales_invoice_no']);
|
hide_field(['production_order', 'process', 'Get Items', 'fg_completed_qty','purchase_receipt_no','delivery_note_no', 'sales_invoice_no']);
|
||||||
hide_field(lst);
|
|
||||||
doc.production_order = '';
|
doc.production_order = '';
|
||||||
doc.process = '';
|
doc.process = '';
|
||||||
doc.fg_completed_qty = 0;
|
doc.fg_completed_qty = 0;
|
||||||
@@ -48,12 +51,10 @@ var cfn_set_fields = function(doc, cdt, cdn) {
|
|||||||
|
|
||||||
if(doc.purpose == 'Purchase Return'){
|
if(doc.purpose == 'Purchase Return'){
|
||||||
doc.customer=doc.customer_name = doc.customer_address=doc.delivery_note_no=doc.sales_invoice_no='';
|
doc.customer=doc.customer_name = doc.customer_address=doc.delivery_note_no=doc.sales_invoice_no='';
|
||||||
hide_field(lst);
|
|
||||||
unhide_field(['supplier','supplier_name','supplier_address','purchase_receipt_no']);
|
unhide_field(['supplier','supplier_name','supplier_address','purchase_receipt_no']);
|
||||||
}
|
}
|
||||||
else if(doc.purpose == 'Sales Return'){
|
else if(doc.purpose == 'Sales Return'){
|
||||||
doc.supplier=doc.supplier_name = doc.supplier_address=doc.purchase_receipt_no='';
|
doc.supplier=doc.supplier_name = doc.supplier_address=doc.purchase_receipt_no='';
|
||||||
hide_field(lst);
|
|
||||||
unhide_field(['customer','customer_name','customer_address','delivery_note_no', 'sales_invoice_no']);
|
unhide_field(['customer','customer_name','customer_address','delivery_note_no', 'sales_invoice_no']);
|
||||||
} else{
|
} else{
|
||||||
doc.customer=doc.customer_name=doc.customer_address=doc.delivery_note_no=doc.sales_invoice_no=doc.supplier=doc.supplier_name = doc.supplier_address=doc.purchase_receipt_no='';
|
doc.customer=doc.customer_name=doc.customer_address=doc.delivery_note_no=doc.sales_invoice_no=doc.supplier=doc.supplier_name = doc.supplier_address=doc.purchase_receipt_no='';
|
||||||
|
|||||||
@@ -157,13 +157,13 @@ class DocType:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_raw_materials(self,pro_obj):
|
def get_raw_materials(self, bom_no, fg_qty, consider_sa_items_as_rm):
|
||||||
"""
|
"""
|
||||||
get all items from flat bom except
|
get all items from flat bom except
|
||||||
child items of sub-contracted and sub assembly items
|
child items of sub-contracted and sub assembly items
|
||||||
and sub assembly items itself.
|
and sub assembly items itself.
|
||||||
"""
|
"""
|
||||||
if pro_obj.doc.consider_sa_items == 'Yes':
|
if consider_sa_items_as_rm == 'Yes':
|
||||||
# Get all raw materials considering SA items as raw materials,
|
# Get all raw materials considering SA items as raw materials,
|
||||||
# so no childs of SA items
|
# so no childs of SA items
|
||||||
fl_bom_sa_items = sql("""
|
fl_bom_sa_items = sql("""
|
||||||
@@ -171,8 +171,7 @@ class DocType:
|
|||||||
from `tabBOM Material`
|
from `tabBOM Material`
|
||||||
where parent = '%s' and docstatus < 2
|
where parent = '%s' and docstatus < 2
|
||||||
group by item_code
|
group by item_code
|
||||||
""" % ((self.doc.process == 'Backflush') and flt(self.doc.fg_completed_qty) \
|
""" % (fg_qty, bom_no))
|
||||||
or flt(pro_obj.doc.qty), cstr(pro_obj.doc.bom_no)))
|
|
||||||
|
|
||||||
self.make_items_dict(fl_bom_sa_items)
|
self.make_items_dict(fl_bom_sa_items)
|
||||||
|
|
||||||
@@ -189,8 +188,7 @@ class DocType:
|
|||||||
and ifnull(it.is_sub_contracted_item, 'No') = 'No' and fb.docstatus<2 and fb.parent=%s
|
and ifnull(it.is_sub_contracted_item, 'No') = 'No' and fb.docstatus<2 and fb.parent=%s
|
||||||
) a
|
) a
|
||||||
group by item_code,stock_uom
|
group by item_code,stock_uom
|
||||||
""" , ((self.doc.process == 'Backflush') and flt(self.doc.fg_completed_qty) \
|
""" , (fg_qty, bom_no))
|
||||||
or flt(pro_obj.doc.qty), cstr(pro_obj.doc.bom_no)))
|
|
||||||
self.make_items_dict(fl_bom_sa_child_item)
|
self.make_items_dict(fl_bom_sa_child_item)
|
||||||
|
|
||||||
# Update only qty remaining to be issued for production
|
# Update only qty remaining to be issued for production
|
||||||
@@ -199,17 +197,11 @@ class DocType:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def add_to_stock_entry_detail(self, pro_obj, item_dict, fg_item = 0):
|
def add_to_stock_entry_detail(self, source_wh, target_wh, item_dict, fg_item = 0, bom_no = ''):
|
||||||
sw, tw = '', ''
|
|
||||||
if self.doc.process == 'Material Transfer':
|
|
||||||
tw = cstr(pro_obj.doc.wip_warehouse)
|
|
||||||
if self.doc.process == 'Backflush':
|
|
||||||
tw = fg_item and cstr(pro_obj.doc.fg_warehouse) or ''
|
|
||||||
if not fg_item: sw = cstr(pro_obj.doc.wip_warehouse)
|
|
||||||
for d in item_dict:
|
for d in item_dict:
|
||||||
se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail', 0, self.doclist)
|
se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail', 0, self.doclist)
|
||||||
se_child.s_warehouse = sw
|
se_child.s_warehouse = source_wh
|
||||||
se_child.t_warehouse = tw
|
se_child.t_warehouse = target_wh
|
||||||
se_child.fg_item = fg_item
|
se_child.fg_item = fg_item
|
||||||
se_child.item_code = cstr(d)
|
se_child.item_code = cstr(d)
|
||||||
se_child.description = item_dict[d][1]
|
se_child.description = item_dict[d][1]
|
||||||
@@ -219,24 +211,52 @@ 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
|
if fg_item: se_child.bom_no = bom_no
|
||||||
|
|
||||||
|
def validate_bom_no(self):
|
||||||
|
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
|
# get items
|
||||||
#------------------
|
#------------------
|
||||||
def get_items(self):
|
def get_items(self):
|
||||||
pro_obj = self.doc.production_order and get_obj('Production Order', self.doc.production_order) or ''
|
if self.doc.purpose == 'Production Order':
|
||||||
|
pro_obj = self.doc.production_order and get_obj('Production Order', self.doc.production_order) or ''
|
||||||
|
self.validate_for_production_order(pro_obj)
|
||||||
|
|
||||||
self.validate_for_production_order(pro_obj)
|
bom_no = pro_obj.doc.bom_no
|
||||||
self.get_raw_materials(pro_obj)
|
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
|
||||||
|
elif self.doc.purpose == 'Others':
|
||||||
|
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
|
||||||
|
|
||||||
|
self.get_raw_materials(bom_no, fg_qty, consider_sa_items_as_rm)
|
||||||
self.doc.clear_table(self.doclist, 'mtn_details', 1)
|
self.doc.clear_table(self.doclist, 'mtn_details', 1)
|
||||||
|
|
||||||
self.add_to_stock_entry_detail(pro_obj, self.item_dict)
|
sw = (self.doc.process == 'Backflush') and cstr(pro_obj.doc.wip_warehouse) or ''
|
||||||
|
tw = (self.doc.process == 'Material Transfer') and cstr(pro_obj.doc.wip_warehouse) or ''
|
||||||
|
self.add_to_stock_entry_detail(sw, tw, self.item_dict)
|
||||||
|
|
||||||
|
fg_item_dict = {}
|
||||||
if self.doc.process == 'Backflush':
|
if self.doc.process == 'Backflush':
|
||||||
item_dict = {cstr(pro_obj.doc.production_item) : [self.doc.fg_completed_qty, pro_obj.doc.description, pro_obj.doc.stock_uom]}
|
sw = ''
|
||||||
self.add_to_stock_entry_detail(pro_obj, item_dict, fg_item = 1)
|
tw = cstr(pro_obj.doc.fg_warehouse)
|
||||||
|
fg_item_dict = {cstr(pro_obj.doc.production_item) : [self.doc.fg_completed_qty, pro_obj.doc.description, pro_obj.doc.stock_uom]}
|
||||||
|
elif self.doc.purpose == 'Others' and self.doc.bom_no:
|
||||||
|
sw, tw = '', ''
|
||||||
|
item = sql("select item, description, uom from `tabBill Of Materials` where name = %s", self.doc.bom_no, as_dict=1)
|
||||||
|
fg_item_dict = {item[0]['item'] : [self.doc.fg_completed_qty, item[0]['description'], item[0]['uom']]}
|
||||||
|
|
||||||
|
if fg_item_dict:
|
||||||
|
self.add_to_stock_entry_detail(sw, tw, fg_item_dict, fg_item = 1, bom_no = bom_no)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def validate_transfer_qty(self):
|
def validate_transfer_qty(self):
|
||||||
@@ -289,7 +309,7 @@ class DocType:
|
|||||||
|
|
||||||
|
|
||||||
def validate_for_production_order(self, pro_obj):
|
def validate_for_production_order(self, pro_obj):
|
||||||
if self.doc.purpose == 'Production Order' or self.doc.process or self.doc.production_order or flt(self.doc.fg_completed_qty):
|
if self.doc.purpose == 'Production Order' or self.doc.process or self.doc.production_order:
|
||||||
if self.doc.purpose != 'Production Order':
|
if self.doc.purpose != 'Production Order':
|
||||||
msgprint("Purpose should be 'Production Order'.")
|
msgprint("Purpose should be 'Production Order'.")
|
||||||
raise Exception
|
raise Exception
|
||||||
@@ -394,7 +414,6 @@ class DocType:
|
|||||||
if cstr(pro_obj.doc.production_item) != cstr(d.item_code):
|
if cstr(pro_obj.doc.production_item) != cstr(d.item_code):
|
||||||
msgprint("Item %s in Stock Entry Detail as Row No %s do not match with Item %s in Production Order %s" % (cstr(d.item_code), cstr(d.idx), cstr(pro_obj.doc.production_item), cstr(pro_obj.doc.name)))
|
msgprint("Item %s in Stock Entry Detail as Row No %s do not match with Item %s in Production Order %s" % (cstr(d.item_code), cstr(d.idx), cstr(pro_obj.doc.production_item), cstr(pro_obj.doc.name)))
|
||||||
raise Exception
|
raise Exception
|
||||||
fg_qty = flt(fg_qty) + flt(d.transfer_qty)
|
|
||||||
if cstr(d.t_warehouse) != cstr(pro_obj.doc.fg_warehouse):
|
if cstr(d.t_warehouse) != cstr(pro_obj.doc.fg_warehouse):
|
||||||
msgprint("As Item %s is FG Item. Target Warehouse should be same as FG Warehouse %s in Production Order %s, at Row No %s. " % ( cstr(d.item_code), cstr(pro_obj.doc.fg_warehouse), cstr(pro_obj.doc.name), cstr(d.idx)))
|
msgprint("As Item %s is FG Item. Target Warehouse should be same as FG Warehouse %s in Production Order %s, at Row No %s. " % ( cstr(d.item_code), cstr(pro_obj.doc.fg_warehouse), cstr(pro_obj.doc.name), cstr(d.idx)))
|
||||||
raise Exception
|
raise Exception
|
||||||
@@ -408,6 +427,9 @@ class DocType:
|
|||||||
if cstr(d.s_warehouse) != cstr(pro_obj.doc.wip_warehouse):
|
if cstr(d.s_warehouse) != cstr(pro_obj.doc.wip_warehouse):
|
||||||
msgprint("As Item %s is Raw Material. Source Warehouse should be same as WIP Warehouse %s in Production Order %s, at Row No %s. " % ( cstr(d.item_code), cstr(pro_obj.doc.wip_warehouse), cstr(pro_obj.doc.name), cstr(d.idx)))
|
msgprint("As Item %s is Raw Material. Source Warehouse should be same as WIP Warehouse %s in Production Order %s, at Row No %s. " % ( cstr(d.item_code), cstr(pro_obj.doc.wip_warehouse), cstr(pro_obj.doc.name), cstr(d.idx)))
|
||||||
raise Exception
|
raise Exception
|
||||||
|
if d.fg_item and (self.doc.purpose == 'Others' or self.doc.process == 'Backflush'):
|
||||||
|
fg_qty = flt(fg_qty) + flt(d.transfer_qty)
|
||||||
|
|
||||||
d.save()
|
d.save()
|
||||||
if self.doc.fg_completed_qty and flt(self.doc.fg_completed_qty) != flt(fg_qty):
|
if self.doc.fg_completed_qty and flt(self.doc.fg_completed_qty) != flt(fg_qty):
|
||||||
msgprint("The Total of FG Qty %s in Stock Entry Detail do not match with FG Completed Qty %s" % (flt(fg_qty), flt(self.doc.fg_completed_qty)))
|
msgprint("The Total of FG Qty %s in Stock Entry Detail do not match with FG Completed Qty %s" % (flt(fg_qty), flt(self.doc.fg_completed_qty)))
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user