Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
3 Răspunsuri
13432 Vizualizări

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?  

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Cel mai bun răspuns

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

Hope it helps,

thanks

Imagine profil
Abandonează
Autor Cel mai bun răspuns

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:



Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
apr. 25
1201
1
mai 23
3293
2
iun. 24
3590
0
mai 22
2494
2
mar. 22
3753