跳至内容
菜单
此问题已终结
1 回复
996 查看

I added tree view to report pos order : and I need to show button in the top of the tree
I added button when selection but i need it always appears without select
the code of add button:

<?xml version="1.0" encoding="utf-8"?>
<templates id="template">
    <t t-inherit="web.ListView.selection" t-inherit-mode="extension">
        <xpath expr="//div [@class='o_list_selection_box alert alert-info d-inline-flex align-items-center pl-0 px-lg-2 py-0 mb-0 ml-2']"
               position="inside">
            <button type="button" title="Create ODC Template"
                    class="btn btn-secondary fa fa-file-excel-o o_button_odc_template"/>
        </xpath>
    </t>

</templates>

the code to add tree:
<record id="point_of_sale.action_report_pos_order_all" model="ir.actions.act_window">
    <field name="name">Orders Analysis</field>
    <field name="res_model">report.pos.order</field>
    <field name="view_mode">tree,graph,pivot</field>
    <field name="search_view_id" ref="point_of_sale.view_report_pos_order_search"/>
    <field name="context">{'group_by_no_leaf':1,'group_by':[]}</field>
    <field name="help" type="html">
        <p class="o_view_nocontent_smiling_face">
            No data yet!
        </p>
        <p>
            Create a new POS order
        </p>
    </field>
</record>

and i did the same thing in sale.report view and i need to show the button in the top of this view without selection odoo15


               

               


               

           

       

形象
丢弃
最佳答案

Hi,

We can add a button near the create button in the list view by adding js class to the corresponding tree view.


<?xml version="1.0" encoding="UTF-8"?>
<odoo>
   <data>
<record id="sale_order_inherited_tree_view" model="ir.ui.view">
<field name="name">sale.order.view.tree.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_quotation_tree"/>
           <field name="arch" type="xml">
               <xpath expr="//tree" position="attributes">
<attribute name="js_class">button_in_tree</attribute>
               </xpath>
           </field>
       </record>
   </data>
</odoo>


Replace the model and inherit id by your model. then add js function


For more details refer the blog:

https://www.cybrosys.com/blog/how-to-add-a-create-button-near-tree-kanban-view-in-odoo-15" target="_blank" data-saferedirecturl="https://www.cybrosys.com/blog/how-to-add-a-create-button-near-tree-kanban-view-in-odoo-15

" rel="ugc">https://www.google.com/url?q=https://www.cybrosys.com/blog/how-to-add-a-create-button-near-tree-kanban-view-in-odoo-15&source=gmail&ust=1709800290750000&usg=AOvVaw2DhQWGW0DkbzayW8Joh2fR">https://www.cybrosys.com/blog/how-to-add-a-create-button-near-tree-kanban-view-in-odoo-15


Hope it helps,


形象
丢弃