[fixes] fix in the item defaults

This commit is contained in:
Manas Solanki 2018-05-16 15:50:17 +05:30
parent 8e184569a1
commit e3910fb2a6
4 changed files with 472 additions and 670 deletions

File diff suppressed because it is too large Load Diff

View File

@ -125,6 +125,9 @@ class Item(WebsiteGenerator):
self.old_website_item_groups = frappe.db.sql_list("""select item_group
from `tabWebsite Item Group`
where parentfield='website_item_groups' and parenttype='Item' and parent=%s""", self.name)
elif not self.item_defaults:
self.append("item_defaults", {"company": frappe.defaults.get_defaults().company})
def on_update(self):
invalidate_cache_for_item(self)
@ -892,4 +895,4 @@ def get_item_defaults(item, company):
`tabItem` i, `tabItem Default` id
where
i.name = id.parent and i.name = %s and id.company = %s
''', (item, company), as_dict=1)[0]
''', (item, company), as_dict=1)

View File

@ -38,7 +38,7 @@
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
@ -431,7 +431,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2018-05-03 02:44:24.097373",
"modified": "2018-05-16 05:58:28.182186",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item Default",

View File

@ -207,7 +207,7 @@ def get_basic_details(args, item):
if len(user_default_warehouse_list) == 1 else ""
item_defaults = get_item_defaults(item.name, args.company)
warehouse = user_default_warehouse or item_defaults.default_warehouse or args.warehouse
warehouse = user_default_warehouse or item_defaults.get("default_warehouse") or args.warehouse
material_request_type = ''
if args.get('doctype') == "Material Request":
@ -683,14 +683,14 @@ def get_default_bom(item_code=None):
def get_valuation_rate(item_code, company, warehouse=None):
item = get_item_defaults(item_code, company)
# item = frappe.get_doc("Item", item_code)
if item.is_stock_item:
if item.get("is_stock_item"):
if not warehouse:
warehouse = item.default_warehouse
warehouse = item.get("default_warehouse")
return frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse},
["valuation_rate"], as_dict=True) or {"valuation_rate": 0}
elif not item.is_stock_item:
elif not item.get("is_stock_item"):
valuation_rate =frappe.db.sql("""select sum(base_net_amount) / sum(qty*conversion_factor)
from `tabPurchase Invoice Item`
where item_code = %s and docstatus=1""", item_code)