Search code examples
odoo

Odoo search domain condition1 and (condition2 or condition3)


I am trying to construct an Odoo domain query with a logic of (Condition 1) AND (Condition 2 OR Condition3)

This is the code I've written:

moves = self.env['account.move'].search(
     [(
     "&",
          ('sftp_uploaded', '=', False),
        "|",
          ('move_type', 'in', ['entry']),
          ('move_type', 'in', ['out_receipt']),
      )], limit=200)

Running this returns a strange error

ValueError: <class 'TypeError'>: "unhashable type: 'list'" while evaluating 'model._sftp_cron_action()'

In the same function the following code works fine

moves = self.env['account.move'].search(
    [(
        'move_type', 'in', ['out_invoice']),
        ('sftp_uploaded', '=', False
    )], limit=20)

Solution

  • You have one extra pair of parentheses.

    moves = self.env['account.move'].search(
         [
         "&",
              ('sftp_uploaded', '=', False),
            "|",
              ('move_type', 'in', ['entry']),
              ('move_type', 'in', ['out_receipt']),
          ], limit=200)