Re: [tryton-dev] Defining a domain that evaluates a reference field
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=nameMoves/field field name=res_modelstock.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
Re: [tryton-dev] Defining a domain that evaluates a reference field
On 21 Nov 18:29, Jordi Esteve (Zikzakmedia) wrote: 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=nameMoves/field field name=res_modelstock.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. You can use a tuple: ('model', id) -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck.com Tel: +32 472 54 46 59 Website: http://www.b2ck.com/ pgpquiABa6KQn.pgp Description: PGP signature
Re: [tryton-dev] Defining a domain that evaluates a reference field
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=nameMoves/field field name=res_modelstock.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
Re: [tryton-dev] Defining a domain that evaluates a reference field
El 21/11/14 a les 21:10, Jordi Esteve (Zikzakmedia) ha escrit: 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=nameMoves/field field name=res_modelstock.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 Which is correct when joining on a reference field: http://hg.tryton.org/trytond/file/441615f9b5d7/trytond/model/fields/reference.py#l117 -- Sergi Almacellas Abellana www.koolpi.com Twitter: @pokoli_srk
Re: [tryton-dev] Defining a domain that evaluates a reference field
On 21 Nov 21:10, Jordi Esteve (Zikzakmedia) wrote: Thanks for the help, I never have guested that using a a tuple ('model', id) was the solution to search in a reference field. But it is documented: http://doc.tryton.org/3.4/trytond/doc/ref/models/fields.html?highlight=reference#trytond.model.fields.Reference -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck.com Tel: +32 472 54 46 59 Website: http://www.b2ck.com/ pgpT2Dav_lxQO.pgp Description: PGP signature