TypeError:import_users()只需要5个参数(给定2个)

时间:2017-05-26 10:55:41

标签: python openerp

当我尝试从生物识别考勤机导入用户时,我收到错误:

TypeError: import_users() takes exactly 5 arguments (2 given)

这是我的班级:

class BiometricUser(models.TransientModel):
    _name = 'biometric.user.wizard'

    biometric_device = fields.Many2one(
        'biometric.machine', 'Biometric device',
    )

    def import_users(self, cr, uid, ids, context):
        """
        wrapper function
        """
        for biometric_import_user in self.browse(cr, uid, ids, context):
            biometric_import_user.create_users_in_openerp()

    @api.model
    def create_users_in_openerp(self):
        self.biometric_device.create_user()

1 个答案:

答案 0 :(得分:1)

@ api.model 更改为 @ api.multi 并将(cr,uid,ids,context)更改为 self

尝试使用以下代码:

@api.multi
def import_users(self):
    """
    wrapper function
    """
    for biometric_import_user in self:
        biometric_import_user.create_users_in_openerp()

@api.multi
def create_users_in_openerp(self):
    self.biometric_device.create_user()