diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-04-05 10:50:56 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-04-05 10:50:56 +0200 |
| commit | f2be461f0906ed47306da58c31240014b6239d80 (patch) | |
| tree | 6084c152dd56f691aa75c2e4580ffaf53b8257ba /odoo/addons/test_testing_utilities/models.py | |
| parent | f391b8c5a55bdc512d70cb8b3e61f23903abb5ed (diff) | |
| parent | f2d0995362ccdae88ba64597ea6f0feca3eab618 (diff) | |
[MERGE] forward port branch saas-12.1 up to f2d0995362c
Diffstat (limited to 'odoo/addons/test_testing_utilities/models.py')
| -rw-r--r-- | odoo/addons/test_testing_utilities/models.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/odoo/addons/test_testing_utilities/models.py b/odoo/addons/test_testing_utilities/models.py index fbdec47a7cf..0c04bc06e8d 100644 --- a/odoo/addons/test_testing_utilities/models.py +++ b/odoo/addons/test_testing_utilities/models.py @@ -188,6 +188,13 @@ class O2MSub3(models.Model): r.name = str(r.v) +class O2MRecursive(models.Model): + _name = _description = 'test_testing_utilities.recursive' + + one_to_many_id = fields.Many2one('test_testing_utilities.recursive', readonly=True) + many_to_one_ids = fields.One2many('test_testing_utilities.recursive', 'one_to_many_id', readonly=True) + + class O2MOnchangeParent(models.Model): _name = 'test_testing_utilities.onchange_parent' _description = 'Testing Utilities Onchange Parent' @@ -233,3 +240,24 @@ class O2MChangeSub(models.Model): parent = fields.Many2one('test_testing_utilities.onchange_count') name = fields.Char() + +class O2MReadonlySubfield(models.Model): + _name = 'o2m_readonly_subfield_parent' + _description = _name + + line_ids = fields.One2many('o2m_readonly_subfield_child', 'parent_id') + +class O2MReadonlySubfieldChild(models.Model): + _name = _description = 'o2m_readonly_subfield_child' + + name = fields.Char() + parent_id = fields.Many2one('o2m_readonly_subfield_parent') + f = fields.Integer(compute='_compute_f', inverse='_inverse_f', readonly=True) + + @api.depends('name') + def _compute_f(self): + for r in self: + r.f = len(r.name) if r.name else 0 + + def _inverse_f(self): + raise AssertionError("Inverse of f should not be called") |
