Fixes in Production, Stock Entry and Stock Controller
This commit is contained in:
@@ -34,8 +34,7 @@ class StockController(AccountsController):
|
|||||||
warehouse_account = get_warehouse_account()
|
warehouse_account = get_warehouse_account()
|
||||||
|
|
||||||
stock_ledger = self.get_stock_ledger_details()
|
stock_ledger = self.get_stock_ledger_details()
|
||||||
voucher_details = self.get_voucher_details(stock_ledger, default_expense_account,
|
voucher_details = self.get_voucher_details(default_expense_account, default_cost_center)
|
||||||
default_cost_center)
|
|
||||||
|
|
||||||
gl_list = []
|
gl_list = []
|
||||||
warehouse_with_no_account = []
|
warehouse_with_no_account = []
|
||||||
@@ -73,12 +72,15 @@ class StockController(AccountsController):
|
|||||||
|
|
||||||
return process_gl_map(gl_list)
|
return process_gl_map(gl_list)
|
||||||
|
|
||||||
def get_voucher_details(self, stock_ledger, default_expense_account, default_cost_center):
|
def get_voucher_details(self, default_expense_account, default_cost_center):
|
||||||
details = self.get(self.fname)
|
details = self.get(self.fname)
|
||||||
if default_expense_account:
|
|
||||||
|
if default_expense_account or default_cost_center:
|
||||||
for d in details:
|
for d in details:
|
||||||
d.expense_account = default_expense_account
|
if default_expense_account and not d.get("expense_account"):
|
||||||
d.cost_center = default_cost_center
|
d.expense_account = default_expense_account
|
||||||
|
if default_cost_center and not d.get("cost_center"):
|
||||||
|
d.cost_center = default_cost_center
|
||||||
|
|
||||||
return details
|
return details
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ var cfn_set_fields = function(doc, dt, dn) {
|
|||||||
if (doc.status == 'Submitted' || doc.status == 'Material Transferred' || doc.status == 'In Process'){
|
if (doc.status == 'Submitted' || doc.status == 'Material Transferred' || doc.status == 'In Process'){
|
||||||
cur_frm.add_custom_button(__('Transfer Raw Materials'), cur_frm.cscript['Transfer Raw Materials']);
|
cur_frm.add_custom_button(__('Transfer Raw Materials'), cur_frm.cscript['Transfer Raw Materials']);
|
||||||
cur_frm.add_custom_button(__('Update Finished Goods'), cur_frm.cscript['Update Finished Goods']);
|
cur_frm.add_custom_button(__('Update Finished Goods'), cur_frm.cscript['Update Finished Goods']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ cur_frm.fields_dict['project_name'].get_query = function(doc, dt, dn) {
|
|||||||
filters:[
|
filters:[
|
||||||
['Project', 'status', 'not in', 'Completed, Cancelled']
|
['Project', 'status', 'not in', 'Completed, Cancelled']
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.set_query("bom_no", function(doc) {
|
cur_frm.set_query("bom_no", function(doc) {
|
||||||
@@ -112,4 +112,4 @@ cur_frm.set_query("bom_no", function(doc) {
|
|||||||
filters: {item: cstr(doc.production_item)}
|
filters: {item: cstr(doc.production_item)}
|
||||||
}
|
}
|
||||||
} else msgprint(__("Please enter Production Item first"));
|
} else msgprint(__("Please enter Production Item first"));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -420,7 +420,7 @@ class StockEntry(StockController):
|
|||||||
item["to_warehouse"] = ""
|
item["to_warehouse"] = ""
|
||||||
|
|
||||||
# add raw materials to Stock Entry Detail table
|
# add raw materials to Stock Entry Detail table
|
||||||
idx = self.add_to_stock_entry_detail(item_dict)
|
self.add_to_stock_entry_detail(item_dict)
|
||||||
|
|
||||||
# add finished good item to Stock Entry Detail table -- along with bom_no
|
# add finished good item to Stock Entry Detail table -- along with bom_no
|
||||||
if self.production_order and self.purpose == "Manufacture/Repack":
|
if self.production_order and self.purpose == "Manufacture/Repack":
|
||||||
@@ -437,7 +437,7 @@ class StockEntry(StockController):
|
|||||||
"expense_account": item.expense_account,
|
"expense_account": item.expense_account,
|
||||||
"cost_center": item.buying_cost_center,
|
"cost_center": item.buying_cost_center,
|
||||||
}
|
}
|
||||||
}, bom_no=pro_obj.bom_no, idx=idx)
|
}, bom_no=pro_obj.bom_no)
|
||||||
|
|
||||||
elif self.purpose in ["Material Receipt", "Manufacture/Repack"]:
|
elif self.purpose in ["Material Receipt", "Manufacture/Repack"]:
|
||||||
if self.purpose=="Material Receipt":
|
if self.purpose=="Material Receipt":
|
||||||
@@ -457,7 +457,7 @@ class StockEntry(StockController):
|
|||||||
"expense_account": item[0].expense_account,
|
"expense_account": item[0].expense_account,
|
||||||
"cost_center": item[0].buying_cost_center,
|
"cost_center": item[0].buying_cost_center,
|
||||||
}
|
}
|
||||||
}, bom_no=self.bom_no, idx=idx)
|
}, bom_no=self.bom_no)
|
||||||
|
|
||||||
self.get_stock_and_rate()
|
self.get_stock_and_rate()
|
||||||
|
|
||||||
@@ -519,14 +519,12 @@ class StockEntry(StockController):
|
|||||||
|
|
||||||
return issued_item_qty
|
return issued_item_qty
|
||||||
|
|
||||||
def add_to_stock_entry_detail(self, item_dict, bom_no=None, idx=None):
|
def add_to_stock_entry_detail(self, item_dict, bom_no=None):
|
||||||
if not idx: idx = 1
|
|
||||||
expense_account, cost_center = frappe.db.get_values("Company", self.company, \
|
expense_account, cost_center = frappe.db.get_values("Company", self.company, \
|
||||||
["default_expense_account", "cost_center"])[0]
|
["default_expense_account", "cost_center"])[0]
|
||||||
|
|
||||||
for d in item_dict:
|
for d in item_dict:
|
||||||
se_child = self.append('mtn_details', {})
|
se_child = self.append('mtn_details')
|
||||||
se_child.idx = idx
|
|
||||||
se_child.s_warehouse = item_dict[d].get("from_warehouse", self.from_warehouse)
|
se_child.s_warehouse = item_dict[d].get("from_warehouse", self.from_warehouse)
|
||||||
se_child.t_warehouse = item_dict[d].get("to_warehouse", self.to_warehouse)
|
se_child.t_warehouse = item_dict[d].get("to_warehouse", self.to_warehouse)
|
||||||
se_child.item_code = cstr(d)
|
se_child.item_code = cstr(d)
|
||||||
@@ -545,10 +543,6 @@ class StockEntry(StockController):
|
|||||||
# to be assigned for finished item
|
# to be assigned for finished item
|
||||||
se_child.bom_no = bom_no
|
se_child.bom_no = bom_no
|
||||||
|
|
||||||
# increment idx by 1
|
|
||||||
idx += 1
|
|
||||||
return idx
|
|
||||||
|
|
||||||
def validate_with_material_request(self):
|
def validate_with_material_request(self):
|
||||||
for item in self.get("mtn_details"):
|
for item in self.get("mtn_details"):
|
||||||
if item.material_request:
|
if item.material_request:
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ def get_bin(item_code, warehouse):
|
|||||||
bin_obj.insert()
|
bin_obj.insert()
|
||||||
else:
|
else:
|
||||||
bin_obj = frappe.get_doc('Bin', bin)
|
bin_obj = frappe.get_doc('Bin', bin)
|
||||||
|
bin_obj.ignore_permissions = True
|
||||||
return bin_obj
|
return bin_obj
|
||||||
|
|
||||||
def update_bin(args):
|
def update_bin(args):
|
||||||
@@ -82,6 +83,7 @@ def get_incoming_rate(args):
|
|||||||
get_fifo_rate(previous_stock_queue, args.get("qty") or 0) or 0
|
get_fifo_rate(previous_stock_queue, args.get("qty") or 0) or 0
|
||||||
elif valuation_method == 'Moving Average':
|
elif valuation_method == 'Moving Average':
|
||||||
in_rate = previous_sle.get('valuation_rate') or 0
|
in_rate = previous_sle.get('valuation_rate') or 0
|
||||||
|
|
||||||
return in_rate
|
return in_rate
|
||||||
|
|
||||||
def get_avg_purchase_rate(serial_nos):
|
def get_avg_purchase_rate(serial_nos):
|
||||||
@@ -120,8 +122,9 @@ def get_fifo_rate(previous_stock_queue, qty):
|
|||||||
outgoing_cost += flt(qty_to_pop) * flt(batch[1])
|
outgoing_cost += flt(qty_to_pop) * flt(batch[1])
|
||||||
batch[0] -= qty_to_pop
|
batch[0] -= qty_to_pop
|
||||||
qty_to_pop = 0
|
qty_to_pop = 0
|
||||||
|
|
||||||
# if queue gets blank and qty_to_pop remaining, get average rate of full queue
|
# if queue gets blank and qty_to_pop remaining, get average rate of full queue
|
||||||
return outgoing_cost / abs(qty) - qty_to_pop
|
return outgoing_cost / (abs(qty) - qty_to_pop)
|
||||||
|
|
||||||
def get_valid_serial_nos(sr_nos, qty=0, item_code=''):
|
def get_valid_serial_nos(sr_nos, qty=0, item_code=''):
|
||||||
"""split serial nos, validate and return list of valid serial nos"""
|
"""split serial nos, validate and return list of valid serial nos"""
|
||||||
|
|||||||
Reference in New Issue
Block a user