Getting invoice state 'paid' when primary move line reconciled

One ornery fallout of our recent migration from OpenERP to Tryton is the fact we ignored the need to set invoice.move to the accounting move generated, we only set move.origin back to the invoice.

I did a psql one-liner to set invoice.move, which seems fine … one can now navigate to the move from the invoice.

The issue is for the payments made under Tryton with invoices migrated.

The invoice state does not pick up the fact that the primary move line may now be reconciled.

Now, if I de-reconcile and re-reconcile the primary move line then the invoice state is correctly set.

Naturally I’m not too warm to do this with a few hundred invoices, any hint on getting these invoices to process more automatically the reconciled state of the move?

It would be nice to avoid patching Invoice.process() but perhaps that’s the only way?
or some tryton-console magic? (since amount to pay is ‘0’ in this case, is it reasonable simply to force the state to ‘paid’?)

Thanks in advance

Trying a test with trytond-console using:
>>> Invoice = pool.get(‘account.invoice’)
>>> invoices =[(‘state’, ‘=’, ‘posted’), (‘invoice_date’, ‘<’, ‘2019-01-01’)])
>>> for invoice in invoices:
… if invoice.state == ‘posted’ and invoice.amount_to_pay == 0.0:
… for line in invoice.move.lines:
… if line.account == invoice.account and line.reconciliation is not None:
… invoice.state = ‘paid’
>>> transaction.commit()

(can’t seem to get indentation to work correctly here)

doesn’t seem to change the state.

If I print I do get the correct data though and navigating using the same logic works as well.
Is the problem manually changing the state to ‘paid’ that’s a noop?

adding a call after setting the state ?

The proper way would be to call Invoice.process on all affected invoices.

Yes, that seems to work great and much simpler!

Invoice = pool.get(‘account.invoice’)
invoices =[(‘state’, ‘=’, ‘posted’), (‘invoice_date’, ‘<’, ‘2019-01-01’)])


oups, I notice that there are some (two ‘in’ and one ‘out’ invoice) that don’t get reconciled.
(they all have amount to pay = 0.00)

How to debug why?

I checked that invoice.move is correct and move.origin too, as well as the primary move line being correctly reconciled…

using pudb it appears as if get_reconciled() returns always None, invoice.lines_to_pay is always empty.
maturity_date is None.

Why not reconcile move lines where maturity_date isn’t set?

To work around this, I thought to edit the maturity date, thought I read somewhere it was now possible. Can’t seem to see where I could do that in 5.2. Stuck?

I tested by setting with psql the maturity date of one of these records… that did it.

I found that editing maturity dates was seemingly possible back in 4.8.x but apparently no longer.
created Issue 8787: can't seem to edit maturity date on moves - Tryton issue tracker

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.