Crash in Pay invoice with overpayment
On Tryton version 6.8, when attempting to pay an customer invoice from the invoice form by clicking Pay with an amount greater than the amount to pay, results in a crash. The error is:
Thu Jul 13 17:49:04 2023] ERROR-trytond.protocols.dispatcher-account.invoice.pay.execute(49259, {'ask': {'amount': Decimal('161.585'), 'amount_writeoff': Decimal('-161. [truncated]...) from admin@127.0.0.1/inde5_6/ in 298 ms
Traceback (most recent call last):
File "/home/richi/work/tryton60/tryton_src/trytond/trytond/protocols/dispatcher.py", line 204, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/home/richi/work/tryton60/tryton_src/trytond/trytond/wizard/wizard.py", line 340, in execute
result = wizard._execute(state_name)
File "/home/richi/work/tryton60/tryton_src/trytond/trytond/wizard/wizard.py", line 380, in _execute
result = self._execute(transition())
File "/home/richi/work/tryton60/tryton_src/trytond/trytond/modules/account_invoice/invoice.py", line 3380, in transition_pay
MoveLine.reconcile(
File "/home/richi/work/tryton60/tryton_src/trytond/trytond/modules/account/move.py", line 1561, in reconcile
move = cls._get_writeoff_move(
File "/home/richi/work/tryton60/tryton_src/trytond/trytond/modules/account/move.py", line 1648, in _get_writeoff_move
if account.second_currency:
AttributeError: 'NoneType' object has no attribute 'second_currency'
Thu Jul 13 17:49:04 2023] ERROR-trytond.protocols.wrappers-<JSONRequest 1@127.0.0.1 'http://localhost:8080/inde5_6/' [POST] wizard.account.invoice.pay.execute>
Traceback (most recent call last):
File "/home/richi/work/tryton60/tryton_src/trytond/trytond/protocols/wrappers.py", line 197, in wrapper
return func(request, pool, *args, **kwargs)
File "/home/richi/work/tryton60/tryton_src/trytond/trytond/protocols/dispatcher.py", line 204, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/home/richi/work/tryton60/tryton_src/trytond/trytond/wizard/wizard.py", line 340, in execute
result = wizard._execute(state_name)
File "/home/richi/work/tryton60/tryton_src/trytond/trytond/wizard/wizard.py", line 380, in _execute
result = self._execute(transition())
File "/home/richi/work/tryton60/tryton_src/trytond/trytond/modules/account_invoice/invoice.py", line 3380, in transition_pay
MoveLine.reconcile(
File "/home/richi/work/tryton60/tryton_src/trytond/trytond/modules/account/move.py", line 1561, in reconcile
move = cls._get_writeoff_move(
File "/home/richi/work/tryton60/tryton_src/trytond/trytond/modules/account/move.py", line 1648, in _get_writeoff_move
if account.second_currency:
AttributeError: 'NoneType' object has no attribute 'second_currency'