Fixes in Production, Stock Entry and Stock Controller
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 497192d..c1d7d83 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -34,8 +34,7 @@
warehouse_account = get_warehouse_account()
stock_ledger = self.get_stock_ledger_details()
- voucher_details = self.get_voucher_details(stock_ledger, default_expense_account,
- default_cost_center)
+ voucher_details = self.get_voucher_details(default_expense_account, default_cost_center)
gl_list = []
warehouse_with_no_account = []
@@ -73,12 +72,15 @@
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)
- if default_expense_account:
+
+ if default_expense_account or default_cost_center:
for d in details:
- d.expense_account = default_expense_account
- d.cost_center = default_cost_center
+ if default_expense_account and not d.get("expense_account"):
+ d.expense_account = default_expense_account
+ if default_cost_center and not d.get("cost_center"):
+ d.cost_center = default_cost_center
return details
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.js b/erpnext/manufacturing/doctype/production_order/production_order.js
index 0b014ba..ba7b275 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.js
+++ b/erpnext/manufacturing/doctype/production_order/production_order.js
@@ -62,7 +62,7 @@
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(__('Update Finished Goods'), cur_frm.cscript['Update Finished Goods']);
- }
+ }
}
}
@@ -102,7 +102,7 @@
filters:[
['Project', 'status', 'not in', 'Completed, Cancelled']
]
- }
+ }
}
cur_frm.set_query("bom_no", function(doc) {
@@ -112,4 +112,4 @@
filters: {item: cstr(doc.production_item)}
}
} else msgprint(__("Please enter Production Item first"));
-});
\ No newline at end of file
+});
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 8026a3e..7fc686b 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -420,7 +420,7 @@
item["to_warehouse"] = ""
# 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
if self.production_order and self.purpose == "Manufacture/Repack":
@@ -437,7 +437,7 @@
"expense_account": item.expense_account,
"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"]:
if self.purpose=="Material Receipt":
@@ -457,7 +457,7 @@
"expense_account": item[0].expense_account,
"cost_center": item[0].buying_cost_center,
}
- }, bom_no=self.bom_no, idx=idx)
+ }, bom_no=self.bom_no)
self.get_stock_and_rate()
@@ -519,14 +519,12 @@
return issued_item_qty
- def add_to_stock_entry_detail(self, item_dict, bom_no=None, idx=None):
- if not idx: idx = 1
+ def add_to_stock_entry_detail(self, item_dict, bom_no=None):
expense_account, cost_center = frappe.db.get_values("Company", self.company, \
["default_expense_account", "cost_center"])[0]
for d in item_dict:
- se_child = self.append('mtn_details', {})
- se_child.idx = idx
+ se_child = self.append('mtn_details')
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.item_code = cstr(d)
@@ -545,10 +543,6 @@
# to be assigned for finished item
se_child.bom_no = bom_no
- # increment idx by 1
- idx += 1
- return idx
-
def validate_with_material_request(self):
for item in self.get("mtn_details"):
if item.material_request:
diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py
index 1c5458e..526b7c2 100644
--- a/erpnext/stock/utils.py
+++ b/erpnext/stock/utils.py
@@ -49,6 +49,7 @@
bin_obj.insert()
else:
bin_obj = frappe.get_doc('Bin', bin)
+ bin_obj.ignore_permissions = True
return bin_obj
def update_bin(args):
@@ -82,6 +83,7 @@
get_fifo_rate(previous_stock_queue, args.get("qty") or 0) or 0
elif valuation_method == 'Moving Average':
in_rate = previous_sle.get('valuation_rate') or 0
+
return in_rate
def get_avg_purchase_rate(serial_nos):
@@ -120,8 +122,9 @@
outgoing_cost += flt(qty_to_pop) * flt(batch[1])
batch[0] -= qty_to_pop
qty_to_pop = 0
+
# 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=''):
"""split serial nos, validate and return list of valid serial nos"""