El 21/11/14 a les 18:35, Sergi Almacellas Abellana ha escrit:
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 does not work because you give 4 parameters in a domain. The
solution that works is the one Cedric has given
use a tuple: ('model', id)
In my example would be
('shipment', '=', ('stock.shipment.out', Eval('active_id')))
but I have had to do a trick: Add an extra pair of parenthesis because I
want to search in subfield like
('move.shipment', '=', (('stock.shipment.out', Eval('active_id'))))
Also using 'active_model' or 'active_ids' instead of 'active_id' did not
work in this case.
Thanks for the help, I never have guested that using a a tuple ('model',
id) was the solution to search in a reference field.
--
Jordi Esteve
Consultor Zikzakmedia SL
jest...@zikzakmedia.com
Mòbil 679 170 693
Zikzakmedia SL
St. Jaume, 9, baixos, 2a
08720 Vilafranca del Penedès
Tel 93 890 2108