product-attribute icon indicating copy to clipboard operation
product-attribute copied to clipboard

[17.0] product_pricelist_revision: raising warning on product.pricelist.item name field

Open rrebollo opened this issue 8 months ago • 0 comments

Warning

👇 These lines are raising the below warning:

https://github.com/OCA/product-attribute/blob/e80e148ffaaa44929ac7fbadab27aa1397739474/product_pricelist_revision/models/pricelist.py#L7-L11

Traceback

2025-04-15 21:15:36,131 1 WARNING ? py.warnings: /opt/odoo/custom/src/odoo/odoo/modules/registry.py:372: UserWarning: product.pricelist.item: inconsistent 'store' for computed fields, accessing price may recompute and update name. Use distinct compute methods for stored and non-stored fields.
  File "/opt/odoo/custom/src/islanddeal/00-post-upgrade.py", line 78, in <module>
    main()
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click_odoo/env_options.py", line 194, in _invoke
    with self.environment_manager(
  File "/usr/local/lib/python3.10/contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.10/site-packages/click_odoo/env.py", line 20, in OdooEnvironment
    ctx = Environment(cr, uid, {})["res.users"].context_get()
  File "<decorator-gen-109>", line 2, in context_get
  File "/opt/odoo/custom/src/odoo/odoo/tools/cache.py", line 104, in lookup
    value = d[key] = self.method(*args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/res_users.py", line 810, in context_get
    values = user.read(list(name_to_key), load=False)[0]
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/res_users.py", line 1907, in read
    res = super(UsersView, self).read(other_fields, load=load)
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/res_users.py", line 645, in read
    return super(Users, self).read(fields=fields, load=load)
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3584, in read
    return self._read_format(fnames=fields, load=load)
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/res_users.py", line 1866, in _read_format
    return super()._read_format(valid_fields, load)
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3797, in _read_format
    vals[name] = convert(record[name], record, use_display_name)
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 6693, in __getitem__
    return self._fields[key].__get__(self, self.env.registry[self._name])
  File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 1219, in __get__
    self.compute_value(recs)
  File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 1388, in compute_value
    fields = records.pool.field_computed[self]
  File "/opt/odoo/custom/src/odoo/odoo/tools/func.py", line 28, in __get__
    value = self.fget(obj)
  File "/opt/odoo/custom/src/odoo/odoo/modules/registry.py", line 372, in field_computed
    warnings.warn(

There is a similar warning complaining about the compute_sudo.

Reasoning

I think is related to fact that name and price are computed in the same method in builtin class. So when this code is executed name pass to be store=True and in v17 compute_sudo=True implicitly. But price, compute in the same method is store=False and in v17 compute_sudo=False so ...

rrebollo avatar Apr 15 '25 21:04 rrebollo