2017-02-16 7 views
0

odoo 10.0によって「サインアップ/ログインフォーム」を作成します。「Log_In()はOdoo 10.0で3つの引数(2が指定されています)」を受け取ります

私のコードの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() 

がLogIn_SignUp.xml:

<record model="ir.ui.view" id="LogIn_form_view"> 
     <field name="name">Logging</field> 
     <field name="model">studentmanagement.sinhvien</field> 
     <field name="type">form</field> 
     <field name="arch" type="xml"> 
      <form string="Logging"> 
       <group> 
        <field name="LienLac"/> 
        <field name="MatKhau"/> 
        <button string="Log In" type="object" name="Log_In"/> 
       </group> 
      </form> 
     </field> 
    </record> 

    <record model="ir.actions.act_window" id="LogIn_form_action"> 
     <field name="name">Log In</field> 
     <field name="res_model">studentmanagement.sinhvien</field> 
     <field name="view_type">form</field> 
     <field name='view_id' ref='LogIn_form_view'/> 
    </record> 

    <menuitem id="main_menu_entrance" name="entrance"/> 
    <menuitem id="Log In" name="Log In" parent="main_menu_entrance" action="LogIn_form_action"/> 

フォーム:enter image description here そして、これは誤りです:enter image description here

は、私は多くのことを検索しましたが、誰も持っていません同じ状況。私はそのようなエラーを正確に理解することはできませんし、それを解決する方法。

答えて

1

それは確かに伝えるのは難しいですが、スタックトレースに基づいて、あなたはLog_Inが1つだけ**kwargsを受け入れる持っている必要があります:

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

または可能性だけ:

def Log_In(self, args): 
    Account = args.get('Account') 
    Password = args.get('Password') 
    if Account is not None & Password is not None: 
    ... 
+0

問題は、 'Account name = "LienLac" /> 2つのテキストフィールドによって参照される2つの引数が –

+0

であるとわからない場合、 Odooのドキュメントには、https://github.com/odoo/odoo/blob/fc2e80cb4bcc450762c7ac5cb82a3e2d88062b38/addons/point_of_sale/wizard/pos_details.xmlとhttps://github.com/odoo/odoo/blob/dae737eca119227cdc4f341c0766cab9caec48bb/の例があります。 addons/point_of_sale/wizard/pos_details.py。呼び出しは 'self'を引数として' @ api.multi'を使用するように見えます。アカウントとパスワードのフィールドにはすでに値が入力されている可能性があります(LienLacとMatkhauですか)。 – Scovetta

+0

はい、それはあなたのサポートを受けて –

0

私が持っています私のコードを修正し、それは私のために働く:

+0

あなたは[Odoo Guidelines](https://www.odoo.com/documentation/10.0/reference/guidelines.html)と[PEP8](https:// www .python.org/dev/peps/pep-0008 /)の後にコードをリファクタリングします。 – CZoellner

関連する問題