fix: Add extra column to display Invoice or Item when grouped by Invoice (#28483)

This commit is contained in:
mergify[bot]
2021-11-22 13:14:38 +05:30
committed by GitHub
parent f4797ac5e3
commit 7c731147ba

View File

@@ -20,7 +20,7 @@ def execute(filters=None):
data = [] data = []
group_wise_columns = frappe._dict({ group_wise_columns = frappe._dict({
"invoice": ["parent", "customer", "customer_group", "posting_date","item_code", "item_name","item_group", "brand", "description", \ "invoice": ["invoice_or_item", "customer", "customer_group", "posting_date","item_code", "item_name","item_group", "brand", "description",
"warehouse", "qty", "base_rate", "buying_rate", "base_amount", "warehouse", "qty", "base_rate", "buying_rate", "base_amount",
"buying_amount", "gross_profit", "gross_profit_percent", "project"], "buying_amount", "gross_profit", "gross_profit_percent", "project"],
"item_code": ["item_code", "item_name", "brand", "description", "qty", "base_rate", "item_code": ["item_code", "item_name", "brand", "description", "qty", "base_rate",
@@ -85,6 +85,7 @@ def get_columns(group_wise_columns, filters):
columns = [] columns = []
column_map = frappe._dict({ column_map = frappe._dict({
"parent": _("Sales Invoice") + ":Link/Sales Invoice:120", "parent": _("Sales Invoice") + ":Link/Sales Invoice:120",
"invoice_or_item": _("Sales Invoice") + ":Link/Sales Invoice:120",
"posting_date": _("Posting Date") + ":Date:100", "posting_date": _("Posting Date") + ":Date:100",
"posting_time": _("Posting Time") + ":Data:100", "posting_time": _("Posting Time") + ":Data:100",
"item_code": _("Item Code") + ":Link/Item:100", "item_code": _("Item Code") + ":Link/Item:100",
@@ -123,7 +124,7 @@ def get_columns(group_wise_columns, filters):
def get_column_names(): def get_column_names():
return frappe._dict({ return frappe._dict({
'parent': 'sales_invoice', 'invoice_or_item': 'sales_invoice',
'customer': 'customer', 'customer': 'customer',
'customer_group': 'customer_group', 'customer_group': 'customer_group',
'posting_date': 'posting_date', 'posting_date': 'posting_date',
@@ -449,7 +450,7 @@ class GrossProfitGenerator(object):
if not row.indent: if not row.indent:
row.indent = 1.0 row.indent = 1.0
row.parent_invoice = row.parent row.parent_invoice = row.parent
row.parent = row.item_code row.invoice_or_item = row.item_code
if frappe.db.exists('Product Bundle', row.item_code): if frappe.db.exists('Product Bundle', row.item_code):
self.add_bundle_items(row, index) self.add_bundle_items(row, index)
@@ -458,7 +459,8 @@ class GrossProfitGenerator(object):
return frappe._dict({ return frappe._dict({
'parent_invoice': "", 'parent_invoice': "",
'indent': 0.0, 'indent': 0.0,
'parent': row.parent, 'invoice_or_item': row.parent,
'parent': None,
'posting_date': row.posting_date, 'posting_date': row.posting_date,
'posting_time': row.posting_time, 'posting_time': row.posting_time,
'project': row.project, 'project': row.project,
@@ -502,7 +504,8 @@ class GrossProfitGenerator(object):
return frappe._dict({ return frappe._dict({
'parent_invoice': product_bundle.item_code, 'parent_invoice': product_bundle.item_code,
'indent': product_bundle.indent + 1, 'indent': product_bundle.indent + 1,
'parent': item.item_code, 'parent': None,
'invoice_or_item': item.item_code,
'posting_date': product_bundle.posting_date, 'posting_date': product_bundle.posting_date,
'posting_time': product_bundle.posting_time, 'posting_time': product_bundle.posting_time,
'project': product_bundle.project, 'project': product_bundle.project,