Wrong on_change calls on a paid invoices
When opening the form view on sao of an invoice with alternate currency that has been already paid I get the following traceback:
Traceback (most recent call last):
File "/trytond/wsgi.py", line 71, in dispatch_request
return endpoint(request, **request.view_args)
File "/trytond/protocols/dispatcher.py", line 41, in rpc
request, database_name, *request.rpc_params)
File "/trytond/wsgi.py", line 42, in auth_required
return wrapped(*args, **kwargs)
File "/trytond/protocols/wrappers.py", line 122, in wrapper
return func(request, pool, *args, **kwargs)
File "/trytond/protocols/dispatcher.py", line 172, in _dispatch
result = rpc.result(meth(inst, *c_args, **c_kwargs))
File "/trytond/model/modelview.py", line 671, in on_change
method()
File "/trytond/model/modelview.py", line 84, in wrapper
result = func(self, *args, **kwargs)
File "/trytond/model/fields/field.py", line 113, in wrapper
return func(self, *args, **kwargs)
File "/trytond/modules/account/move.py", line 817, in on_change_debit
self._amount_second_currency_sign()
File "/trytond/modules/account/move.py", line 833, in _amount_second_currency_sign
self.amount_second_currency.copy_sign(self.debit - self.credit)
TypeError: unsupported operand type(s) for -: 'NoneType' and 'Decimal'
The error is raised because sao triggers the following request:
ERROR trytond.protocols.dispatcher .on_change(*({u'id': 4, u'credit': Decimal('16.5'), u'amount_second_currency': Decimal('-18.15'), u'debit': None}, [u'debit'], {u'language': u'en', u'language_direction': u'ltr', u'company.rec_name': u'Company', u'groups': [5, 6, 1, 2, 3, 4], u'employee': None, u'type': u'out', u'company': 1}), **{}) from admin@127.0.0.1//account_es/
If I open an invoice with company currency, when navigating I get a message if I want to save the changes (but I haven't modified anything).
Everything works as expected on tryton.