简体   繁体   中英

row of tree views odoo

I am trying to place invisible an entire row in the tree view when the record has an "x" status, the thing is that I can place it invisible by placing the {invisible} attribute in each field but this is not what I want because this allows me to select the record as in the following image:

enter image description here

and this is the code that I have in the tree view:

<record id="dues_control_tree" model="ir.ui.view">
        <field name="name">dues.control.tree</field>
        <field name="model">dues.control</field>
        <field name="arch" type="xml">
            <tree string="Listado De Pagos" decoration-info ="status==2" decoration-danger ="status==1">
              <field name="re_customer" attrs="{'invisible':[('status', '=', 2)]}" />
              <field name="n_invoice" attrs="{'invisible':[('status', '=', 2)]}" />
              <field name="amount_total" attrs="{'invisible':[('status', '=', 2)]}" />
              <field name="number_dues" attrs="{'invisible':[('status', '=', 2)]}" />
              <field name="amount_dues" attrs="{'invisible':[('status', '=', 2)]}" /> 
              <field name="pay_amount_dues" attrs="{'invisible':[('status', '=', 2)]}"/>
              <field name="status" attrs="{'invisible':[('status', '=', 2)]}"/>
            </tree>
        </field>
    </record>

the thing is that I want it not to be seen and the entire row can not be selected when you have the X status.

You have not to make all row invisible, use domain instead. This helps

<record model="ir.actions.act_window" id="your_action_id">
   <field name="name">dues.control.action</field>
   <field name="res_model">dues.control</field>
   <field name="view_mode">tree,form</field>
   <field name="domain">
         [('status', '!=', 2)]
   </field>
</record>

You are trying to implement record rule for this tree view. The best way to do this is to use ir.actions.server instead of ir.actions.window. (action which Triggers and shows this tree view when some one clicks on menu item) you can set a domain on that action server and restrict rows which you want to show. on code field of action servers you can mention a function to run and sets domain on showing rows when a client clicks on related menu item. set domain on that function to not show records which has status = X. This is a solution sample I'm sure this will solve your problem , do your best and be lucky.

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