Odoo Help

0

TypeError: search() got multiple values for keyword argument 'context'

By
Apoorv Soral
on 12/14/16, 5:25 AM 595 views

sale_list = self.env['sale.order'].search('|',             

                                  ( ['&',('id','in',self.sale_id_all.ids),('partner_id','in',self.cust_id.ids)]  ),                                                         

                                   (  [('id','in',self.sale_id_all.ids)]  ),

                                   (  [('partner_id','in',self.cust_id.ids)]  ),

                                   (  [('state','in',al)]  )

)




Traceback (most recent call last):
  File "/home/pchouksey1/workspace/dexciss/core/openerp/http.py", line 543, in _handle_exception    return super(JsonRequest, self)._handle_exception(exception)  File "/home/pchouksey1/workspace/dexciss/core/openerp/http.py", line 580, in dispatch    result = self._call_function(**self.params)  File "/home/pchouksey1/workspace/dexciss/core/openerp/http.py", line 316, in _call_function    return checked_call(self.db, *args, **kwargs)  File "/home/pchouksey1/workspace/dexciss/core/openerp/service/model.py", line 118, in wrapper    return f(dbname, *args, **kwargs)  File "/home/pchouksey1/workspace/dexciss/core/openerp/http.py", line 313, in checked_call    return self.endpoint(*a, **kw)  File "/home/pchouksey1/workspace/dexciss/core/openerp/http.py", line 809, in __call__    return self.method(*args, **kw)  File "/home/pchouksey1/workspace/dexciss/core/openerp/http.py", line 409, in response_wrap    response = f(*args, **kw)  File "/home/pchouksey1/workspace/dexciss/core/addons/web/controllers/main.py", line 948, in call_button    action = self._call_kw(model, method, args, {})  File "/home/pchouksey1/workspace/dexciss/core/addons/web/controllers/main.py", line 936, in _call_kw    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)  File "/home/pchouksey1/workspace/dexciss/core/openerp/api.py", line 268, in wrapper    return old_api(self, *args, **kwargs)  File "/home/pchouksey1/workspace/dexciss/core/openerp/api.py", line 399, in old_api    result = method(recs, *args, **kwargs)  File "/home/pchouksey1/workspace/dexciss/repo/delivery_performance/wizard/delivery_performance.py", line 301, in out_picking    ([('state','in',al)])  File "/home/pchouksey1/workspace/dexciss/core/openerp/api.py", line 266, in wrapper    return new_api(self, *args, **kwargs)  File "/home/pchouksey1/workspace/dexciss/core/openerp/api.py", line 508, in new_api    result = method(self._model, cr, uid, *args, **old_kwargs)TypeError: search() got multiple values for keyword argument 'context'



how to set filter in multiple m2m field?

0
Apoorv Soral
On 12/15/16, 7:36 AM

This is m code -


I want to apply "and" on three(or more) statements together... Like sale_id_all and cust_id and saleperson_id,etc.


sale_list = self.env['sale.order'].search(['|','|','|', '&', ('id','in',self.sale_id_all.ids), ('partner_id','in',self.cust_id.ids),('user_id','in',self.sales_person_id.ids),                                                              ('id','in',self.sale_id_all.ids),('partner_id','in',self.cust_id.ids),('user_id','in',self.sales_person_id.ids)                                                             ])

0

Hello Apoorv,

sale_list = self.env['sale.order'].search( ['|', '&', ('id','in',self.sale_id_all.ids), ('partner_id','in',self.cust_id.ids), '&', '&', ('id','in',self.sale_id_all.ids), ('partner_id','in',self.cust_id.ids), ('state','in',al) ] )

I hope this can be helpful to you.


It sure was helpful. Let me make it more interesting for you -

I want to apply domain like this - ((if customer id exists, then search all records which matches customer id selected in m2m) or (search all customer id))

and

((if saleorder id exists, then search all records which matches saleorder id selected in m2m) or (search all saleorder id))

Apoorv Soral
on 12/15/16, 2:33 AM
0
Burhan Vakharia
On 12/14/16, 8:39 AM

Hello Apporv,

Actually the domain syntax is wrong in the above code, that is the reason why you are facing this error.

In domain, you need to pass list of tuples.

Example code,

self.env['res.partner'].search([('customer','=',True)])


By default the domain  adds a 'AND' condition by default. You can add an 'Or' condition as bellow,

self.env['res.partner'].search(['|',('customer','=',True),('email','!=',False)])


Hope this helps,

Thank You.


Hi Burhan,

thanks for help but

actually i want to set filter according to recrods

if we select only cust(m2m) so (saleorder and cust) is false or (saleorder) is false but (cust) True so filter all cust

and if we select saleorder and cust so filter and so those records.

it means.

i want to set multiple & and multiple |(or) in single search method

Is It possible so how?

Apoorv Soral
on 12/14/16, 9:44 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 12/14/16, 5:25 AM
Seen: 595 times
Last updated: 12/15/16, 7:36 AM