Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
2 Besvarelser
2613 Visninger

Obj : make user see only warehouse operation types that i will a singe to him  

what i did : i created new module in my model  i did this 

class ResUsers(models.Model):
_inherit = 'res.users'
operation_type_ids = fields.Many2many('stock.picking.type', string="Multi Picking")

Then I added this field in user view  


What i need : domain filter condition to put in   inventory  record rule so it can display to the user only operation types  that i  a signed in Operation Types field

Avatar
Kassér
Bedste svar

Hiii,

Add Record Rule on stock.picking.type
This ensures that users can only access operation types assigned to them.

<record id="stock_picking_type_user_visibility_rule" model="ir.rule">

    <field name="name">Limit Operation Types per User</field>

    <field name="model_id" ref="stock.model_stock_picking_type"/>

    <field name="domain_force">[('id', 'in', user.operation_type_ids.ids)]</field>

    <field name="global" eval="False"/>

    <field name="groups" eval="[(4, ref('base.group_user'))]"/>

    <field name="perm_read" eval="True"/>

    <field name="perm_write" eval="False"/>

    <field name="perm_create" eval="False"/>

    <field name="perm_unlink" eval="False"/>

</record>


Add this via code or through the Odoo UI:

=> Settings > Technical > Record Rules > Create

i hope it is use full

Avatar
Kassér
Bedste svar

Hi,

Since you've added a Many2many field operation_type_ids to the res.users model to assign specific warehouse operation types to each user, you can create a record rule to restrict visibility accordingly.

 

Try like following

xml

<record model="ir.rule" id="stock_operation_type_rule">


    <field name="name">Warehouses Operation Type</field>


    <field name="model_id" ref="stock.model_stock_picking_type"/>


    <field name="domain_force">[('id', 'in', user.operation_type_ids.ids)]</field>


    <field name="groups" eval="[(4, ref('base.group_user'))]"/>



</record>



Hope it helps

Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
2
mar. 24
1998
2
jun. 23
3904
2
sep. 22
4378
1
mar. 24
1791
1
nov. 22
2576