diff options
| author | Raphael Collet <rco@odoo.com> | 2020-09-16 14:09:19 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-09-17 15:11:18 +0000 |
| commit | 7325c3f8c538a8b8c0435963cdda3ced6fe4b324 (patch) | |
| tree | 8896f7083324cc56a2e81013dbda9f88f56e380c /odoo/fields.py | |
| parent | 77ec3b224f3fd6c8ad6dccbbf7612be8464a385d (diff) | |
[FIX] core: non-stored binary fields should have attachment=False
This prevents some code (in controllers) to retrieve an attachment for a
field that is not stored, as the code only relies on `field.attachment`.
This also makes the field definition more consistent.
closes odoo/odoo#57969
X-original-commit: 13397943d9e953815ae5ce9b01ce812a92903361
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/fields.py')
| -rw-r--r-- | odoo/fields.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/odoo/fields.py b/odoo/fields.py index f4e26e7b935..e6325fe59d5 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -1890,6 +1890,12 @@ class Binary(Field): def column_type(self): return None if self.attachment else ('bytea', 'bytea') + def _get_attrs(self, model, name): + attrs = super(Binary, self)._get_attrs(model, name) + if not attrs.get('store', True): + attrs['attachment'] = False + return attrs + _description_attachment = property(attrgetter('attachment')) def convert_to_column(self, value, record, values=None, validate=True): |
