summaryrefslogtreecommitdiff
path: root/odoo/fields.py
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2020-06-16 13:44:32 +0000
committerXavier Morel <xmo@odoo.com>2020-06-17 07:23:28 +0000
commit1eadda159f6be8094f6aac3c95f21b81ff078177 (patch)
tree4f9d63e7936d0c6c41f54ab07f8efda4d28810e3 /odoo/fields.py
parentde131bb6ff75364743527410cb4f3dd481d9d408 (diff)
[FIX] core: make `state` special case overridable
`state` was special cased in `copy_data` such that it would always be reset to its default value if it had one. While this special case can be useful (maybe) and is certainly ingrained in odoo, having it not be overridable can be problematic. Move the special case to the fields, so it's possible to explicitly mark state fields as copy. closes odoo/odoo#53113 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Diffstat (limited to 'odoo/fields.py')
-rw-r--r--odoo/fields.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/odoo/fields.py b/odoo/fields.py
index c21d367c98a..854a2f831b2 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -307,6 +307,9 @@ class Field(MetaField('DummyField', (object,), {})):
attrs['_modules'] = modules
# initialize ``self`` with ``attrs``
+ if name == 'state':
+ # by default, `state` fields should be reset on copy
+ attrs['copy'] = attrs.get('copy', False)
if attrs.get('compute'):
# by default, computed fields are not stored, computed in superuser
# mode if stored, not copied (unless stored and explicitly not