odooodoo-17

remove purchase order PurchaseDashBoard in odoo17


how can i remove purchase order PurchaseDashBoard

in odoo 17

<templates>
    <t t-name="purchase.PurchaseKanbanView" t-inherit="web.KanbanRenderer" t-inherit-mode="primary">
        <xpath expr="//div[hasclass('o_kanban_renderer')]" position="before">
            <PurchaseDashBoard />
        </xpath>
    </t>
</templates>
<templates>
    <t t-name="purchase.PurchaseListView" t-inherit="web.ListRenderer" t-inherit-mode="primary">
        <xpath expr="//div[hasclass('o_list_renderer')]" position="before">
            <PurchaseDashBoard />
        </xpath>
    </t>
</templates>

odoo purchase order


Solution

  • You could simple hide it with css...

    .o_purchase_dashboard{
        display: none !important;    
    }
    

    to only hide it on specific views...

    .o_list_view .o_purchase_dashboard, .o_kanban_view .o_purchase_dashboard{
    display: none !important; 
    }
    

    Finally you must include your css file in the __manifest__.py

    "assets": {
            "web.assets_backend":[
                "path_to_your_file/purchase_dashboard.css",
    
            ]
    }
    

    Also you could archive the same result using a more odoo like aproach by modifying de component using an xml file...

    <?xml version="1.0" encoding="UTF-8"?>
    <templates xml:space="preserve">
    
        <t t-name="my_module.PurchaseDashboard" t-inherit="purchase.PurchaseDashboard" t-inherit-mode="extension" owl="1">
            <xpath expr="//div[hasclass('o_purchase_dashboard')]" position="attributes">
                <attribute name="class" separator=" " add="d-none"></attribute>
                
            </xpath>
        </t>
          
    </templates>
    

    and if you want to remove the component completely from a view...

    <?xml version="1.0" encoding="UTF-8"?>
    <templates xml:space="preserve">   
          
          <t t-name="my_module.PurchaseListView" t-inherit="purchase.PurchaseListView" t-inherit-mode="extension" owl="1">
            <xpath expr="//PurchaseDashBoard" position="replace">
                
            </xpath>
        </t>
    </templates>
    

    Don't forget to include de xml file in the __manifest__.py

    "assets": {
            "web.assets_backend":[
                "path_to_your_file/purchase_dashboard.xml",
    
            ]
    }