Odoo Help

0

Custom module with record rule: No access on stock location when loading product treeview

By
Yohann
on 8/29/13, 1:22 PM 1,981 views

Hello,

I created a module that add on stock.location, product.product, stock.picking and res.users a many2one field : warehouse_id.

from osv import osv, fields

class res_users(osv.osv):
    _name       = 'res.users'
    _inherit    = 'res.users'

    _columns = {
        'warehouse_id': fields.many2one('stock.warehouse', 'Entrepot'),
    }
res_users()

class stock_picking(osv.osv):
    _name       = 'stock.picking'
    _inherit    = 'stock.picking'

    _columns = {
        'warehouse_id': fields.many2one('stock.warehouse', 'Entrepot', required=True),
    }
stock_picking()

class stock_location(osv.osv):
    _name       = 'stock.location'
    _inherit    = 'stock.location'

    _columns = {
        'warehouse_id': fields.many2one('stock.warehouse', 'Entrepot', required=True),
    }
stock_location()

class product_product(osv.osv):
    _name = 'product.product'
    _inherit = 'product.product'

    _columns = {
        'warehouse_id': fields.many2one('stock.warehouse', 'Entrepot', required=True),
    }
product_product()

Then, I added record rule on stock.location, product.product and stock.picking like that :

[('warehouse_id', '=', user.warehouse_id.id)]

And the problem is when I try to load the tree view of product.product, it shows me :

AccessError Operation prohibited by access rules, or performed on an already deleted document (Operation: read, Document type: Stock Location).

Does anyone have an idea to solve this problem or what am I doing wrong ?

Thank you a lot !

3
Borni DHIFI
On 8/29/13, 7:34 PM

Hi,

it is a Access Rights to user used who uses your custom module.

so add a user to groupe Warehouse User or create custom security/ir.model.access.csv to affecte a Access Rights for your new group.

0
Yohann
On 8/30/13, 5:12 AM

Hello,

Thank you for your answer but the user already belongs to group Warehouse Manager.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 8/29/13, 1:22 PM
Seen: 1981 times
Last updated: 3/16/15, 8:10 AM