-Fix for updated get_default_cost_center
-Back to not updating item's defaults child table
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index e2922b3..a1aa6b1 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -86,7 +86,7 @@
def after_insert(self):
'''set opening stock and item price'''
if self.standard_rate:
- for default in self.item_defaults:
+ for default in self.item_defaults or [frappe._dict()]:
self.add_price(default.default_price_list)
if self.opening_stock:
@@ -126,9 +126,6 @@
self.validate_fixed_asset()
self.validate_retain_sample()
self.validate_uom_conversion_factor()
- self.validate_item_defaults()
- self.update_defaults_from_item_group()
- self.update_defaults_add_company()
if not self.get("__islocal"):
self.old_item_group = frappe.db.get_value(self.doctype, self.name, "item_group")
@@ -136,10 +133,6 @@
from `tabWebsite Item Group`
where parentfield='website_item_groups' and parenttype='Item' and parent=%s""", self.name)
- def update_defaults_add_company(self):
- if not self.item_defaults:
- self.append("item_defaults", {"company": frappe.defaults.get_defaults().company})
-
def on_update(self):
invalidate_cache_for_item(self)
self.validate_name_with_item_group()
@@ -181,7 +174,7 @@
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
# default warehouse, or Stores
- for default in self.item_defaults:
+ for default in self.item_defaults or [frappe._dict({'company': frappe.defaults.get_defaults().company})]:
default_warehouse = (default.default_warehouse
or frappe.db.get_single_value('Stock Settings', 'default_warehouse')
or frappe.db.get_value('Warehouse', {'warehouse_name': _('Stores')}))
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 5d3c6c4..5c6555a 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -10,6 +10,7 @@
from erpnext.stock.stock_ledger import get_previous_sle, NegativeStockError, get_valuation_rate
from erpnext.stock.get_item_details import get_bin_details, get_default_cost_center, get_conversion_factor, get_reserved_qty_for_so
from erpnext.setup.doctype.item_group.item_group import get_item_group_defaults
+from erpnext.setup.doctype.brand.brand import get_brand_defaults
from erpnext.stock.doctype.batch.batch import get_batch_no, set_batch_nos, get_batch_qty
from erpnext.stock.doctype.item.item import get_item_defaults
from erpnext.manufacturing.doctype.bom.bom import validate_bom_no, add_additional_cost
@@ -631,6 +632,7 @@
item = item[0]
item_group_defaults = get_item_group_defaults(item.name, self.company)
+ brand_defaults = get_brand_defaults(item.name, self.company)
ret = frappe._dict({
'uom' : item.stock_uom,
@@ -639,7 +641,7 @@
'image' : item.image,
'item_name' : item.item_name,
'expense_account' : args.get("expense_account"),
- 'cost_center' : get_default_cost_center(args, item, item_group_defaults),
+ 'cost_center' : get_default_cost_center(args, item, item_group_defaults, brand_defaults),
'qty' : args.get("qty"),
'transfer_qty' : args.get('qty'),
'conversion_factor' : 1,