diff --git a/partner_statement/report/activity_statement.py b/partner_statement/report/activity_statement.py
index 53f920a9..c0fc8635 100644
--- a/partner_statement/report/activity_statement.py
+++ b/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):
diff --git a/partner_statement/views/activity_statement.xml b/partner_statement/views/activity_statement.xml
index bd6e5401..92bfe25f 100644
--- a/partner_statement/views/activity_statement.xml
+++ b/partner_statement/views/activity_statement.xml
@@ -29,7 +29,7 @@
- Statement between and in + Supplier Statement between and in