跳至内容
菜单
此问题已终结
1 回复
8035 查看

hello everyone, i'm trying to create read only tree view, my custom tree view is inherited from 'res.bank'. we can remove create button from control panel view (search / filter ir.ui.view) by using 

 
....

but I can still click some record and then opening default form (i don't make any form, and i dont want to show it) and it can do CRUD thing.

形象
丢弃
最佳答案

Hi,
You have mentioned that you are creating a readonly tree view for res.bank by inheriting the existing tree view. The tree view only has the Create option(No button for Edit and in the action, there is no option for duplicate, but we can delete the records). Hope you have added code for removing the create button from the view(But it is not visible here).


Code to remove the create and delete options from the res.bank tree view:

<record id="res_bank_view_tree" model="ir.ui.view">


    <field name="name">res.bank.view.tree.inherit.custom_module</field>


    <field name="model">res.bank</field>


    <field name="inherit_id" ref="base.view_res_bank_tree"/>


    <field name="arch" type="xml">


        <xpath expr="//tree" position="attributes">


            <attribute name="create">0</attribute>


            <attribute name="delete">0</attribute>


        </xpath>


    </field>


</record>


As you have mentioned above, when you click on any record, the form will be opened. The form view is already defined(please check the base module) and added in the window action. So, you need to update the window action linked to the menuitem Contacts/Configuration/Banks:

<record id="base.action_res_bank_form" model="ir.actions.act_window">


    <field name="res_model">res.bank</field>


    <field name="view_mode">tree</field>


</record>


This will prevent opening the form view from the tree view.

Hope it helps

形象
丢弃
相关帖文 回复 查看 活动
2
3月 24
2108
3
7月 23
5264
2
10月 22
4392
3
3月 24
2143
2
6月 24
9990