Improve accounting move descriptions

- Add statement line number as move description
- Set description on statement account line if unique

issue6205
review26051002
This commit is contained in:
Cédric Krier
2017-02-01 21:43:20 +01:00
parent cc9987d133
commit 2137eecd2c
3 changed files with 38 additions and 2 deletions
+3
View File
@@ -1,3 +1,6 @@
* Add statement line number as move description
* Set description on statement account line if unique
Version 4.2.0 - 2016-11-28
* Bug fixes (see mercurial logs for details)
* Manage readonly state on Statement Line
+10 -2
View File
@@ -450,7 +450,7 @@ class Statement(Workflow, ModelSQL, ModelView):
move_lines.append((move_line, line))
move_line = statement._get_move_line(
amount, amount_second_currency)
amount, amount_second_currency, lines)
move_line.move = move
move_lines.append((move_line, None))
@@ -474,9 +474,10 @@ class Statement(Workflow, ModelSQL, ModelView):
date=key['date'],
origin=self,
company=self.company,
description=unicode(key['number']),
)
def _get_move_line(self, amount, amount_second_currency):
def _get_move_line(self, amount, amount_second_currency, lines):
'Return counterpart Move Line for the amount'
pool = Pool()
MoveLine = pool.get('account.move.line')
@@ -497,12 +498,19 @@ class Statement(Workflow, ModelSQL, ModelView):
second_currency = None
amount_second_currency = None
descriptions = {l.description for l in lines}
if len(descriptions) == 1:
description, = descriptions
else:
description = ''
return MoveLine(
debit=abs(amount) if amount < 0 else 0,
credit=abs(amount) if amount > 0 else 0,
account=account,
second_currency=second_currency,
amount_second_currency=amount_second_currency,
description=description,
)
@classmethod
+25
View File
@@ -148,6 +148,8 @@ Received 180 from customer::
>>> statement_line = StatementLine()
>>> statement.lines.append(statement_line)
>>> statement_line.number = '0001'
>>> statement_line.description = 'description'
>>> statement_line.date = today
>>> statement_line.amount = Decimal('180')
>>> statement_line.party = customer
@@ -159,10 +161,15 @@ Received 180 from customer::
>>> statement_line = statement.lines[-1]
>>> statement_line.amount
Decimal('80.00')
>>> statement_line.number
'0001'
>>> statement_line.description
'description'
>>> statement_line.party == customer
True
>>> statement_line.account == receivable
True
>>> statement_line.description = 'other description'
>>> statement_line.invoice = customer_invoice2
>>> statement_line.amount
Decimal('80.00')
@@ -171,6 +178,8 @@ Paid 50 to customer::
>>> statement_line = StatementLine()
>>> statement.lines.append(statement_line)
>>> statement_line.number = '0002'
>>> statement_line.description = 'description'
>>> statement_line.date = today
>>> statement_line.amount = Decimal('-50')
>>> statement_line.party = customer
@@ -201,6 +210,22 @@ Validate statement::
>>> statement.state
u'validated'
Test posted moves::
>>> statement_line = statement.lines[0]
>>> move = statement_line.move
>>> move.description
u'0001'
>>> sorted((l.description for l in move.lines))
[u'', u'description', u'other description']
>>> statement_line = statement.lines[2]
>>> move = statement_line.move
>>> move.description
u'0002'
>>> sorted((l.description for l in move.lines))
[u'description', u'description']
Test invoice state::
>>> customer_invoice1.reload()