Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
2802 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
2
Mar 24
2222
2
Jun 23
4167
2
Sep 22
4618
1
Mar 24
1966
1
Nov 22
2685