Skip to Content
Menu
This question has been flagged
1 Reply
3867 Views

Hello. I extend sale.order model with a field. As result I want to get a tree view with a char field that contains a string made of all product names of an order.


class SaleOrderInherit(models.Model):
    _inherit = 'sale.order'

    order_products = fields.Char(string='Order products', compute='_compute_order_products')

    @api.depends('order_line.product_id')
    def _compute_order_products(self):
        for _order in self:
            s_order_products = ''
            for _order_line in _order.order_line:
                s_order_products += str(_order_line.product_id.name) + ', '
            _order.order_products = s_order_products[:-2]


I get this error:

The requested operation ("read" on "Product" (product.product)) was rejected because of the following rules: 

 (Records: False (id=3), User: Administrator (id=2))

Implicitly accessed through 'Product' (product.product).

Avatar
Discard

Set permission in Odoo: https://goo.gl/8DZYRT

Best Answer

Hi,

The issue is with the access rights, while computing the value it is reading value from the product master, but the logged in user group has no permission to read the corresponding model/record .

So either you have to adjust the access rights/ record rule accordingly so that the user group can get/read value from product master or you can use sudo to bypass the access rights. Using sudo is not a proffered/recommended way.

Thanks

Avatar
Discard
Author

But user Administrator has full access to product.product.

Also if I use compute_sudo=True, nothing changes.

order_products = fields.Char(string='Order products', compute='_compute_order_products', compute_sudo=True)

Thanks

Related Posts Replies Views Activity
2
Nov 24
476
4
Feb 24
10164
1
Jan 24
369
0
May 23
831
4
Apr 23
38316