|
|
@ -79,29 +79,32 @@ class ActivityStatement(models.AbstractModel): |
|
|
|
self._cr.mogrify( |
|
|
|
""" |
|
|
|
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) |
|
|
|
END as debit, |
|
|
|
CASE WHEN (l.currency_id is not null AND l.amount_currency < 0.0) |
|
|
|
THEN sum(l.amount_currency * (-1)) |
|
|
|
ELSE sum(l.credit) |
|
|
|
END as credit, |
|
|
|
CASE WHEN l.date_maturity is null |
|
|
|
THEN l.date |
|
|
|
ELSE l.date_maturity |
|
|
|
END as date_maturity |
|
|
|
CASE WHEN (aj.type IN ('sale', 'purchase')) |
|
|
|
THEN l.name |
|
|
|
ELSE '/' |
|
|
|
END as name, |
|
|
|
CASE |
|
|
|
WHEN (aj.type IN ('sale', 'purchase')) AND l.name IS NOT NULL |
|
|
|
THEN l.ref |
|
|
|
WHEN aj.type IN ('sale', 'purchase') AND l.name IS NULL |
|
|
|
THEN m.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) |
|
|
|
END as debit, |
|
|
|
CASE WHEN (l.currency_id is not null AND l.amount_currency < 0.0) |
|
|
|
THEN sum(l.amount_currency * (-1)) |
|
|
|
ELSE sum(l.credit) |
|
|
|
END as credit, |
|
|
|
CASE WHEN l.date_maturity is null |
|
|
|
THEN l.date |
|
|
|
ELSE l.date_maturity |
|
|
|
END as date_maturity |
|
|
|
FROM account_move_line l |
|
|
|
JOIN account_move m ON (l.move_id = m.id) |
|
|
|
JOIN account_journal aj ON (l.journal_id = aj.id) |
|
|
@ -115,10 +118,13 @@ class ActivityStatement(models.AbstractModel): |
|
|
|
THEN l.name |
|
|
|
ELSE '/' |
|
|
|
END, |
|
|
|
CASE WHEN (aj.type IN ('sale', 'purchase')) |
|
|
|
THEN l.ref |
|
|
|
WHEN (aj.type in ('bank', 'cash')) |
|
|
|
THEN 'Payment' |
|
|
|
CASE |
|
|
|
WHEN (aj.type IN ('sale', 'purchase')) AND l.name IS NOT NULL |
|
|
|
THEN l.ref |
|
|
|
WHEN aj.type IN ('sale', 'purchase') AND l.name IS NULL |
|
|
|
THEN m.ref |
|
|
|
WHEN (aj.type in ('bank', 'cash')) |
|
|
|
THEN 'Payment' |
|
|
|
ELSE '' |
|
|
|
END, |
|
|
|
l.blocked, l.currency_id, l.amount_currency, l.company_id |
|
|
|