File “/usr/lib/python3/dist-packages/trytond/model/modelstorage.py”, line 1326, in _validate
else:
File “/usr/lib/python3/dist-packages/trytond/model/modelstorage.py”, line 1310, in digits_test
if isinstance(value, Decimal):
^^^^^^^^^^^^^^^^^^^
decimal.InvalidOperation: [<class ‘decimal.InvalidOperation’>]
i do not know how to debug il i write in digits_test
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/proteus/__init__.py", line 102, in newfunc
return self.func(owner, [instance], *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/proteus/__init__.py", line 847, in save
ids = proxy.create(values, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/proteus/config.py", line 202, in __call__
result = rpc.result(meth(*args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/trytond/modules/stock/move.py", line 815, in create
moves = super(Move, cls).create(vlist)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/trytond/model/modelsql.py", line 159, in wrapper
return func(cls, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/trytond/model/modelsql.py", line 679, in create
cls._validate(sub_records)
File "/usr/lib/python3/dist-packages/trytond/model/modelstorage.py", line 79, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/trytond/model/modelstorage.py", line 1328, in _validate
digits_test(getattr(record, field_name),
File "/usr/lib/python3/dist-packages/trytond/model/modelstorage.py", line 1312, in digits_test
if value.quantize(exp) != value:
^^^^^^^^^^^^^^^^^^^
decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]
def digits_test(value, digits, field_name):
print(value, digits, field_name) # My debug line
def raise_error(value):
error_args = cls.__names__(field_name)
error_args['digits'] = digits[1]
error_args['value'] = repr(value)
raise DigitsValidationError(
gettext('ir.msg_digits_validation_record',
**error_args))
if (value is None
or not digits
or any(d is None for d in digits)):
return
if isinstance(value, Decimal):
exp = Decimal('.'.join(['0', '0' * digits[1]]))
print(exp,value,digits) #my 2nd debug linze
if value.quantize(exp) != value:
raise_error(value)
Unlike other operations, if the length of the coefficient after the quantize operation would be greater than precision, then an InvalidOperation is signaled.
Any way I do not see any reason to set a global precision so low on decimal. Tryton is expected to run with the default decimal context.
you have the right to doubt in your reality, but in my reality of work it is the case.
i kow why that situation happens and i know how to by pass but there might be some problems elsewhere.
if i do
val=value.quantize(Decimal(“0.000”))
with 12.123456
>>> decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]
val=value.quantize(Decimal(“0.00”))
with 12.123456
val => 12.12
this happens because we decide to have 4 decimals because we have tva 5.5 and having a rounded TTC price with 1.055 is some time complicated
no the subjet was not resolve and i doubt that someone wanting to use proteus with move will face the same problem. in that script Create initial stock moves with proteus on a remote server the price was not used. and with the price it would not work.