I am trying to restrict visibility of Inter-Company Purchase Orders and Sale Orders in Odoo 15.
I added a Boolean field on both models:
is_inter_company_po on purchase.order
is_inter_company_so on sale.order
If the field is True, the document should be visible only to a special access group.
All other users should not see these inter-company records.
My Record Rules
<record id="purchase_hide_intercompany_po_rule" model="ir.rule"> <field name="name">Hide Intercompany Purchase Orders (Global)</field> <field name="model_id" ref="purchase.model_purchase_order"/> <field name="domain_force">[('is_inter_company_po', '=', False)]</field> <field name="groups" eval="[(6, 0, [])]"/> <!-- Apply to ALL users --> </record>
<record id="sale_hide_intercompany_so_rule" model="ir.rule"> <field name="name">Hide Intercompany Sale Orders (Global)</field> <field name="model_id" ref="sale.model_sale_order"/> <field name="domain_force">[('is_inter_company_so', '=', False)]</field> <field name="groups" eval="[(6, 0, [])]"/> <!-- Apply to ALL users --> </record>
In addition, I created a new group:
"Sales / Access to Intercompany Sale Orders" "Purchase / Access to Intercompany Purchase"
Some users can still see Inter-Company Sale Orders / Purchase Orders.
It looks like another record rule is overriding my hide rule.
Especially on purchase.order — the hide rule does not fully take effect.
I want to:
Hide inter-company SO/PO from all users by default.
Allow only one specific group to see them.
Make sure no other record rule overrides or cancels this rule
I later tried to override the existing rule directly, but the override did not work and I am trying to understand why.
Original rule:
My attempt to inherit/override it:
Can you explain why this override is ignored? I believe the module dependencies are correct, so I expected this to replace the domain_force of the original rule, but nothing changes.
Hello, Use the <function> tag in your custom module's XML:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<function model="ir.rule" name="write">
<value eval="[ref('sale.sale_order_see_all')]"/>
<value eval="{'domain_force': "['&', ('stock_move_request_id', '=', False), (1, '=', 1)]"}"/>
</function>
</odoo>
Hope it helps