跳至内容
菜单
此问题已终结
2 回复
2589 查看

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

形象
丢弃
最佳答案

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

形象
丢弃
最佳答案

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

形象
丢弃
相关帖文 回复 查看 活动
2
3月 24
1975
2
6月 23
3888
2
9月 22
4354
1
3月 24
1760
1
11月 22
2555