Skip to Content
Menu
This question has been flagged
1 Reply
9251 Views

Hi

I need to create a button in each tree view line like this https://i.imgur.com/3QSZKJB.png?1 with a drop down list of actions to perform like this https://i.imgur.com/DxW3N1Y.png. Is this possible, and if so how?

I already created a the button in eah line:

<button class="btn btn-secondary dropdown-toggle" type="button"/>

But the code in Bootstrap:https://getbootstrap.com/docs/4.0/components/dropdowns/#examples

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropdown button
  </button>
  <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
    <a class="dropdown-item" href="#">Action</a>
    <a class="dropdown-item" href="#">Another action</a>
    <a class="dropdown-item" href="#">Something else here</a>
  </div>
</div>

doens't work in odoo12

Thanks a lot!

Avatar
Discard
Best Answer

In xml
<record id="action_cancel_request" model="ir.actions.server">            |
    <field name="name">Cancel</field>            
    <field name="type">ir.actions.server</field>            |
    <field name="model_id" ref="sale.model_sale_order" />            
    <field name="state">code</field>            
    <field name="binding_model_id" ref="sale.model_sale_order" />            
    <field name="code">action = self.action_cancel(cr, uid, context.get('active_ids', []),context=context</field>        
</record>

<record id="cancel_action_menu" model="ir.values">            
    <field eval="'client_action_multi'" name="key2"/>            
    <field eval="'sale.order'" name="model"/>            |
    <field name="name">Cancel</field>
     <field eval="'ir.actions.server,%d'%action_cancel_request" name="value"/>
 </record>
In python,

@api.multidef action_cancel(self):    
if self.env.context.get('active_ids', False):        
    sale_order_ids = self.browse(self.env.context.get('active_ids'))        
        for sale_order in sale_order_ids:            
            sale_order.update({'state': 'cancel'})​

Upvote my answer if I help you! Thanks!

Avatar
Discard
Author

I did it like you said but it doesn't work.

I already added a button in each line in the external.id = pl.process_tree, now i need to have a drop-down list of actions (Copy, Share, Print, Delete..) when pressed that button

Author

Jeremy Gillbert , i've been able to create a dropdown button in the form view, but in tree view it doens't work, i can't have <div> tags.

Do you know why and hoe to do it?

Related Posts Replies Views Activity
1
Jan 19
3547
2
Oct 20
3060
0
Aug 19
3188
3
Jan 24
9861
2
Jul 23
784