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’?)
Trying a test with trytond-console using:
>>> Invoice = pool.get(‘account.invoice’)
>>> invoices = Invoice.search([(‘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?
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?