summaryrefslogtreecommitdiff
path: root/odoo/fields.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-02-23 20:15:38 +0100
committerChristophe Simonis <chs@odoo.com>2017-02-23 20:15:38 +0100
commit85368d7f86a15567a2d0bc42aca15b8487bba0ed (patch)
treeaf3717280f256f2e025a696c42079790d87f864b /odoo/fields.py
parentf2f6aedf75eb3729592b2e5f6f8af6633bad3609 (diff)
parent387b2acfcbfd5d4525ef8453e0c1999753246576 (diff)
[MERGE] forward port branch 10.0 up to 387b2acfcbf
Diffstat (limited to 'odoo/fields.py')
-rw-r--r--odoo/fields.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/odoo/fields.py b/odoo/fields.py
index c2b89f1218c..539c5f4badf 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -1222,13 +1222,14 @@ class Monetary(Field):
_description_currency_field = property(attrgetter('currency_field'))
_description_group_operator = property(attrgetter('group_operator'))
- def _setup_regular_base(self, model):
- super(Monetary, self)._setup_regular_base(model)
- if not self.currency_field:
- self.currency_field = 'currency_id'
-
def _setup_regular_full(self, model):
super(Monetary, self)._setup_regular_full(model)
+ if not self.currency_field:
+ # pick a default, trying in order: 'currency_id', 'x_currency_id'
+ if 'currency_id' in model._fields:
+ self.currency_field = 'currency_id'
+ elif 'x_currency_id' in model._fields:
+ self.currency_field = 'x_currency_id'
assert self.currency_field in model._fields, \
"Field %s with unknown currency_field %r" % (self, self.currency_field)