access_restriction_by_user/models/res_users.py

57 lines
1.8 KiB
Python

from odoo import models, fields
class ResUsers(models.Model):
_inherit = 'res.users'
allowed_warehouse_ids = fields.Many2many(
'stock.warehouse',
'res_users_stock_warehouse_rel',
'user_id',
'warehouse_id',
string="Allowed Warehouses",
help="Warehouses this user is allowed to access. Leave empty to restrict access to none."
)
allowed_picking_type_ids = fields.Many2many(
'stock.picking.type',
'res_users_stock_picking_type_rel',
'user_id',
'picking_type_id',
string="Allowed Picking Types",
help="Picking Types this user is allowed to access. Leave empty to restrict access to none."
)
allowed_location_ids = fields.Many2many(
'stock.location',
'res_users_stock_location_rel',
'user_id',
'location_id',
string="Allowed Locations",
help="Locations this user is allowed to access. Leave empty to restrict access to none."
)
allowed_workcenter_ids = fields.Many2many(
'mrp.workcenter',
'res_users_mrp_workcenter_rel',
'user_id',
'workcenter_id',
string="Allowed Work Centers",
help="Work Centers this user is allowed to access. Leave empty to restrict access to none."
)
allowed_approval_category_ids = fields.Many2many(
'approval.category',
'res_users_approval_category_rel',
'user_id',
'category_id',
string="Allowed Approvals",
help="Approval Categories this user is allowed to access. Leave empty to restrict access to none."
)
allowed_quality_checks = fields.Boolean(
string="Is Allowed todo Quality Checks?",
default=False,
help="If checked, this user can see the Quality Checks button on Manufacturing Orders.",
prefetch=False,
)