On 2015-09-23 01:09, Cédric Krier wrote:
> On 2015-09-23 00:51, Raimon Esteve wrote:
> > Hie,
> > 
> > I try to do an ir.rule with a domain to Eval context value.
> > 
> >         <record model="ir.rule" id="rule_sale1">
> >             <field name="domain"
> >                 eval="[('shop', '=', Eval('context', {}).get('shop', -1))]"
> >                 pyson="1"/>
> >             <field name="rule_group" ref="rule_group_sale"/>
> >         </record>
> > 
> > After update module, PYSON is converted to:
> > 
> > [["shop", "=", {"d": -1, "k": "shop", "__class__": "Get", "v": {"d":
> > {}, "__class__": "Eval", "v": "context"}}]]
> > 
> > When I try to acces sale doesn't get shop from the context.
> 
> Maybe it is not in the context.
> 
> > If I try with user, in this case work successfully.
> > 
> >             <field name="domain"
> >                 eval="[('shop', '=', Eval('user', {}).get('shop', -1))]"
> >                 pyson="1"/>
> > 
> > What are I missing? Is it possible ir.rule with context?
> 
> I don't know but I will never ever do such thing. You don't base
> security on contextual value that user can set.

Indeed the rules evaluate the expression with a limited context
(Rule._get_context) and the global context is not part of it because it
makes no sense as I previously explained.

-- 
Cédric Krier - B2CK SPRL
Email/Jabber: [email protected]
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Reply via email to