diff options
| author | Xavier Morel <xmo@odoo.com> | 2020-07-17 08:38:21 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-07-20 11:42:58 +0000 |
| commit | b3761a8cba6f24bbcb4b35f14e076965d1210f69 (patch) | |
| tree | e610ddb26702da9f7d822e19ae2fabc02137c1f1 /odoo/addons/test_testing_utilities/models.py | |
| parent | 8f09ef294a6aa7a845114474658cf0b4f32c46e1 (diff) | |
[FIX] core: fix handling of removals in sub-o2m
Issue is specifically in the case of an onchange removing a record in
an o2m in an o2m (so a sub-o2m) if loading an *existing* record in the
SSF: since the server pretty much only returns a REMOVE_ALL followed
by the records to keep or create, conserving the removal information
requires diffing the value currently stored in the form and the result
fo the onchange.
Diff which was properly done for top-level o2ms, but not for the ones
below that (apparently forgot this bit when improving support for
nested o2ms earlier this year).
X-original-commit: 177d009541cca589c6ebb85fc051b893ec001536
Diffstat (limited to 'odoo/addons/test_testing_utilities/models.py')
| -rw-r--r-- | odoo/addons/test_testing_utilities/models.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/odoo/addons/test_testing_utilities/models.py b/odoo/addons/test_testing_utilities/models.py index cf2b4f0e8c6..8796526653a 100644 --- a/odoo/addons/test_testing_utilities/models.py +++ b/odoo/addons/test_testing_utilities/models.py @@ -280,12 +280,26 @@ class ReqBool(models.Model): f_bool = fields.Boolean(required=True) +class O2MChangesParent(models.Model): + _name = _description = 'o2m_changes_parent' + + name = fields.Char() + line_ids = fields.One2many('o2m_changes_children', 'parent_id') + + @api.onchange('name') + def _onchange_name(self): + for line in self.line_ids: + line.line_ids = [(2, l.id, False) for l in line.line_ids] + [ + (0, 0, {'v': 0, 'vv': 0}) + ] + class O2MChangesChildren(models.Model): _name = _description = 'o2m_changes_children' name = fields.Char() v = fields.Integer() line_ids = fields.One2many('o2m_changes_children.lines', 'parent_id') + parent_id = fields.Many2one('o2m_changes_parent') @api.onchange('v') def _onchange_v(self): |
