[FIX] sale: normalize domain is smart

When manipulating domain, this is always better to
normalize them, otherwise we can have strange behavior
when handleing them with `expression.OR` and
`expression.AND`.

For instance:
domain = [('so_line', 'in', [91]), ('amount', '<=', 0.0)]
timesheet_domain = ['&', ('so_line', 'in', []), ('project_id', '!=', False)]

`expresion.OR(domain, timesheet_domain)` will give
['|', ('so_line', 'in', [91]), ('amount', '<=', 0.0), '&', ('so_line', 'in', []),
('project_id', '!=', False)]

And this is not what we attempt.

Closes #24038
This commit is contained in:
jem-odoo
2018-05-08 11:17:54 +02:00
parent a0f8a06079
commit aee95705d2
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -1183,7 +1183,7 @@ class SaleOrderLine(models.Model):
on SO lines. This method is a hook: since analytic line are used for timesheet,
expense, ... each use case should provide its part of the domain.
"""
return [('so_line', 'in', self.ids), ('amount', '<=', 0.0)]
return ['&', ('so_line', 'in', self.ids), ('amount', '<=', 0.0)]
@api.multi
def _analytic_compute_delivered_quantity(self):
@@ -175,6 +175,7 @@ class SaleOrderLine(models.Model):
@api.multi
def _analytic_compute_delivered_quantity_domain(self):
domain = super(SaleOrderLine, self)._analytic_compute_delivered_quantity_domain()
domain = expression.AND([domain, [('project_id', '=', False)]])
timesheet_domain = self._timesheet_compute_delivered_quantity_domain()
return expression.OR([domain, timesheet_domain])