Odoo: Make it impossible to edit a record in tree view?

邮差的信 提交于 2020-01-14 02:34:06

问题


In Odoo you can make it impossible to create or delete records from the tree view like this:

            <tree create="false" delete="false">
                <field name="create_date" readonly="True"/>
            </tree>

But I can still click the records and go to the form of that record. Is there a way to make it impossible to click those records and edit them?


回答1:


Found it already, need to use editable="false":

<tree create="false" delete="false" editable="false">

</tree>



回答2:


Hear it is possible to editable of your tree view to change the attribute of Tree tag

just do some things like this

Editable on Bottom :

<tree create="false" delete="false" editable="bottom">

</tree>

Editable on Top :

<tree create="false" delete="false" editable="top">

</tree>

I hope my answer may helpful for you :)




回答3:


A solution for the complete tree view (action) to be read-only is to not provide form in the view_mode attribute in addition to the create, edit (and delete) options:

<record id="hr_timesheet_line_tree" model="ir.ui.view">
    <field name="name">hr.analytic.timesheet.tree</field>
    <field name="model">hr.analytic.timesheet</field>
    <field name="arch" type="xml">
        <tree string="Timesheet Activities" create="false" edit="false" delete="false">                  
            <field name="date" on_change="on_change_date(date)"/>
            <field name="name"/>
     </tree>
    </field>
</record>

<record id="act_hr_timesheet_line_evry1_all_form" model="ir.actions.act_window">
    <field name="name">Timesheet Activities</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">hr.analytic.timesheet</field>
    <field name="view_type">form</field>
    <field name="view_mode">tree</field>
    <field name="help" type="html">
        <p class="oe_view_nocontent_create">
            Click to record activities.
        </p>
    </field>
</record>


来源:https://stackoverflow.com/questions/31611065/odoo-make-it-impossible-to-edit-a-record-in-tree-view

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!