Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Delegation inheritance from res.users model

Eduardo BP
on 5/30/15, 1:48 PM 877 views

Hi Odoo developers.

I have created a new model Comercial which inherits from res.users model using delegation inheritance.

class Comercial(models.Model):
_name = 'crm.comercial'
_inherits = {'res.users': 'usuario_id'}

num_ventas = fields.Integer()
usuario_id = fields.Many2one('res.users', required=True, ondelete='restrict',
name = fields.Char(related='usuario_id.name', inherited=True)
email = fields.Char(related='usuario_id.email', inherited=True)

I haven't defined a form view for Comercial model, so when I create a new Comercial in a form, it shows all fields from res.users model and res.partner model. It shows the fields from res.partner model because res.users inherits from res.partner using delegation inheritance too.

class res_users(osv.osv):
_inherits = {
'res.partner': 'partner_id',
'partner_id': fields.many2one('res.partner', required=True,
string='Related Partner', ondelete='restrict',
help='Partner-related data of the user', auto_join=True),

When I create a new Comercial in the form and click on the Save button, I get this error:

File "/opt/odoo/odoo_server/openerp/sql_db.py", line 234, in execute
res = self._obj.execute(query, params)
ProgrammingError: invalid reference to FROM-clause entry for table "res_users"
LINE 2: ...ario_id" = "crm_comercial__usuario_id"."id") AND ("res_users...
HINT: Perhaps you meant to reference the table alias "crm_comercial__usuario_id".

Thank you. 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)


Asked: 5/30/15, 1:48 PM
Seen: 877 times
Last updated: 5/30/15, 1:48 PM