创建模型继承res.users的用户

时间:2015-04-09 16:39:21

标签: odoo odoo-8

我想创建一个模型" my_model.user"继承" res.users",但我有问题,我不明白!

from openerp import models, fields, api

class User(models.Model):
    _name = 'my_model.user'
    _inherit = 'res.users'

    name = fields.Char(string="Name", required=True)
    user_first_name = fields.Char(string="First name", required=True)
    user_flight_hours = fields.Integer(string="Flight hours", default=0)
    #code...

这是我的错误消息:

Integrity Error

The operation cannot be completed, probably due to the following:
- deletion: you may be trying to delete a record while other records still    reference it
- creation/update: a mandatory field is not correctly set

[object with reference: Users - res.users]

你能帮帮我吗?

1 个答案:

答案 0 :(得分:3)

我找到了解决方案!

from openerp import models, fields, api

class User(models.Model):
_name = 'test_impot.user'
_inherit = 'res.users'

name = fields.Char(string="Name", required=True)

#other fields...

#this is the solution
@api.model
def create(self, values):
    return super(User, self).create(values)