AttributeError: 'int' object has no attribute 'copy_sign' when updating statement lines
When updating a statement line I get the following error:
Traceback (most recent call last):
File "/home/pokoli/projectes/tryton/tryton/trytond/trytond/protocols/wrappers.py", line 197, in wrapper
return func(request, pool, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pokoli/projectes/tryton/tryton/trytond/trytond/protocols/dispatcher.py", line 201, in _dispatch
result = rpc.result(meth(inst, *c_args, **c_kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pokoli/projectes/tryton/tryton/trytond/trytond/model/modelview.py", line 51, in wrapper
result = func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pokoli/projectes/tryton/tryton/trytond/trytond/modules/patches/account_statement.py", line 30, in on_change_lines
super().on_change_lines()
File "/home/pokoli/projectes/tryton/tryton/trytond/trytond/model/fields/field.py", line 124, in wrapper
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pokoli/projectes/tryton/tryton/trytond/trytond/modules/account_statement/statement.py", line 307, in on_change_lines
line.amount = amount_to_pay.copy_sign(line.amount)
^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'copy_sign'
This issue is not reproducible using the standard user interface as it apears only when the amount to pay of the invoice is zero but there are more than one line of linked to its invoice. This is not feasible via user interface but it is possible to match it using rules or custom import.
I'm able to reproduce the issue with both account_statement and account_payment modules activated. Here are the steps:
- Create an invoice for a customer
- Pay the invoice using the account_payment module so the amount to pay becomes 0
- Create an statement with 3 lines linked to the previous invoice
- Update the amount of the last line.
The error is raised on step 4.