تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
10070 أدوات العرض

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!

الصورة الرمزية
إهمال
أفضل إجابة

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!

الصورة الرمزية
إهمال
الكاتب

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

الكاتب

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?

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يناير 19
4042
2
أكتوبر 20
3738
0
أغسطس 19
3780
3
يناير 24
10551
2
يوليو 23
784