[FIX] purchase_stock: `on_time_rate` product other company than PO
- User in company A,
- Purchase order in company A,
- Product in company B
```
File "/home/odoo/src/odoo/14.0/addons/purchase_stock/models/res_partner.py", line 23, in _compute_on_time_rate
]).filtered(lambda l: l.product_id.product_tmpl_id.type != 'service' and l.order_id.state in ['done', 'purchase'])
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 5279, in filtered
return self.browse([rec.id for rec in self if func(rec)])
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 5279, in <listcomp>
return self.browse([rec.id for rec in self if func(rec)])
File "/home/odoo/src/odoo/14.0/addons/purchase_stock/models/res_partner.py", line 23, in <lambda>
]).filtered(lambda l: l.product_id.product_tmpl_id.type != 'service' and l.order_id.state in ['done', 'purchase'])
File "/home/odoo/src/odoo/14.0/odoo/fields.py", line 2483, in __get__
return super().__get__(records, owner)
File "/home/odoo/src/odoo/14.0/odoo/fields.py", line 998, in __get__
record._fetch_field(self)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 3072, in _fetch_field
self._read(fnames)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 3183, in _read
raise self.env['ir.rule']._make_access_error('read', forbidden)
odoo.exceptions.AccessError: Due to security restrictions, you are not allowed to access 'Product' (product.product) records.
```
If you do not share products between companies
(if the multi-company record rule for `product.template` is enabled)
then you are not supposed to use a product from another company in a purchase order.
However, this is possible to land in the case if you enable
the multi-company record rule after you created some purchase orders,
using products from other companies.
Adding `sudo()` just to get the type of product
doesn't cost much to support that case
upg-8277
closes odoo/odoo#66936
Signed-off-by:
Denis Ledoux (dle) <dle@odoo.com>
Loading
Please register or sign in to comment