Search code examples
pythonmoduleodoo

Can't see the changes I've made in my custom Odoo module


I've created a new custom module called 'custom_purchase_order_report'. I'm trying to change/add to the text being generated in the Purchase Order PDF report. I've inherited from the extension view called 'purchase_stock.report_purchaseorder_document' and have added a generic xpath searching for all strong fields and adding my own, just for exploratory purposes to see if my change is shown (it doesn't).

What are the steps to reproduce my issue?

Go to any purchase order, click on the cog wheel icon, then print -> Purchase order. I want the text in the PDF report to change or be added from Shipping Address to "Chen Address".

My manifest file:

{
    'name': "Custom Purchase Order Report",
    'summary': "Modify text in the Purchase Order PDF report",
    'version': '1.0',
    'category': 'Purchases',
    'author': "Chen Avnery",
    'license': 'AGPL-3',
    'depends': ['purchase', 'purchase_stock'],
    'data': [
        'views/report_purchase_order.xml',
    ],
    'installable': True,
}

My view file:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <template id="report_purchaseorder_document_custom_inherit" inherit_id="purchase_stock.report_purchaseorder_document">
            <xpath expr="//strong" position="after">
                <strong>Chen address:</strong>
            </xpath>
        </template>
    </data>
</odoo>

Solution

  • According to View resolution documentation:

    if the view has a parent, the parent is fully resolved then the current view’s inheritance specs are applied

    The xpath will be applied after resolving the parent view, so the text will be added after the first strong element located in the parent view, it will not be visible if the Dropship Address is not set

    To add it after the strong tag defined in purchase_stock module, target the t-else tag:

    expr='//t[@t-else=""]/t[@t-set="information_block"]/strong'