Skip to Content
Menu
This question has been flagged
2 Replies
2588 Rodiniai

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

Portretas
Atmesti
Best Answer

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

Portretas
Atmesti
Best Answer

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

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
2
kov. 24
1973
2
birž. 23
3888
2
rugs. 22
4354
1
kov. 24
1759
1
lapkr. 22
2554