zoukankan      html  css  js  c++  java
  • odoo 通过button跳转到tree视图,并传递domain

    跳转到视图的按钮类型,目前我知道的有两种,一种是object,即通过定义相应的方法来返回相关的视图,另一种是action,可以直接跳转到对应的视图

    举例如下:

                        <button name="button_get_product_quantity" type="object" string="查询可用量"/>
                        <!--button_get_product_quantity 是一个定义的方法-->
                        <field name="id" invisible="1"/>
                        <button name="%(sale_order_line_part_action_tree)d" type="action" string="配件信息" context="{'default_order_line_id':id}"/>
                        <!--sale_order_line_part_action_tree 是一个窗口动作-->
    

    第一种传递domain比较简单,可以直接在函数返回的动作视图中添加domain,domain 的数据可以直接在函数中获取,此处不再赘述
    第二种传递domain需要借助context实现:

    1. 在原视图中的button设置context,本例中设置的上下文:context="{'default_order_line_id':id}"
    2. 在动作视图中将context 的值取出,context.get('default_order_line_id', True),并定义到domain字段中:
    <record id="sale_order_line_part_action_tree" model="ir.actions.act_window">
        <field name="name">sale.order.line.part.action</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">sale.order.line.part</field>
        <field name="view_mode">tree,form</field>
        <field name="view_type">form</field>
        <field name="domain">[('order_line_id','=',context.get('default_order_line_id', True))]</field>
        <field name="help" type="html">
        <field name="target">new</field>
            <p class="oe_view_nocontent_create">
                <!-- Add Text Here -->
            </p><p>
                <!-- More details about what a user can do with this object will be OK -->
            </p>
        </field>
    </record>
    
  • 相关阅读:
    python
    mysql 操作
    you-get 使用代理
    恢复本地策略组--用于启动项管理等
    bat批处理——获取文件夹下所有文件名/重命名
    cmd--set用法,下次补充实例
    bat+7z批量压缩"文件夹"
    Excel提取字符串示例
    cron
    AIX修改用户密码登录不成功案例分享
  • 原文地址:https://www.cnblogs.com/qianxunman/p/12389946.html
Copyright © 2011-2022 走看看