【问题标题】:Open a xml after clicking button in odoo 10在odoo 10中单击按钮后打开一个xml
【发布时间】:2022-03-12 18:14:40
【问题描述】:

我们如何在 odoo 10 中打开一个新的 xml 表单?我想登录系统后打开views/views.xml

我的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" type="password"/>
                    <button string="Log In" type="object" name="Log_In"/>
                </group>
            </form>
        </field>
    </record>

python 中的函数“Log_In()”:

但它不起作用:它不仅不改变页面,而且还在数据库中插入一行studentmanagement.sinhvien!所以我不明白发生了什么!

【问题讨论】:

    标签: python odoo odoo-10


    【解决方案1】:

    你需要把你要返回的字典的view_id改成你视图的id,即your_module_name.LogIn_form_view

    【讨论】:

    • 它的意思是 'view_id' : 'studentmanagement.view.xml' 吗?我希望它在单击按钮后显示“view.xml”
    • 没有。 view_id 不是 xml 文件。 xml 文件可以包含多个视图。 id 是你的记录标签的 id 属性。
    【解决方案2】:

    我猜,你需要用@api.model装饰你的方法
    然后在您返回dict 值时,您需要将view_id 更改为类似view_id:self.env.ref("module_name.XML_ID").id

    XML_ID 是在 xml 中定义的 id
    例如:
    <record id="view_login_form" model="ir.ui.view"> <field name=""></field> </record>
    所以,XML_ID 必须是view_login_form

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-10
      相关资源
      最近更新 更多