I am relatively new to Odoo and I am playing around with record rules. I am just testing out my code to see if I understand how Odoo works. I added a selection field to the users model where you could pick their country. I then added another selection field to the sales orders where you can choose which country the sale order is assigned to. I then wanted to use a record rule so that sales users with all documents access could only see the sale in their own country. I know this is probably not the best way of doing it but it is just a proof of concept for record rules. The problem is I introduced the record rules to the necessary groups but they dont seem to take any effect. I just want to compare the country fields to make sure they are equal and only show records with the same country as the user but it is not working. I dont know which context variables I can use for the domain since I dont know which variables the context has.
here are the three record rules I wrote
<record id="sale_rule_country" model="ir.rule">
<field name="name">Only ALL Own Country Sales</field>
<field name="model_id" ref="model_sale_order"/>
<field eval="True" name="global"/>
<field name="domain_force">[(user.user_country,'=','country_name')]</field>
<field name="groups" eval="[(4, ref('sales_team.group_sale_salesman_all_leads'))]"/>
</record>
<record id="sale_manager_rule_country" model="ir.rule">
<field name="name">Employee Only Own Country Sales</field>
<field name="model_id" ref="model_sale_order"/>
<field eval="True" name="global"/>
<field name="domain_force">[(user.user_country,'=','country_name')]</field>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="sale_rule_country_own" model="ir.rule">
<field name="name">Only Own Country Sales</field>
<field name="model_id" ref="model_sale_order"/>
<field eval="True" name="global"/>
<field name="domain_force">[(user.user_country,'=','country_name')]</field>
<field name="groups" eval="[(4, ref('sales_team.group_sale_salesman'))]"/>
</record>