I am trying to list payments line in an invoice.
looking at the payments term in the code i thought that in relatorio, it could make it
<for each="line in invoice.payment_lines">
because
<for each="line in invoice.lines_to_pay">
works like a charm…
class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
'Invoice'
__name__ = 'account.invoice'
[...]
lines_to_pay = fields.Function(fields.Many2Many(
'account.move.line', None, None, 'Lines to Pay'),
'get_lines_to_pay')
payment_lines = fields.Many2Many('account.invoice-account.move.line',
'invoice', 'line', string='Payment Lines',
domain=[
('account', '=', Eval('account', -1)),
('party', 'in', [None, Eval('party', -1)]),
['OR',
('invoice_payment', '=', None),
('invoice_payment', '=', Eval('id', -1)),
],
If(Eval('type') == 'out',
If(Eval('total_amount', 0) >= 0,
('debit', '=', 0),
('credit', '=', 0)),
If(Eval('total_amount', 0) >= 0,
('credit', '=', 0),
('debit', '=', 0))),
],
states={
'invisible': Eval('state') == 'paid',
'readonly': Eval('state') != 'posted',
},
depends=['state', 'account', 'party', 'id', 'type', 'total_amount'])
but it says
IndexError: pop from empty list
and in the ‘account.invoice-account.move.line’ table i have the info
tryton=# select * from “account_invoice-account_move_line” order by id desc;
id | create_date | create_uid | invoice | line | write_date | write_uid
----±---------------------------±-----------±--------±-----±-----------±----------
20 | 2025-01-23 13:25:06.741864 | 1 | 39 | 228 | |
39 is the id of the invoice
select id,debit,credit from account_move_line where id=228;
id | credit | debit |
-----±--------±----------±
228 | | 38.77 | 0 |
i tried to make a function like get_lines_to_pay but i did not succeed… where can i find some code helping me to do it ?