python - 覆盖 Odoo 中的创建函数

标签 python python-2.7 odoo openerp-7

我正在尝试覆盖“hr.employee”对象中的“创建”按钮。但是我收到了错误

Type Error:must be type , not str

我的代码块如下所示

from openerp import models, fields,api

class hrEmployee(models.Model):

    _inherit = "hr.employee"   

    def create(self, cr, uid, ids, context):
    #Todo code
        super('hr.employee', self).create(cr, uid, ids, context=context)   
      # return True

我不知道这里出了什么问题。 望指教

最佳答案

from openerp import models, fields,api
class hrEmployee(models.Model):
   _inherit = "hr.employee"

   @api.model
   def create(self, values):
       res_id = super(hrEmployee, self).create(values)
       return res_id

关于python - 覆盖 Odoo 中的创建函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31749586/

相关文章:

PYTHONPATH sys.path 差异

python - Django 会在用户登录时刷新 request.session 对象吗?

python - 在 subprocess.check_output() 中抑制 stderr

postgresql - 如何在 Odoo 8 中创建 One2one 关系?

python - 错误: dictionary update sequence element #0 has length 3; 2 is required

python - 只读字段没有保存在openerp的数据库中?

python - Pandas 从每行列表中减去相同的数字

python - 使用 scikit learn 在逻辑回归中所有系数都变为零

python - 我写了两个单独的文件,一个包含类,另一个调用它们,但调用一个是所有对象。为什么?

python-2.7 - 对包含字符串和数字的数据帧索引进行排序