item defaults based on caching
This commit is contained in:
parent
63a741e5c8
commit
3f142b874a
@ -926,22 +926,16 @@ def check_stock_uom_with_bin(item, stock_uom):
|
|||||||
frappe.throw(
|
frappe.throw(
|
||||||
_("Default Unit of Measure for Item {0} cannot be changed directly because you have already made some transaction(s) with another UOM. You will need to create a new Item to use a different Default UOM.").format(item))
|
_("Default Unit of Measure for Item {0} cannot be changed directly because you have already made some transaction(s) with another UOM. You will need to create a new Item to use a different Default UOM.").format(item))
|
||||||
|
|
||||||
def get_item_defaults(item, company):
|
def get_item_defaults(item_code, company):
|
||||||
item_defaults = frappe.db.sql('''
|
item = frappe.get_cached_doc('Item', item_code)
|
||||||
select
|
|
||||||
i.item_name, i.description, i.stock_uom, i.name, i.is_stock_item, i.item_code, i.item_group,
|
out = item.as_dict()
|
||||||
id.expense_account, id.income_account, id.buying_cost_center, id.default_warehouse,
|
|
||||||
id.selling_cost_center, id.default_supplier
|
for d in item.item_defaults:
|
||||||
from
|
if d.company == company:
|
||||||
`tabItem` i LEFT JOIN `tabItem Default` id ON i.name = id.parent and id.company = %s
|
out.update(d.as_dict())
|
||||||
where
|
|
||||||
i.name = %s
|
return out
|
||||||
''', (company, item), as_dict=1)
|
|
||||||
if item_defaults:
|
|
||||||
return item_defaults[0]
|
|
||||||
else:
|
|
||||||
return frappe.db.get_value("Item", item, ["name", "item_name", "description", "stock_uom",
|
|
||||||
"is_stock_item", "item_code", "item_group"], as_dict=1)
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_uom_conv_factor(uom, stock_uom):
|
def get_uom_conv_factor(uom, stock_uom):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user