fix get data fields in report sale by kind
This commit is contained in:
parent
8f60fef695
commit
60335e7da5
20
sale.py
20
sale.py
|
@ -1661,7 +1661,7 @@ class SaleByKindReport(Report):
|
|||
where &= invoice.company == data['company']
|
||||
where &= invoice.type == 'out'
|
||||
|
||||
if data['start_time'] and data['end_time']:
|
||||
if data.get('start_time') and data.get('end_time'):
|
||||
start_date = datetime.combine(
|
||||
data['start_date'], data['start_time']) + timedelta(hours=5)
|
||||
end_date = datetime.combine(
|
||||
|
@ -1669,14 +1669,14 @@ class SaleByKindReport(Report):
|
|||
|
||||
where &= invoice.create_date <= end_date
|
||||
where &= invoice.create_date >= start_date
|
||||
if data['shop']:
|
||||
if data.get('shop'):
|
||||
where &= invoice.shop == data['shop']
|
||||
|
||||
if data['party']:
|
||||
if data.get('party'):
|
||||
where &= invoice.party == data['party']
|
||||
if data['payment_terms']:
|
||||
if data.get('payment_terms'):
|
||||
where &= invoice.payment_term.in_(data['payment_terms'])
|
||||
if data['kind']:
|
||||
if data.get('kind'):
|
||||
where &= invoice.sale_kind == data['kind']
|
||||
return where
|
||||
|
||||
|
@ -1737,12 +1737,12 @@ class SaleByKindReport(Report):
|
|||
invoice = tables['invoice']
|
||||
columns.extend([Count(invoice.number).as_('sales_total')])
|
||||
|
||||
if data['detailed']:
|
||||
if data.get('detailed'):
|
||||
columns, group_by = cls.set_detailed_query(
|
||||
tables, columns, group_by)
|
||||
|
||||
columns.extend(cls.get_columns_kind(tables, withs, 'count'))
|
||||
if data['including_tax']:
|
||||
if data.get('including_tax'):
|
||||
invoicetax = withs['with_invoicetax']
|
||||
columns.extend(cls.get_columns_kind(tables, withs, 'invoice_amount'))
|
||||
columns.extend([
|
||||
|
@ -1756,7 +1756,7 @@ class SaleByKindReport(Report):
|
|||
)
|
||||
records, totals = cls.get_values(query, {}, {}, data['detailed'])
|
||||
|
||||
if not data['including_tax']:
|
||||
if not data.get('including_tax'):
|
||||
from_item, tables, columns, group_by, withs = cls.get_query(data)
|
||||
where = cls._where(tables, data)
|
||||
line = tables['invoice.line']
|
||||
|
@ -1766,7 +1766,7 @@ class SaleByKindReport(Report):
|
|||
where &= NotIn(line.product, products_exception)
|
||||
columns.extend([Sum(line.quantity*line.unit_price).as_('amount_total')])
|
||||
|
||||
if data['detailed']:
|
||||
if data.get('detailed'):
|
||||
columns, group_by = cls.set_detailed_query(
|
||||
tables, columns, group_by)
|
||||
|
||||
|
@ -1778,7 +1778,7 @@ class SaleByKindReport(Report):
|
|||
with_=withs.values())
|
||||
records, totals = cls.get_values(
|
||||
query, records,
|
||||
totals, data['detailed'])
|
||||
totals, data.get('detailed'))
|
||||
report_context['records'] = records.values()
|
||||
report_context['company'] = company.rec_name
|
||||
report_context['total'] = totals if len(totals) > 1 else None
|
||||
|
|
Loading…
Reference in New Issue