Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
29088 Lượt xem

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>
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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>
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

example:

<tree string="Purchase Order Lines" string="Sale Order" create="false" editable="bottom">
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 5 23
2151
1
thg 4 23
3724
2
thg 5 25
31264
2
thg 9 22
5612
3
thg 9 19
11771