Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Xpath works locally but won't work when deployed on server.

Subscribe

Get notified when there's activity on this post

This question has been flagged
inheritancedeploymentxpathodoov12
8 Replies
6744 Views
Avatar
Sameer Ahmad

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?

0
Avatar
Discard
Niyas Raphy (Walnut Software Solutions)

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.

Sameer Ahmad
Author

will make sure, thank you!

Avatar
Sudhir Arya (ERP Harbor Consulting Services)
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.

2
Avatar
Discard
Sameer Ahmad
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?

Sudhir Arya (ERP Harbor Consulting Services)

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

Sameer Ahmad
Author

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

Avatar
Ermin Trevisan
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".

1
Avatar
Discard
Sameer Ahmad
Author

Hi Ermin,

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

Sameer Ahmad
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?

Avatar
Nikhil Dhiman
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...

0
Avatar
Discard
Sameer Ahmad
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.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
How to modify xpath from other xpath? (inherit from inherited view) Solved
inheritance xpath
Avatar
Avatar
Avatar
4
Dec 23
19717
Problem with XPATH
inheritance xpath v15
Avatar
Avatar
1
Jul 25
3138
Extension View - Multiple xpath replacements Solved
views inheritance xpath
Avatar
Avatar
Avatar
2
May 24
4193
Vista no disponible fleet.vehicle.inspection.control_panel.custom definición en fleet_vehicle_inspection_ecom/views/fleet_vehicle_inspection_ecom.xml
inheritance xpath v15
Avatar
Avatar
1
Feb 24
2282
How to hide a button that is identified by its action id ?
views inheritance xpath
Avatar
Avatar
Avatar
4
Sep 20
7234
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now