odoo/openerp/addons/test_new_api
Xavier ALT f02b23006b [FIX] fields: during an onchange(), do not invalidate *2many fields because of their domain
Our usage of domain on fields One2many seems to trigger an obscure behaviour on
onchange.

With the following (simplified) config:

    Message(models.Model):
        _name = 'test_new_api.message'
        important = fields.Boolean('Important')

    Discussion(models.Model):
        _name = 'test_new_api.discussion'
        name = fields.Char('Name')
        important_emails = fields.One2Many('test_new_api.emailmessage', 'discussion',
                                           domain=[('important', '=', True)])

    Email(models.Model):
        _name = 'test_new_api.emailmessage'
        _inherits = {'test_new_api.message': 'message'}

        discussion = fields.Many2one('test_new_api.discussion', 'Discussion')
        message = fields.Many2one('test_new_api.message', 'Message')

Steps:
- We change 'name' on discussion, triggers an `onchange()` call
- we ends up filling cache on virtual record (on secondary fields, we calling
  record.mapped('important_emails.important'))
- we get a cache miss ('important' field not provided, only 'important_emails' ids,
  i.e with no change on existing records)
- we fill the cache, this mark 'important' field as modified
- because of commit 5676d81 and because 'important' is that case is a related (i.e
  computed) field we triggers cache recomputation
- as there is no way to recompute 'important_emails' for virtual record (no real
  ID) we ends up with empty 'important_emails' generating removal of existing records.

=> Finally changing any value for 'test_new_api.discussion' that trigger an onchange
will always reset 'important_emails' to empty

Fixed by Raphael Collet <rco@odoo.com>, and test by Xavier Alt <xal@odoo.com>.
2016-06-17 17:50:25 +02:00
..
tests [FIX] fields: during an onchange(), do not invalidate *2many fields because of their domain 2016-06-17 17:50:25 +02:00
__init__.py [MERGE] new v8 api by rco 2014-07-06 17:05:41 +02:00
__openerp__.py [FIX] models: old api, prevent infinite recursion in stored function fields 2015-08-31 17:45:21 +02:00
demo_data.xml [FIX] osv: fix boolean in domain for custom field 2015-12-04 16:31:31 +01:00
ir.model.access.csv [FIX] fields: during an onchange(), do not invalidate *2many fields because of their domain 2016-06-17 17:50:25 +02:00
models.py [FIX] fields: during an onchange(), do not invalidate *2many fields because of their domain 2016-06-17 17:50:25 +02:00
views.xml [FIX] fields: during an onchange(), do not invalidate *2many fields because of their domain 2016-06-17 17:50:25 +02:00