2015-09-23 8:26 GMT+02:00 Cédric Krier <[email protected]>: > 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.
Yes, I check it this morning. http://hg.tryton.org/trytond/file/9640b76e4a3e/trytond/ir/rule.py#l144 Finally I change ir.rule to: <field name="domain" eval="[('shop', 'in', Eval('user', {}).get('shops', []))]" pyson="1"/> Thanks
