fix: adjusted width of colums to see full column names, also fixes #21556

This commit is contained in:
Abhishek Balam 2020-05-10 14:53:59 +05:30
parent 5ec5584319
commit 500dff63e7
2 changed files with 23 additions and 19 deletions

View File

@ -14,21 +14,21 @@ def execute(filters=None):
'fieldname': 'new_customers', 'fieldname': 'new_customers',
'fieldtype': 'Int', 'fieldtype': 'Int',
'default': 0, 'default': 0,
'width': 100 'width': 150
}, },
{ {
'label': _('Repeat Customers'), 'label': _('Repeat Customers'),
'fieldname': 'repeat_customers', 'fieldname': 'repeat_customers',
'fieldtype': 'Int', 'fieldtype': 'Int',
'default': 0, 'default': 0,
'width': 100 'width': 150
}, },
{ {
'label': _('Total'), 'label': _('Total'),
'fieldname': 'total', 'fieldname': 'total',
'fieldtype': 'Int', 'fieldtype': 'Int',
'default': 0, 'default': 0,
'width': 100 'width': 150
}, },
{ {
'label': _('New Customer Revenue'), 'label': _('New Customer Revenue'),
@ -52,10 +52,10 @@ def execute(filters=None):
'width': 150 'width': 150
} }
] ]
if filters.get('view_type') == 'Territory Wise': if filters.get('view_type') == 'Monthly':
return get_data_by_territory(filters, common_columns)
else:
return get_data_by_time(filters, common_columns) return get_data_by_time(filters, common_columns)
else:
return get_data_by_territory(filters, common_columns)
def get_data_by_time(filters, common_columns): def get_data_by_time(filters, common_columns):
# key yyyy-mm # key yyyy-mm

View File

@ -20,31 +20,36 @@ def get_columns():
"label": _("Territory"), "label": _("Territory"),
"fieldname": "territory", "fieldname": "territory",
"fieldtype": "Link", "fieldtype": "Link",
"options": "Territory" "options": "Territory",
"width": 150
}, },
{ {
"label": _("Opportunity Amount"), "label": _("Opportunity Amount"),
"fieldname": "opportunity_amount", "fieldname": "opportunity_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"options": currency "options": currency,
"width": 150
}, },
{ {
"label": _("Quotation Amount"), "label": _("Quotation Amount"),
"fieldname": "quotation_amount", "fieldname": "quotation_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"options": currency "options": currency,
"width": 150
}, },
{ {
"label": _("Order Amount"), "label": _("Order Amount"),
"fieldname": "order_amount", "fieldname": "order_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"options": currency "options": currency,
"width": 150
}, },
{ {
"label": _("Billing Amount"), "label": _("Billing Amount"),
"fieldname": "billing_amount", "fieldname": "billing_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"options": currency "options": currency,
"width": 150
} }
] ]
@ -62,8 +67,7 @@ def get_data(filters=None):
territory_opportunities = list(filter(lambda x: x.territory == territory.name, opportunities)) territory_opportunities = list(filter(lambda x: x.territory == territory.name, opportunities))
t_opportunity_names = [] t_opportunity_names = []
if territory_opportunities: if territory_opportunities:
t_opportunity_names = [t.name for t in territory_opportunities] t_opportunity_names = [t.name for t in territory_opportunities]
territory_quotations = [] territory_quotations = []
if t_opportunity_names and quotations: if t_opportunity_names and quotations:
territory_quotations = list(filter(lambda x: x.opportunity in t_opportunity_names, quotations)) territory_quotations = list(filter(lambda x: x.opportunity in t_opportunity_names, quotations))
@ -76,7 +80,7 @@ def get_data(filters=None):
list(filter(lambda x: x.quotation in t_quotation_names, sales_orders)) list(filter(lambda x: x.quotation in t_quotation_names, sales_orders))
t_order_names = [] t_order_names = []
if territory_orders: if territory_orders:
t_order_names = [t.name for t in territory_orders] t_order_names = [t.name for t in territory_orders]
territory_invoices = list(filter(lambda x: x.sales_order in t_order_names, sales_invoices)) if t_order_names and sales_invoices else [] territory_invoices = list(filter(lambda x: x.sales_order in t_order_names, sales_invoices)) if t_order_names and sales_invoices else []
@ -96,12 +100,12 @@ def get_opportunities(filters):
if filters.get('transaction_date'): if filters.get('transaction_date'):
conditions = " WHERE transaction_date between {0} and {1}".format( conditions = " WHERE transaction_date between {0} and {1}".format(
frappe.db.escape(filters['transaction_date'][0]), frappe.db.escape(filters['transaction_date'][0]),
frappe.db.escape(filters['transaction_date'][1])) frappe.db.escape(filters['transaction_date'][1]))
if filters.company: if filters.company:
if conditions: if conditions:
conditions += " AND" conditions += " AND"
else: else:
conditions += " WHERE" conditions += " WHERE"
conditions += " company = %(company)s" conditions += " company = %(company)s"
@ -115,7 +119,7 @@ def get_opportunities(filters):
def get_quotations(opportunities): def get_quotations(opportunities):
if not opportunities: if not opportunities:
return [] return []
opportunity_names = [o.name for o in opportunities] opportunity_names = [o.name for o in opportunities]
return frappe.db.sql(""" return frappe.db.sql("""
@ -155,5 +159,5 @@ def _get_total(doclist, amount_field="base_grand_total"):
total = 0 total = 0
for doc in doclist: for doc in doclist:
total += doc.get(amount_field, 0) total += doc.get(amount_field, 0)
return total return total