Show reconciliations lines as payment lines
Once the invoice is paid, we can show the reconciliation lines instead of the payment lines. issue8157 review70581002
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Show reconciliation lines as payment lines
|
||||
* Fill in origin of move line
|
||||
* Remove partial payment when cancel
|
||||
* Set cancel state when credit with refund
|
||||
|
||||
+17
@@ -205,6 +205,12 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
'readonly': Eval('state') != 'posted',
|
||||
},
|
||||
depends=['state', 'account', 'party', 'id', 'type', 'total_amount'])
|
||||
reconciliation_lines = fields.Function(fields.Many2Many(
|
||||
'account.move.line', None, None, "Payment Lines",
|
||||
states={
|
||||
'invisible': Eval('state') != 'paid',
|
||||
}),
|
||||
'get_reconciliation_lines')
|
||||
amount_to_pay_today = fields.Function(fields.Numeric('Amount to Pay Today',
|
||||
digits=(16, Eval('currency_digits', 2)),
|
||||
depends=['currency_digits']), 'get_amount_to_pay')
|
||||
@@ -646,6 +652,17 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
lines[invoice_id].append(line_id)
|
||||
return lines
|
||||
|
||||
def get_reconciliation_lines(self, name):
|
||||
if self.state != 'paid':
|
||||
return
|
||||
lines = set()
|
||||
for line in self.move.lines:
|
||||
if line.account == self.account and line.reconciliation:
|
||||
for line in line.reconciliation.lines:
|
||||
if line not in self.move.lines:
|
||||
lines.add(line)
|
||||
return [l.id for l in sorted(lines, key=lambda l: l.date)]
|
||||
|
||||
@classmethod
|
||||
def get_amount_to_pay(cls, invoices, name):
|
||||
pool = Pool()
|
||||
|
||||
@@ -306,6 +306,8 @@ Pay invoice::
|
||||
|
||||
>>> invoice.state
|
||||
'paid'
|
||||
>>> sorted(l.credit for l in invoice.reconciliation_lines)
|
||||
[Decimal('1.00'), Decimal('20.00'), Decimal('99.00'), Decimal('120.00')]
|
||||
|
||||
Create empty invoice::
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="amount_to_pay"/>
|
||||
<field name="payment_lines" colspan="4"
|
||||
view_ids="account_invoice.move_line_view_list_payment"/>
|
||||
<field name="reconciliation_lines" colspan="4" view_ids="account_invoice.move_line_view_list_payment"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<field name="party_lang" invisible="1" colspan="6"/>
|
||||
|
||||
Reference in New Issue
Block a user