diff options
Diffstat (limited to 'odoo/fields.py')
| -rw-r--r-- | odoo/fields.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/odoo/fields.py b/odoo/fields.py index 324450bf80e..99d2ac9c8e4 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -2049,20 +2049,21 @@ class Binary(Field): cache.update(records, self, [cache_value] * len(records)) # retrieve the attachments that store the values, and adapt them - if self.store: + if self.store and any(records._ids): + real_records = records.filtered('id') atts = records.env['ir.attachment'].sudo() if not_null: atts = atts.search([ ('res_model', '=', self.model_name), ('res_field', '=', self.name), - ('res_id', 'in', records.ids), + ('res_id', 'in', real_records.ids), ]) if value: # update the existing attachments atts.write({'datas': value}) atts_records = records.browse(atts.mapped('res_id')) # create the missing attachments - missing = (records - atts_records).filtered('id') + missing = (real_records - atts_records) if missing: atts.create([{ 'name': self.name, |
