This question has been flagged
4 Replies
25105 Views

Hello, I have Odoo 9 CE.

I want to prevent opening elements when I click in an item of the tree view. I try to put editable="bottom" but not works, when I click on a order line element it opens all data of ther order line. I want to can't click on the element.

The purchase_order_form in where this tree view is contained is readonly, so i set create="false" edit="false" delete="false"


<tree string="Purchase Order Lines" editable="bottom">                                    
<field name="product_id" context="{'partner_id': parent.partner_id}"/>                                   
<field name="name"/>                                   
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>                                   
<field name="product_qty"/>                                   
<field name="qty_received" invisible="not context.get('show_purchase', False)"/>                                   
<field name="product_uom" groups="product.group_uom"/>                               
</tree>
Avatar
Discard
Best Answer

Dear Jose,

We can pass readonly="1" attribute in each field in the tree view. Like:

<tree string="Purchase Order Lines" editable="bottom">                                    
    <field name="product_id" context="{'partner_id': parent.partner_id}" readonly="1"/>                                   
    <field name="name" readonly="1"/>                                   
    <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}" readonly="1"/>                                   
    <field name="product_qty" readonly="1"/>                                   
    <field name="qty_received" invisible="not context.get('show_purchase', False)" readonly="1"/>                                   
    <field name="product_uom" groups="product.group_uom" readonly="1"/>                               
</tree>

----------------- OR ---------------

If we set mode=tree only in action, it will not allow users to click on the tree. Like:

<record id="action_invoice_lines_vendor" model="ir.actions.act_window">
        <field name="name">Vendor Invoice Lines</field>
        <field name="res_model">account.invoice.line</field>
        <field name="type">ir.actions.act_window</field>
        <field name="view_mode">tree</field>
        <field name="view_type">form</field>
        <field name="domain">[('invoice_id.type', '=', 'in_invoice')]</field>
</record>

Hope this will work for you.

Thank you.


Avatar
Discard
Best Answer

Hi Jose,

try bellow code:

after changes your code should look like this:

<tree string="Purchase Order Lines" string="Sale Order" create="false" edit="false" editable="bottom">
    <field name="product_id" context="{'partner_id': parent.partner_id}"/>     <field name="name"/>     <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>     <field name="product_qty"/>     <field name="qty_received" invisible="not context.get('show_purchase', False)"/>     <field name="product_uom" groups="product.group_uom"/> </tree>
Avatar
Discard
Best Answer

Hello Haresh,

your solution does not work for me. I specified edit="false" and editable="bottom", but when I click on an item in the tree view, still the form is opened for the specified item. How to deactivate this? I don't want the row to link anywhere, also, the cursor should not change, because there are other links inside every row.

Thanks!

Avatar
Discard
Best Answer

don't use edit="false" with editable="bottom"

example:

<tree string="Purchase Order Lines" string="Sale Order" create="false" editable="bottom">
Avatar
Discard