按钮传递上下文:

                <xpath expr="//div[@name='dec_work_sheet_id']" position="after">
                    <div class="col-lg-5 oe_button_box" name="button_box" style="width: 400px;">
                        <button name="%(cus_center_jiali_ext.copy_customs_declaration_action)d" type="action"
                                class="oe_stat_button" icon="fa-align-justify"
                                context="{'context_name': name, 'domain_dec_team_id': dec_team_id}"
                                style="width: 120px !important;margin: 0px 2px -1px 0px;" string="***单复制">
                        </button>
                    </div>
                </xpath>

odoo开发笔记 -- 传递上下文实现列表视图按照指定条件过滤显示_知识

视图中加domain获取上下文,添加过滤条件:

        <record id="copy_customs_declaration_action" model="ir.actions.act_window">
            <field name="name">***单复制</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">cus_center_new.customs_dec</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[('dec_team_id', '=', domain_dec_team_id)]</field>
        </record>

 

odoo开发笔记 -- 传递上下文实现列表视图按照指定条件过滤显示_知识_02