Denis Ledoux e00277fb5b [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#66956

X-original-commit: a08ba4be6518dd99ce93a803724165f62cbef032
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2021-02-26 17:40:45 +00:00
…
…
…
…
…
2020-09-28 14:07:25 +00:00

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials

S
Description
No description provided
Readme LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%