在Odoo 10.0中,“Log_In()接受3个参数(给定2个)”

2024-10-02 22:27:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用odoo10.0创建一个“注册/登录表单”。在

我的代码python:

class SinhVien(models.Model):   
     _name = "studentmanagement.sinhvien"

     Ten = fields.Char()
     GioiTinh = fields.Char()
     NgaySinh = fields.Char()
     LienLac = fields.Char()
     MatKhau = fields.Char()
     DiaChi = fields.Char()
     DangKyHocPhan = fields.Many2many('studentmanagement.khoahoc', 'Dang_Ky_Hoc_Phan', 'studentmanagement.sinhvien_id', 'studentmanagement.khoahoc_id', string ="dang ky hoc phan")
     _sql_constraints = [ ('LienLac', 'unique(LienLac)', 'Two student with the same user!') ]

     def Log_In(self, Account, Password):
         if Account is not None & Password is not None:
            test_prod_ids = self.search([('LienLac','=',Account),   ('MatKhau','=',Password)], limit=1, context=None)
            return {
              'name': ('My Profile'),
              'view_type': 'form',
              'view_mode': 'form',
              'res_model': 'studentmanagement.sinhvien',
              'view_id': False,
              'type': 'ir.actions.act_window',
            }
        else :
            return None
 class KhoaHoc(models.Model):
       _name = "studentmanagement.khoahoc"

       MonHoc = fields.Char()
       TinChi = fields.Integer()
       PhongHoc = fields.Char()
       GiaoVien = fields.Char()

登录_注册.xml公司名称:

^{pr2}$

形式:enter image description here 这是错误:enter image description here

我找了很多,但没有人有同样的情况。我不明白这样的错误,以及如何解决它。在


Tags: namenoneviewidfieldsmodelmodelsaccount
2条回答

我已经更正了我的代码,它对我有效:

def Log_In(self, args):
    Account = args.get('LienLac')
    Password = args.get('MatKhau')
    if Account is not None and Password is not None:
         test_prod_ids = self.search([('LienLac','=',Account),('MatKhau','=',Password)], limit=1, context=None)
         if test_prod_ids:
            return {
               'name': ('My Profile'),
               'view_type': 'form',
               'view_mode': 'form',
               'res_model': 'studentmanagement.sinhvien',
               'view_id': False,
               'type': 'ir.actions.act_window',
             }
       else:
          return None
    else :
         return None

很难确定,但是根据堆栈跟踪,您可能需要Log_In只接受一个{a1}:

def Log_In(self, **kwargs):
    Account = kwargs.get('Account')
    Password = kwargs.get('Password')
    if Account is not None & Password is not None:
    ...

或者可能只是:

^{pr2}$

相关问题 更多 >