Odoo Help

Welcome!

This community 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.

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,566 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

--Borni DHIFI--
5102
| 6 8 9
Tunis, Tunisia
--Borni DHIFI--

Techno Functional Consultant Odoo(OpenERP) 

http://www.linkedin.com/in/borni

Skype : dhifi.borni

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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