El 21/11/14 a les 18:29, Jordi Esteve (Zikzakmedia) ha escrit:
How can I define a domain that evaluates a reference field?
For example, if you want to create an action keyword to open the stock
moves related to a shipment out, the action window could be:
<record model="ir.action.act_window" id="act_moves_of_shipment">
<field name="name">Moves</field>
<field name="res_model">stock.move</field>
<field name="domain">[('shipment', '=',
Eval('active_id'))]</field>
</record>
but this does not work because the shipment field in stock moves is a
reference field, so they values are like 'shipment.out,3'. PYSON does
not have any string concatenation operator to join 'shipment.out' with
the Eval('active_id').
Maybe there is other way to solve this issue.
The correct domain is:
[('shipment.id', 'in', Eval('active_ids'), Eval('active_model')]
This works because when you use a domain that joins a reference field,
you must specify the target model where to join, and that's what
Eval('active_model') do in your case.
P.S: Note I changed active_id to active_ids (and '=' to 'in'), as if
you're using it from a relate action, its better to use always
active_ids as it allows to select more than one record from the client.
Hope it helps!
--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk