Override Create function in Odoo

南楼画角 提交于 2019-12-06 13:43:24

问题


I'm trying to override the 'create' button in 'hr.employee' object. But I'm getting the error

Type Error:must be type , not str

my chunck of code is shown below

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

I don't know what is getting wrong here. Hopes for suggestion


回答1:


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



回答2:


Try this:

return super(hrEmployee, self).create(cr, uid, ids, context)


来源:https://stackoverflow.com/questions/31749586/override-create-function-in-odoo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!