Error al intentar buscar un registro por el id XML

Estoy intentando buscar una ubicacion haciendo uso de la clase Id de pyson de la siguiente manera:

    @staticmethod
    def default_warehouse():
        Location = Pool().get('stock.location')
        location, = Location.search(
            [('id', '=', Id('stock', 'location_warehouse'))])
        return location.id

Pero obtengo el siguiente error:

Traceback (most recent call last):
  File "/.../lib/python3.11/site-packages/trytond/protocols/dispatcher.py", line 180, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/trytond/model/model.py", line 149, in default_get
    value[field_name] = cls._defaults[field_name]()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cristhian/Documents/job/ACK/modules/galparsoro/forecast.py", line 39, in default_warehouse
    location, = Location.search(
                ^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/trytond/model/modelsql.py", line 1450, in search
    tables, expression = cls.__search_query(domain, count, query, order)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/trytond/model/modelsql.py", line 1369, in __search_query
    tables, expression = cls.search_domain(domain)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/trytond/model/modelsql.py", line 1579, in search_domain
    expression = convert(domain)
                 ^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/trytond/model/modelsql.py", line 1575, in convert
    return And((convert(d) for d in (
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/trytond/model/modelsql.py", line 1575, in <genexpr>
    return And((convert(d) for d in (
                ^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/trytond/model/modelsql.py", line 1566, in convert
    expression = field.convert_domain(domain, tables, cls)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/trytond/model/fields/field.py", line 408, in convert_domain
    expression = Operator(column, self._domain_value(operator, value))
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/trytond/model/fields/field.py", line 385, in _domain_value
    return self.sql_format(value)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/trytond/model/fields/field.py", line 363, in sql_format
    value = self._py_type(value)
            ^^^^^^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'Id'

You can not use PYSON statement directly in the domain of ModelStorage.search.
You must retrieve the id of the location using ModelData.get_id (ir.model.data).

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