Browse Source

[IMP] Activity Statements aggregate Payment Data

Before this change, if a payment was reconciled using the bank statement widget
the move was seperated into many multiples of lines making activity
statements twice as long as necessary.

Now payments are a single line
pull/762/head
Graeme Gellatly 6 years ago
committed by Rujia Liu
parent
commit
986334b75b
  1. 30
      partner_statement/report/activity_statement.py
  2. 5
      partner_statement/views/activity_statement.xml

30
partner_statement/report/activity_statement.py

@ -58,8 +58,18 @@ class ActivityStatement(models.AbstractModel):
def _display_lines_sql_q1(self, partners, date_start, date_end,
account_type):
return str(self._cr.mogrify("""
SELECT m.name AS move_id, l.partner_id, l.date, l.name,
l.ref, l.blocked, l.currency_id, l.company_id,
SELECT m.name AS move_id, l.partner_id, l.date,
CASE WHEN (aj.type IN ('sale', 'purchase'))
THEN l.name
ELSE '/'
END as name,
CASE WHEN (aj.type IN ('sale', 'purchase'))
THEN l.ref
WHEN (aj.type in ('bank', 'cash'))
THEN 'Payment'
ELSE ''
END as ref,
l.blocked, l.currency_id, l.company_id,
CASE WHEN (l.currency_id is not null AND l.amount_currency > 0.0)
THEN sum(l.amount_currency)
ELSE sum(l.debit)
@ -75,13 +85,23 @@ class ActivityStatement(models.AbstractModel):
FROM account_move_line l
JOIN account_account_type at ON (at.id = l.user_type_id)
JOIN account_move m ON (l.move_id = m.id)
JOIN account_journal aj ON (l.journal_id = aj.id)
WHERE l.partner_id IN %(partners)s
AND at.type = %(account_type)s
AND %(date_start)s <= l.date
AND l.date <= %(date_end)s
GROUP BY l.partner_id, m.name, l.date, l.date_maturity, l.name,
l.ref, l.blocked, l.currency_id,
l.amount_currency, l.company_id
GROUP BY l.partner_id, m.name, l.date, l.date_maturity,
CASE WHEN (aj.type IN ('sale', 'purchase'))
THEN l.name
ELSE '/'
END,
CASE WHEN (aj.type IN ('sale', 'purchase'))
THEN l.ref
WHEN (aj.type in ('bank', 'cash'))
THEN 'Payment'
ELSE ''
END,
l.blocked, l.currency_id, l.amount_currency, l.company_id
""", locals()), "utf-8")
def _display_lines_sql_q2(self, company_id):

5
partner_statement/views/activity_statement.xml

@ -29,7 +29,7 @@
<t t-set="display_currency" t-value="Currencies[currency[0]]" />
<t t-set="currency" t-value="currency[1]" />
<p>
<span t-esc="'' if account_type == 'receivable' else 'Supplier '"/>Statement between <span t-esc="d['start']" /> and <span t-esc="d['end']" /> in <span t-esc="display_currency.name"/>
<span t-if="account_type == 'payable'">Supplier </span>Statement between <span t-esc="d['start']" /> and <span t-esc="d['end']" /> in <span t-esc="display_currency.name"/>
</p>
<table class="table table-condensed table-statement">
<thead>
@ -79,7 +79,8 @@
</t>
</t>
<t t-if="line['name'] == '/'">
<span t-esc="line['ref']"/>
<span t-if="line['ref'] == 'Payment'">Payment</span>
<span t-else="" t-esc="line['ref']"/>
</t>
</td>
<td class="amount">

Loading…
Cancel
Save