Error exporting data in Many2One field

Al intentar exportar x cantidad de registros desde el cliente de Tryton, cuando selecciono un campo de tipo Many2One, me arroja el siguiente error:

9 140458065190976 [2024-11-25 16:48:34,148] ERROR trytond.protocols.dispatcher party.party.export_data([829, 974, 1068, 513, 117, ...], ['code', 'name', 'tax_identifier/re...', 'routes/rec_name'], True, {'client': 'fa8650f1-c0ee-451...', 'warehouse': 5, 'warehouse.rec_nam...': 'Almacén', 'company_filter': 'one', 'company': 1, ...}) from admin@172.18.0.1/tryton/ in 39 ms
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/trytond/protocols/dispatcher.py", line 196, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/trytond/model/modelstorage.py", line 794, in export_data
    data += cls.__export_row(record, fields_names)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/trytond/model/modelstorage.py", line 729, in __export_row
    value = getattr(value, field_name)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/trytond/model/fields/function.py", line 192, in __get__
    return super().__get__(inst, cls)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/trytond/model/fields/field.py", line 393, in __get__
    return inst.__getattr__(self.name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/trytond/model/modelstorage.py", line 1826, in __getattr__
    fvalue = instantiate(field, data[fname], data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/trytond/model/modelstorage.py", line 1775, in instantiate
    value = int(value)
            ^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'tuple'

Se identifica que el campo que genera el error es de tipo function como se muestra a continuación:

routes = fields.Function(
        fields.Many2One("party.route", "Routes"),

This is not a standard field so I guess the getter of this Function does not compute the proper type as value.

Correcto, el campo no es estandar y observamos que estaba mal definido, se dio solución, modificando el campo y su getter, quedando como se muestra a continuación:


    routes = fields.Function(
            fields.One2Many("party.route", None, "Routes"),
            'get_routes', searcher='search_routes')

    def get_routes(self, name):
        routes = []
        for address in self.addresses:
            routes.extend(r.id for r in address.routes)
        return routes

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