简体   繁体   中英

How to use Domain in tree view? Odoo 14

I want to add domain in tree view of bank statement to get only journal_id with type 'bank'. The problem when I added the domain,I got a wrong result. Here is my code:

<record model="ir.ui.view" id="action_bank_tree">
        <field name="name">account.bank.statement.tree</field>
        <field name="model">account.bank.statement</field>
        <field name="arch" type="xml">
            <tree decoration-danger="not is_difference_zero" decoration-info="state=='open' and is_difference_zero" string="Statements">
                <field name="name"/>
                <field name="date"/>
                <field name="journal_id" domain="[('type', '=' , 'bank')]" context="{'default_type':'bank'}"/>
                <field name="company_id" groups="base.group_multi_company"/>
                <field name="balance_start"/>
                <field name="balance_end_real"/>
                <field name="balance_end" invisible="1"/>
                <field name="currency_id" invisible="1"/>
                <field name="state"/>
                <field name="is_difference_zero" invisible="1"/>
            </tree>
        </field>
    </record>

      <record model="ir.actions.act_window" id="action_bank">
        <field name="type">ir.actions.act_window</field>
        <field name="name">bank</field>
        <field name="res_model">account.bank.statement</field>
        <field name="view_mode">tree,form</field>
    </record>

       <menuitem id="bank" name="bank"
          parent=""
          action="action_bank"
          sequence="1"/>

Any help please?

I have taken reference from sale order views: adding in action_bank act_window may work.

<record id="action_orders" model="ir.actions.act_window">
            <field name="name">Sales Orders</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">sale.order</field>
            <field name="view_mode">tree,form</field>
            <field name="search_view_id" ref="sale_order_view_search_inherit_sale"/>
            <field name="context">{}</field>
            <field name="domain">[('state', 'not in', ('draft', 'sent', 'cancel'))]</field>
        </record>

<record id="sale_order_action_view_order_tree" model="ir.actions.act_window.view">
            <field name="sequence" eval="1"/>
            <field name="view_mode">tree</field>
            <field name="view_id" ref="sale.view_order_tree"/>
            <field name="act_window_id" ref="action_orders"/>
        </record>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM