2

「res.users」を継承したモデル「my_model.user」を作りたいのですが、問題があってよくわかりません!

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]

私たちを手伝ってくれますか ?

4

1 に答える 1

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)
于 2015-04-10T09:58:02.740 に答える