Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
5495 Vizualizări

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 !

Imagine profil
Abandonează
Cel mai bun răspuns

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.

Imagine profil
Abandonează
Autor Cel mai bun răspuns

Hello,

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

Imagine profil
Abandonează