development:override_an_existing_record_rules

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
development:override_an_existing_record_rules [2022/02/17 18:49] azizdevelopment:override_an_existing_record_rules [2022/03/07 09:46] (current) – [Examples:] aziz
Line 1: Line 1:
-:todo: Giving context and examples 
- 
  
 <code xml> <code xml>
Line 10: Line 8:
  </record>  </record>
 </code> </code>
 +
 +Explanation:
 +
 +Record Rules / <ir.rules>
 +
 +==== 1- definitions: =====
 +
 +  * Conditions that records must satisfy for an operation (create, read, update or delete) to be allowed.
 +  * Boolean fields (read, write, create, delete) of ir.rule mean Apply this rule for this kind of operation. 
 +  * Mechanisms to manage or restrict access to data.
 +  * Make use of domain to specify which records can be selected.
 +
 +
 +=====  2- There are two types of Record Rule: =====
 +
 +Global rules and group rules 
 +- (rules restricted to specific groups VERSUS groups applying to all users)
 +
 +
 +===== 3- A record rule has: =====
 +
 +  * Name
 +
 +<code xml>
 +<field name = "name"> Rule_name </field>
 +</code>
 +
 +  * Model on which it applies
 +
 +<code xml>
 +<field ref = "module.model for this rule" name = "model_id" />
 +</code>
 +
 +  * Set of user groups to which the rule applies, if no group is specified the rule is global
 +
 +<code xml>
 +<field name = "groups" eval = " [(4, ref ('group of this rule'))] "/>
 +</code>
 +
 +  * Domain used to check whether a given record matches the rule (and is accessible) or does not (and is not accessible).
 +
 +<code xml>
 +<field name="domain_force">here add your new domain</field>
 +</code>
 +===== Domain examples: =====
 +
 +Group : Sales / User: Own Documents Only
 +
 +<code>
 +['|',
 +  ('user_id','=',user.id),
 +  ('user_id','=',False)
 +
 +</code>
 +
 +This mean:  
 +- user can access just to his own orders / quotations .
 +- orders with no specific user .
 +
 +Group : Sales / User: All Documents
 +
 +''[(1,'=',1)]''
 +This will grant access to ALL Sales Orders / Quotations.
 +
 +
  • development/override_an_existing_record_rules.1645123799.txt.gz
  • Last modified: 2022/02/17 18:49
  • by aziz