diff options
| author | Raphael Collet <rco@odoo.com> | 2017-08-31 14:46:34 +0200 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2017-10-10 11:21:15 +0200 |
| commit | fcf6ef476ced0953e6faf88b7bbf9881923de4d5 (patch) | |
| tree | 5189578e40b6d1ae92063907b519767ce2cdb1b1 /odoo/fields.py | |
| parent | 5a1e5aa4294cbb375e86636e69963286b56215a5 (diff) | |
[FIX] fields: writing on a one2many with a domain should not remove all lines
Specifically, the command `(6, 0, ids)` should only unlink/detach the lines
that satisfy to the field's domain.
Test from #18440
opw-756983
Diffstat (limited to 'odoo/fields.py')
| -rw-r--r-- | odoo/fields.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/odoo/fields.py b/odoo/fields.py index 60aefa9bc25..50209746c10 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -2205,14 +2205,13 @@ class One2many(_RelationalMulti): elif act[0] == 6: record = records[-1] comodel.browse(act[2]).write({inverse: record.id}) - query = "SELECT id FROM %s WHERE %s=%%s AND id <> ALL(%%s)" % (comodel._table, inverse) - comodel._cr.execute(query, (record.id, act[2] or [0])) - lines = comodel.browse([row[0] for row in comodel._cr.fetchall()]) + domain = self.domain(records) if callable(self.domain) else self.domain + domain = domain + [(inverse, 'in', records.ids), ('id', 'not in', act[2] or [0])] inverse_field = comodel._fields[inverse] if inverse_field.ondelete == 'cascade': - lines.unlink() + comodel.search(domain).unlink() else: - lines.write({inverse: False}) + comodel.search(domain).write({inverse: False}) class Many2many(_RelationalMulti): |
