RPC-Call: Error in Wizard Execute

RPC-Call: Error in Wizard Execute

I am using Tryton 7.0 and a web-app that uses RPC-Call.
The web-app works fine with Tryton. Since switching to Tryton 7, I can’t manage the wizards via RPC-Call in PHP.

I don’t get errors in creating and deleting wizards.

I get errors in the execute. Here is an example:
RPC-Call:

$context_mod = array_merge($context,[ 'active_id'=>13, 'active_ids'=>[13], 'active_model'=>'stock.digivoucher', 'action_id'=>624 ]);

$execute_wizard = $rpcClient->cl('wizard.stock.digivoucher.planned_date.define.execute', [41776, ['start'=>['comment'=>'', 'date'=>'2025-02-12']], 'define', $context_mod]);

Error:

Array
(
    [state] => 
    [result] => Array
        (
            [0] => 'str' object cannot be interpreted as an integer
            [1] => Traceback (most recent call last):
  File "/core/trytond/trytond/wsgi.py", line 109, in dispatch_request
    return endpoint(request, **request.view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/core/trytond/trytond/protocols/dispatcher.py", line 43, in rpc
    return methods.get(request.rpc_method, _dispatch)(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/core/trytond/trytond/wsgi.py", line 75, in wrapper
    return func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/core/trytond/trytond/protocols/wrappers.py", line 200, in wrapper
    return func(request, pool, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/core/trytond/trytond/protocols/dispatcher.py", line 196, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/core/trytond/trytond/wizard/wizard.py", line 339, in execute
    setattr(record, field, value)
  File "/core/trytond/trytond/model/fields/field.py", line 403, in __set__
    value = self._py_type(value)
            ^^^^^^^^^^^^^^^^^^^^
TypeError: 'str' object cannot be interpreted as an integer

        )
)

For date fields, I use the text format in all RPC-Calls and I have never had problems (e.g. “2025-02-13”).

Can you help me solve this problem? Thanks!

New versions of Tryton become more and more strict about the input data.
Here is that you provide a string for a Date field but since Prevent assign SQL value to record instances (51719a6696d5) · Commits · Tryton / Tryton · GitLab it is failing.
So of course it is always better to use the proper format and for JSON-RPC Tryton has defined one for the date (see trytond/protocols/jsonrpc.py).
But I think you can fill an issue because we could restore the support assignation of string value for Date, DateTime, Time, TimeStamp and TimeDelta fields.

Thanks CED, you saved my day!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Ref Restore support of assigning non-standard value to field (#13873) · Issues · Tryton / Tryton · GitLab