From ce217acf186970f35c964083aeef8d3b42db5685 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Tue, 15 Mar 2016 10:40:38 +0100 Subject: [PATCH] [FIX] fields: *2many convert_to_cache for new records When interpreting commands, the initial value for new records is an empty list. This regression was introduced by 09397384795f440b5924d9b325988e9cc6eb4d09. Fixes #11239. --- openerp/fields.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openerp/fields.py b/openerp/fields.py index aac91b7a977..7056c732479 100644 --- a/openerp/fields.py +++ b/openerp/fields.py @@ -1744,7 +1744,8 @@ class _RelationalMulti(_Relational): elif isinstance(value, list): # value is a list of record ids or commands comodel = record.env[self.comodel_name] - ids = OrderedSet(record[self.name].ids) + # determine the value ids; by convention empty on new records + ids = OrderedSet(record[self.name].ids if record.id else ()) # modify ids with the commands for command in value: if isinstance(command, (tuple, list)):