콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
8 답글
6142 화면

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?

아바타
취소

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.

작성자

will make sure, thank you!

베스트 답변

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.

아바타
취소
작성자

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.

작성자

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

베스트 답변

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".

아바타
취소
작성자

Hi Ermin,

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

작성자

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?

베스트 답변

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...

아바타
취소
작성자

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.

관련 게시물 답글 화면 활동
4
12월 23
18534
1
7월 25
2371
2
5월 24
3137
1
2월 24
1757
4
9월 20
6335