Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
3 Replies
13535 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai

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

Hope it helps,

thanks

Avatar
Buang
Penulis Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
0
Apr 25
1236
1
Mei 23
3338
2
Jun 24
3623
0
Mei 22
2528
2
Mar 22
3768