-->

Override Create function in Odoo

2019-04-15 16:37发布

问题:

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)