Item defaults query fixes
This commit is contained in:
parent
05283b8af0
commit
b903fc4e71
@ -168,10 +168,10 @@ def get_items_list(pos_profile, company):
|
|||||||
i.has_serial_no, i.is_stock_item, i.brand, i.stock_uom, i.image,
|
i.has_serial_no, i.is_stock_item, i.brand, i.stock_uom, i.image,
|
||||||
id.expense_account, id.selling_cost_center, id.default_warehouse
|
id.expense_account, id.selling_cost_center, id.default_warehouse
|
||||||
from
|
from
|
||||||
`tabItem` i LEFT JOIN `tabItem Default` id ON id.parent = i.name
|
`tabItem` i LEFT JOIN `tabItem Default` id ON id.parent = i.name and id.company = %s
|
||||||
where
|
where
|
||||||
i.disabled = 0 and i.has_variants = 0 and i.is_sales_item = 1
|
i.disabled = 0 and i.has_variants = 0 and i.is_sales_item = 1
|
||||||
and id.company = %s {cond}
|
{cond}
|
||||||
""".format(cond=cond), tuple(args_list), as_dict=1)
|
""".format(cond=cond), tuple(args_list), as_dict=1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -552,10 +552,10 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite
|
|||||||
`tab{table}` bom_item
|
`tab{table}` bom_item
|
||||||
JOIN `tabBOM` bom ON bom_item.parent = bom.name
|
JOIN `tabBOM` bom ON bom_item.parent = bom.name
|
||||||
JOIN `tabItem` item ON item.name = bom_item.item_code
|
JOIN `tabItem` item ON item.name = bom_item.item_code
|
||||||
LEFT JOIN `tabItem Default` item_default ON item_default.parent = item.name
|
LEFT JOIN `tabItem Default` item_default
|
||||||
|
ON item_default.parent = item.name and item_default.company = %(company)s
|
||||||
where
|
where
|
||||||
bom_item.docstatus < 2
|
bom_item.docstatus < 2
|
||||||
and item_default.company = %(company)s
|
|
||||||
and bom.name = %(bom)s
|
and bom.name = %(bom)s
|
||||||
and is_stock_item = 1
|
and is_stock_item = 1
|
||||||
{where_conditions}
|
{where_conditions}
|
||||||
|
@ -298,10 +298,10 @@ class ProductionPlan(Document):
|
|||||||
`tabBOM Explosion Item` bei
|
`tabBOM Explosion Item` bei
|
||||||
JOIN `tabBOM` bom ON bom.name = bei.parent
|
JOIN `tabBOM` bom ON bom.name = bei.parent
|
||||||
JOIN `tabItem` item ON item.name = bei.item_code
|
JOIN `tabItem` item ON item.name = bei.item_code
|
||||||
LEFT JOIN `tabItem Default` item_default ON item_default.parent = item.name
|
LEFT JOIN `tabItem Default` item_default
|
||||||
|
ON item_default.parent = item.name and item_default.company=%s
|
||||||
where
|
where
|
||||||
bei.docstatus < 2
|
bei.docstatus < 2
|
||||||
and item_default.company=%s
|
|
||||||
and bom.name=%s and item.is_stock_item in (1, {0})
|
and bom.name=%s and item.is_stock_item in (1, {0})
|
||||||
group by bei.item_code, bei.stock_uom""".format(self.include_non_stock_items),
|
group by bei.item_code, bei.stock_uom""".format(self.include_non_stock_items),
|
||||||
(self.company, data.bom_no), as_dict=1):
|
(self.company, data.bom_no), as_dict=1):
|
||||||
@ -326,11 +326,11 @@ class ProductionPlan(Document):
|
|||||||
`tabBOM Item` bom_item
|
`tabBOM Item` bom_item
|
||||||
JOIN `tabBOM` bom ON bom.name = bom_item.parent
|
JOIN `tabBOM` bom ON bom.name = bom_item.parent
|
||||||
JOIN tabItem item ON bom_item.item_code = item.name
|
JOIN tabItem item ON bom_item.item_code = item.name
|
||||||
LEFT JOIN `tabItem Default` item_default ON item.name = item_default.parent
|
LEFT JOIN `tabItem Default` item_default
|
||||||
|
ON item.name = item_default.parent and item_default.company = %(company)s
|
||||||
where
|
where
|
||||||
bom.name = %(bom)s
|
bom.name = %(bom)s
|
||||||
and bom_item.docstatus < 2
|
and bom_item.docstatus < 2
|
||||||
and item_default.company = %(company)s
|
|
||||||
and item.is_stock_item in (1, {0})
|
and item.is_stock_item in (1, {0})
|
||||||
group by bom_item.item_code""".format(self.include_non_stock_items),{
|
group by bom_item.item_code""".format(self.include_non_stock_items),{
|
||||||
'bom': bom_no,
|
'bom': bom_no,
|
||||||
|
@ -892,10 +892,10 @@ def get_item_defaults(item, company):
|
|||||||
i.item_name, i.description, i.stock_uom, i.name, i.is_stock_item, i.item_code, i.item_group,
|
i.item_name, i.description, i.stock_uom, i.name, i.is_stock_item, i.item_code, i.item_group,
|
||||||
id.expense_account, id.buying_cost_center, id.default_warehouse, id.selling_cost_center, id.default_supplier
|
id.expense_account, id.buying_cost_center, id.default_warehouse, id.selling_cost_center, id.default_supplier
|
||||||
from
|
from
|
||||||
`tabItem` i LEFT JOIN `tabItem Default` id ON i.name = id.parent
|
`tabItem` i LEFT JOIN `tabItem Default` id ON i.name = id.parent and id.company = %s
|
||||||
where
|
where
|
||||||
i.name = %s and id.company = %s
|
i.name = %s
|
||||||
''', (item, company), as_dict=1)
|
''', (company, item), as_dict=1)
|
||||||
if item_defaults:
|
if item_defaults:
|
||||||
return item_defaults[0]
|
return item_defaults[0]
|
||||||
else:
|
else:
|
||||||
|
@ -21,9 +21,9 @@ def get_product_bundle_items(item_code):
|
|||||||
def get_packing_item_details(item, company):
|
def get_packing_item_details(item, company):
|
||||||
return frappe.db.sql("""
|
return frappe.db.sql("""
|
||||||
select i.item_name, i.description, i.stock_uom, id.default_warehouse
|
select i.item_name, i.description, i.stock_uom, id.default_warehouse
|
||||||
from `tabItem` i LEFT JOIN `tabItem Default` id ON id.parent=i.name
|
from `tabItem` i LEFT JOIN `tabItem Default` id ON id.parent=i.name and id.company=%s
|
||||||
where i.name = %s and id.company""",
|
where i.name = %s""",
|
||||||
(item, company), as_dict = 1)[0]
|
(company, item), as_dict = 1)[0]
|
||||||
|
|
||||||
def get_bin_qty(item, warehouse):
|
def get_bin_qty(item, warehouse):
|
||||||
det = frappe.db.sql("""select actual_qty, projected_qty from `tabBin`
|
det = frappe.db.sql("""select actual_qty, projected_qty from `tabBin`
|
||||||
|
@ -566,11 +566,12 @@ class StockEntry(StockController):
|
|||||||
item = frappe.db.sql("""select i.stock_uom, i.description, i.image, i.item_name, i.item_group,
|
item = frappe.db.sql("""select i.stock_uom, i.description, i.image, i.item_name, i.item_group,
|
||||||
i.has_batch_no, i.sample_quantity, i.has_serial_no,
|
i.has_batch_no, i.sample_quantity, i.has_serial_no,
|
||||||
id.expense_account, id.buying_cost_center
|
id.expense_account, id.buying_cost_center
|
||||||
from `tabItem` i LEFT JOIN `tabItem Default` id ON i.name=id.parent
|
from `tabItem` i LEFT JOIN `tabItem Default` id ON i.name=id.parent and id.company=%s
|
||||||
where i.name=%s and id.company=%s
|
where i.name=%s
|
||||||
and i.disabled=0
|
and i.disabled=0
|
||||||
and (i.end_of_life is null or i.end_of_life='0000-00-00' or i.end_of_life > %s)""",
|
and (i.end_of_life is null or i.end_of_life='0000-00-00' or i.end_of_life > %s)""",
|
||||||
(args.get('item_code'), self.company, nowdate()), as_dict = 1)
|
(self.company, args.get('item_code'), nowdate()), as_dict = 1)
|
||||||
|
|
||||||
if not item:
|
if not item:
|
||||||
frappe.throw(_("Item {0} is not active or end of life has been reached").format(args.get("item_code")))
|
frappe.throw(_("Item {0} is not active or end of life has been reached").format(args.get("item_code")))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user