I'd like to create a record rule for my app.
Here is my XML:
<record model="ir.rule" id="ir_rule_something">
<field name="name">something</field>
<field name="model_id" ref="model_something"/>
<field name="domain_force">[('agent','in',function_that_return_list_of_ids)]</field>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_unlink" eval="False"/>
<field name="perm_create" eval="False"/>
</record>
I would like the function_that_return_list_of_ids
to return a list of id
. Where do I put the method and how do I call it?
The easiest way will be for you to override _eval_context
or _eval_context_for_combinations
in ir.rule
itself.
class MyIrRule(models.Model):
_inherit ="ir.rule"
@api.model
def _eval_context(self):
context = super(MyIrRule,self)._eval_context()
context.update(function_of_ids=function_of_ids)
In this example, function_of_ids
is not a method but a simple function.