diff options
| author | Nans Lefebvre <len@odoo.com> | 2019-06-11 08:45:16 +0000 |
|---|---|---|
| committer | Nans Lefebvre <len@odoo.com> | 2019-06-12 07:58:15 +0000 |
| commit | f1706c848d41c47646dabca771996e9b9f788241 (patch) | |
| tree | ec74ee532149e7973db7255fb2d547a8a0e72606 /addons | |
| parent | a25f6e1b9617a04ccc517ed2e53429ca233ba728 (diff) | |
[FIX] stock: put stored related field product_code in compute_sudo
Have a multi-company setup, with shared products.
Write the default code of a product; an access error is raised on inventory.line
On inventory.line, the field product_code is defined as related to
'product_id.default_code', and stored.
So when writing on the default_code of a product, we get the inventory lines of
other companies. For obvious reasons their access is protected by the record
rule "Inventory Line multi-company", therefore the access error is raised.
To avoid that situation stored related fields should be in compute_sudo.
Note that similarly this is necessary for product_name.
There is one more subtlety: directly writing on the product.product does trigger
the access error, but writing it on the product.template does not.
opw 2007167
closes odoo/odoo#34019
Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/stock/models/stock_inventory.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py index 2b4f077dabb..1c8db33734c 100644 --- a/addons/stock/models/stock_inventory.py +++ b/addons/stock/models/stock_inventory.py @@ -310,9 +310,9 @@ class InventoryLine(models.Model): domain=[('type', '=', 'product')], index=True, required=True) product_name = fields.Char( - 'Product Name', related='product_id.name', store=True, readonly=True) + 'Product Name', related='product_id.name', store=True, readonly=True, compute_sudo=True) product_code = fields.Char( - 'Product Code', related='product_id.default_code', store=True) + 'Product Code', related='product_id.default_code', store=True, readonly=True, compute_sudo=True) product_uom_id = fields.Many2one( 'product.uom', 'Product Unit of Measure', required=True, |
