3
votes

In Odoo 9 community version, I added the following monetary field as a monetary amount via the web interface: res.partner.x_tablet_bail_amount.

It's working fine, but when installing any new module I get the following error and my module does not install. Any help? thanks!

Odoo Server Error
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 605, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 642, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 316, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 309, in checked_call
    result = self.endpoint(*a, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 893, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 471, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 998, in call_button
    action = self._call_kw(model, method, args, {})
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 986, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 238, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 459, in button_immediate_install
    return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 238, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 533, in _button_immediate_function
    registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 385, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 283, in load_modules
    registry.setup_models(cr, partial=True)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 199, in setup_models
    model._setup_fields(cr, SUPERUSER_ID)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 238, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 342, in old_api
    result = method(recs, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 3044, in _setup_fields
    field.setup_full(self)
  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 476, in setup_full
    self._setup_regular_full(model)
  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 1131, in _setup_regular_full
    "Field %s with unknown currency_field %r" % (self, self.currency_field)
AssertionError: Field res.partner.x_tablet_bail_amount with unknown currency_field 'currency_id'
2

2 Answers

1
votes

Fields of type monetary are using other fields to do some stuff like printing currency symbols in reports or the client. Per default currency_id is used (Odoo Code) for that process, and as far as i know there is no currency_id defined on res.partner.

So maybe you should define it or get it as related field from another relation?

0
votes

From the source code it does not seem to be any currency_id field defined on res.partner.

However the field is indeed defined on res.company, which has a Many2One relationship with res.partner. I suppose res.partner is nothing but a kind of partially abstract class that needs to be extended for every type of partner within Odoo, including companies (only guessing here).

So Odoo is right when it spits

Field res.partner.x_tablet_bail_amount with unknown currency_field 'currency_id'

because the field is not there, really.

What you could do is, instead of defining your custom field x_tablet_bail_amount on res.partner, define it on res.company. That way your monetary field will be able to resolve the right currency instead of looking for something that does not exist.