Skip to Content
Menu
This question has been flagged
8 Replies
4971 Views

I have a piece of code like below

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="report_invoice_document">
<t t-call="web.external_layout">
<t t-set="o" t-value="o.with_context(lang=lang)" />
<t t-set="address">
<address t-field="o.partner_id" t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' />
<div t-if="o.partner_id.vat" class="mt16"><t t-esc="o.company_id.country_id.vat_label or 'Tax ID'"/>: <span t-field="o.partner_id.vat"/></div>
</t>
<div class="page">
<div id="informations" class="row mt32 mb32">
<div class="col-auto mw-100 mb-2" t-if="o.name" name="description">
<strong>Description:</strong>
<p class="m-0" t-field="o.name"/>
</div>
</div>
</div>
</t>
</template>
</data>
</odoo>

I want to inherit and replace the informations div so i inherit the code like below using xpath

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<template id="report_invoice_document_inherit" inherit_id="account.report_invoice_document">
<xpath expr="//div[@id='informations']" position="replace">
<div id="informations" class="row mt32 mb32">
<div class="col-auto mw-100 mb-2" t-if="o.date_invoice" name="invoice_date">
<strong>Invoice Date:</strong>
<p class="m-0" t-field="o.date_invoice"/>
</div>
</div>
</xpath>
</template>
</data>
</odoo>

The problem is, the above code and the xpath works fine when i test it in my local machine but it throws me an error as below when i deploy it to a server

Element '<xpath expr="//div[@id='informations']">' cannot be located in parent view

I have checked community code in server and everything seems to be fine. I want to know is there anything wrong in my code? or is it related to the xpath? What seems to cause the issue? Any help?

Avatar
Discard

Also make sure that the corresponding div you have used in the xpath is not replaced or removed from the inheriting in any other custom module in the server.

Author

will make sure, thank you!

Best Answer

Hi Sameer,

Make sure the account module has same structure as per your xpath in your server.

This is a common reason that something works on our local system but not on the server because server might have older version of odoo and we use latest version in our local system.

Just double check the report file of account module with your local system and with the server.

Avatar
Discard
Author

Hi Sudhir,

The first thing i checked for is the thing you mentioned and the account module is same in my local machine and in the server. It makes sense cause we use our own tfs server so no chance of difference will arise and when i checked the files are same. So now i don't know what's causing the issue. Have you ever faced something like this?

Double check with the inherited views. There might be the case that any module would be replacing that div you are using in xpath.

Author

Yes Sudhir. Got an idea now as to why the issue occured. Thanks for your input.

Best Answer

You may have different settings or options set in your production server which leads to such a situation.

Check your parent view under "Settings/Technical/User Interface/Views".

Avatar
Discard
Author

Hi Ermin,

Thanks for your input. I'll look into it and update.

Author

I don't know how or why but the odoo community file code and the code in odoo UI was different, when i copy and pasted the community code into the UI as well the problem got solved. The question now is how did the code get changed in the odoo UI?

Best Answer

Hello, I also faced the same issue... There is a module named sale_layout in odoo 12 community version.. which inherits "report_invoice_document".. you need to inherit the id of that template & then replace the field with your xpath... hope it works for you...

Avatar
Discard
Author

Hi Nikhil,

I don't have sale related modules installed but anyway let me check and update you. Btw the issue is resolved when I replaced the code in report_invoice_document in odoo ui to the code which is in report_invoice file. As Ermin said it. The issue is cleared but I'm waiting for someone to explain me why did it occur in the first place. As Niyas said and as per your answer I think I got an idea why it occurred. Let me cross check and update you soon though. Thanks for the input.

Related Posts Replies Views Activity
4
Dec 23
16612
2
May 24
901
1
Feb 24
530
1
Feb 24
449
4
Sep 20
4831