fix: Add UOM in anlytics report when viewing based on item (#18902)
This commit is contained in:
parent
48d1463825
commit
cffe577028
@ -40,6 +40,16 @@ class Analytics(object):
|
||||
"fieldtype": "Data",
|
||||
"width": 140
|
||||
})
|
||||
|
||||
if self.filters.tree_type == "Item":
|
||||
self.columns.append({
|
||||
"label": _("UOM"),
|
||||
"fieldname": 'stock_uom',
|
||||
"fieldtype": "Link",
|
||||
"options": "UOM",
|
||||
"width": 100
|
||||
})
|
||||
|
||||
for end_date in self.periodic_daterange:
|
||||
period = self.get_period(end_date)
|
||||
self.columns.append({
|
||||
@ -129,7 +139,7 @@ class Analytics(object):
|
||||
value_field = 'qty'
|
||||
|
||||
self.entries = frappe.db.sql("""
|
||||
select i.item_code as entity, i.item_name as entity_name, i.{value_field} as value_field, s.{date_field}
|
||||
select i.item_code as entity, i.item_name as entity_name, i.stock_uom, i.{value_field} as value_field, s.{date_field}
|
||||
from `tab{doctype} Item` i , `tab{doctype}` s
|
||||
where s.name = i.parent and i.docstatus = 1 and s.company = %s
|
||||
and s.{date_field} between %s and %s
|
||||
@ -198,6 +208,10 @@ class Analytics(object):
|
||||
total += amount
|
||||
|
||||
row["total"] = total
|
||||
|
||||
if self.filters.tree_type == "Item":
|
||||
row["stock_uom"] = period_data.get("stock_uom")
|
||||
|
||||
self.data.append(row)
|
||||
|
||||
def get_rows_by_group(self):
|
||||
@ -232,6 +246,9 @@ class Analytics(object):
|
||||
self.entity_periodic_data.setdefault(d.entity, frappe._dict()).setdefault(period, 0.0)
|
||||
self.entity_periodic_data[d.entity][period] += flt(d.value_field)
|
||||
|
||||
if self.filters.tree_type == "Item":
|
||||
self.entity_periodic_data[d.entity]['stock_uom'] = d.stock_uom
|
||||
|
||||
def get_period(self, posting_date):
|
||||
if self.filters.range == 'Weekly':
|
||||
period = "Week " + str(posting_date.isocalendar()[1]) + " " + str(posting_date.year)
|
||||
|
Loading…
Reference in New Issue
Block a user