← Back to team overview

credativ team mailing list archive

Re: [Question #184864]: Using OpenERP domain operators

 

Question #184864 on OpenERP Server changed:
https://answers.launchpad.net/openobject-server/+question/184864

    Status: Open => Answered

Olivier Dony (OpenERP) proposed the following answer:
Hi Cuong,

The domain you are passing to search() is not valid, and the assert fails because of that. You need to remember that OpenERP domains uses prefix operators, so the operator must be *before* its operands.
As OR (|) is a binary operator (it takes 2 operands), it should always be used in this form:  ['|', A, B]. Here you seem to be using it also as infix operator between the operands:   ['|', A, '|', B, '|', C]. which will *not* work.

Here are 2 proper way to OR 3 operands:
   1. [ '|', '|', A, B, C ]  <==  ((A OR B) OR C)
   2. [ '|', A, '|', B, C ]  <==  (A OR (B OR C))

Taking the first way, you code should be:
  ids = self.search(cr, uid, ['|', '|', ('from_pty_id', 'in', (1, 2)), ('to_pty_id', 'in', (3, 4)), ('pty_rel_tye_id', 'in', (5, 6))],
                                limit=limit, context=context)

Hope this helps

-- 
You received this question notification because you are a member of
OpenERP Framework Experts, which is an answer contact for OpenERP
Server.