简体   繁体   English

如何根据 odoo 中用户允许的分支来域/过滤 PO

[英]How to domain/filter PO based on user allowed branch in odoo

I want to display PO based on allowed branch in odoo.我想根据 odoo 中允许的分支显示 PO。 So if you log in as user Ana with allowed branch = Singapore, then the PO that appear are only PO with the Singapore branch.因此,如果您以允许分支 = 新加坡的用户 Ana 身份登录,则出现的采购订单仅为新加坡分支的采购订单。 Maybe someone knows and can give advice?也许有人知道并可以提供建议?

Thanks谢谢

Best Regards最好的祝福

you can use the domain field on a model to filter records based on certain criteria.您可以使用模型上的域字段根据特定条件过滤记录。 This can be useful for restricting which records are visible to a user based on their allowed.这对于根据允许的用户限制哪些记录对用户可见很有用。

Another alterative to make a custom domain (maybe dificult because you need to access the current user)制作自定义域的另一种选择(可能很困难,因为您需要访问当前用户)

I think you can define a new security rule, to discard PO with no match in the branch.我认为您可以定义一个新的安全规则,以丢弃分支中没有匹配项的 PO。 but not sure if you can do user.branch_id or some other field distinct od id.但不确定您是否可以执行user.branch_id或其他一些字段不同的 od id。

<record id="branch_po_rule" model="ir.rule">
        <field name="name">PO own branch</field>
        <field name="model_id"  ref="model_purchase_order"/>
        <field eval="True" name="global"/>
        <field name="domain_force">('branch_id','=',user.branch_id))]</field>
    </record>

But security rules are meant to do this kind of discriminations但是安全规则就是为了做这种歧视

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM