This question has been flagged

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',
        auto_join=True)
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. 


Avatar
Discard