Dear Cedric & Sergi, Thanks for your responses.
On Tue, Jun 13, 2017 at 12:15 PM, Sergi Almacellas Abellana < [email protected]> wrote: > El 13/06/17 a les 07:24, Khurram Shahzad ha escrit: > >> Dear All, >> >> I have defined a domain for a filed as follows: >> >> blood_bags = fields.Many2Many('anth.request-bag', 'blood_request', >> 'blood_bag', 'Blood Bags', required=True, >> domain=[('state','=','cross_matched'), >> ('id', 'in', [1,2])]) >> >> Consider condition ('id', 'in', [1,2]) where I have hard-coded values 1 & >> 2. Is there a way that I can search a model and use the returned list here >> dynamically. >> > If the domain is applied on the field, you should use a One2Many function > field (which will do the compute and return the ids), and use the following > domain: > > [('state', '=', 'cross_matched'), ('id', 'in', Eval('your_function_field', > [])] > > Having said taht, I'm wondering why you want to use the ids, if you are > going to use a search clause on target model. You can use the '.' to > perform joins domain clauses. For example: Using 'direct_field.name' will > search on the name fields of the records related by the 'direct_field' > field. Of course, the direct field must be a relation one. > > Hope it helps. > These records have not been created using xml file. The method by Sergi didn't work as well. Infact, I want to search records on the basis of 'origin' model as well as 'target' model. Simply, I want to return those 'blood_bag' model objects whose 'state' is 'cross_matched' AND they have been cross-matched against 'blood_request'. The blood_request model is related to blood_bag. Regards, Khurram. -- You received this message because you are subscribed to the Google Groups "tryton" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton/CAM3N3Cze5ksE44-Uei3BhMuEd%3DuvAAgiqPtM%2BiVj7G0mVB-KdA%40mail.gmail.com.
