Skip to Content
Menu
This question has been flagged
3 Replies
13251 Views

When you install Apps by selecting multiple, an INSTALL button shows at the top of the List View:



This provides quick access to the INSTALL option, which is also found in the ACTION Menu.


In CRM, I would like to make several of the options available in the ACTION Menu into buttons at the top of that List View.

How can I do this?  

Avatar
Discard
Best Answer

Hi,

You can add buttons inside the tree view as follows,

<record id="module_tree" model="ir.ui.view">
<field name="name">ir.module.module.tree</field>
<field name="model">ir.module.module</field>
<field name="arch" type="xml">
<tree decoration-info="state=='to upgrade' or state=='to install'" decoration-danger="state=='uninstalled'" decoration-muted="state=='uninstallable'" create="false" string="Apps">
<header>
<button name="button_immediate_install" type="object" string="Install"/>
</header>

<field name="shortdesc"/>
<field name="name" groups="base.group_no_one"/>
<field name="author"/>
<field name="website"/>
<field name="installed_version"/>
<field name="state"/>
<field name="category_id" invisible="1"/>
</tree>
</field>
</record>

Inside the tree tag, you can define the buttons inside the header tag as we define in the form view. This option has been introduced in the odoo 14.


The above attached code sample is the tree view of the apps menu which you shown in the question. Lot of such sample can be seen inside odoo 14 source code.


General Syntax:

<record id="tree_name" model="ir.ui.view">
<field name="name">model_name.tree</field>
<field name="model">model_name</field>
<field name="arch" type="xml">
<tree>
<header>
<button name="button_name" type="object" string="Label"/>
</header>

<field name="field_1"/>
<field name="field_2"/>
</tree>
</field>
</record>

Thanks

Avatar
Discard
Best Answer

Hi, you can follow this: https://youtu.be/mcDKP-4-4-E

Hope it helps,

thanks

Avatar
Discard
Author Best Answer

One way is to write Server Actions that execute the Python Method in the class (model).

The "delete" action is a generic method to all models and you can make a Server Action like this:


This will have an ID that you will see in the URL when you are looking at it, or via the View Metadata option from the Debug Menu when in Developer Mode:


This ID field is used to create the button for the top of the List View:



When these two things are done, the List now looks like this:



You can review the code to find the methods for the other Actions you want to add, or search the Actions Menu to find some of the common ones:



This was ID 111 so you can also add it like this:

<tree position="inside">
  <header>
    <button name="84" string="Delete" type="action"/>
    <button name="111" string="Email" type="action"/>
  </header>  
</tree>


The List will then look like this:



Avatar
Discard
Related Posts Replies Views Activity
0
Apr 25
1158
1
May 23
3240
2
Jun 24
3514
0
May 22
2361
2
Mar 22
3625