aligot
aligot

Reputation: 259

Openerp says an existing model does not exist in a many2many relation

I'm trying to establish a many2many relation between my model and account.tax.

I'm using the following column definition:

'tax_id': fields.many2many('account.tax', 'account_contract_line_tax', 'contract_line_id', 'tax_id', 'Taxes', domain=[('parent_id','=',False)]),

And I'm getting the following erorr:

2014-05-25 16:18:55,456 31937 ERROR ***_dev openerp.netsvc: Programming Error
Many2Many destination model does not exist: `account.tax`
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 292, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 622, in dispatch
    security.check(db,uid,passwd)
  File "/usr/lib/pymodules/python2.7/openerp/service/security.py", line 40, in check
    pool = pooler.get_pool(db)
  File "/usr/lib/pymodules/python2.7/openerp/pooler.py", line 49, in get_pool
    return get_db_and_pool(db_name, force_demo, status, update_module)[1]
  File "/usr/lib/pymodules/python2.7/openerp/pooler.py", line 33, in get_db_and_pool
    registry = RegistryManager.get(db_name, force_demo, status, update_module)
  File "/usr/lib/pymodules/python2.7/openerp/modules/registry.py", line 203, in get
    update_module)
  File "/usr/lib/pymodules/python2.7/openerp/modules/registry.py", line 233, in new
    openerp.modules.load_modules(registry.db, force_demo, status, update_module)
  File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 350, in load_modules
    force, status, report, loaded_modules, update_module)
  File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 256, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 165, in load_module_graph
    init_module_models(cr, package.name, models)
  File "/usr/lib/pymodules/python2.7/openerp/modules/module.py", line 374, in init_module_models
    result = obj._auto_init(cr, {'module': module_name})
  File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 3028, in _auto_init
    self._m2m_raise_or_create_relation(cr, f)
  File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 3338, in _m2m_raise_or_create_relation
    raise except_orm('Programming Error', 'Many2Many destination model does not exist: `%s`' % (f._obj,))
except_orm: ('Programming Error', 'Many2Many destination model does not exist: `account.tax`')

Of course, account.tax is existing since I'm using the ERP to established invoice with account module. Furthermore, I can see the model in configuration/database structure/model

I nearly copied the line from account module...

Any ideas ?

A.

Upvotes: 0

Views: 4193

Answers (1)

aligot
aligot

Reputation: 259

Ok...

It seems the reason was the lack of explicit dependency in

__openerp__.py

After adding "account" to dependencies list, it started working...

Best regards,

A.

Upvotes: 2

Related Questions