Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

ValueError. How to customize a Qweb report properly by replacing "div[@class='page']"?

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
qwebinheritreportodoo10
5 Replies
27678 Rodiniai
Portretas
Art

I'm trying to customize a report_invoice_document qweb report. Here is the source code:

<?xml version="1.0"?>
<t t-name="account.report_invoice_document">
<t t-call="report.external_layout">
<t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})"/>
<div class="page">
    <div class="row">
        <div name="invoice_address" class="col-xs-5 col-xs-offset-7">
            <address t-field="o.partner_id" t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: True}"/>
            <span t-if="o.partner_id.vat">TIN: <span t-field="o.partner_id.vat"/></span>
        </div>
    </div>
<h2>
    <span t-if="o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')">Invoice</span>
    <span t-if="o.type == 'out_invoice' and o.state == 'proforma2'">PRO-FORMA</span>
    <span t-if="o.type == 'out_invoice' and o.state == 'draft'">Draft Invoice</span>
    <span t-if="o.type == 'out_invoice' and o.state == 'cancel'">Cancelled Invoice</span>
    <span t-if="o.type == 'out_refund'">Refund</span>
    <span t-if="o.type == 'in_refund'">Vendor Refund</span>
    <span t-if="o.type == 'in_invoice'">Vendor Bill</span>
    <span t-field="o.number"/>
</h2>
...

So I'm trying to replace "div[@class='page']" and build my own report with the following code and expect to see just the "Invoice_test_2" in my report when I print it out:

<odoo>	
    <data>
        <template id="practichem_report_invoice_layout" inherit_id="account.report_invoice_document">
            <xpath expr="//div[@class='page']" position="replace">
                <div class="page">
                    <h2>Invoice_test_2</h2>
                </div>
            </xpath>
        </template>
    </data>
</odoo>

But I'm getting the following error:

ValueError: Can't validate view:
Element '<xpath expr="//div[@name='invoice_address']">' cannot be located in parent view

What am I doing wrong?


1
Portretas
Atmesti
Art
Autorius

However, I can replace the <h2> tag with the following code and it works:

<template id="practichem_report_invoice_layout" inherit_id="account.report_invoice_document">

<xpath expr="//div[@class='page']//h2" position="replace">

<h2>Customer Invoice Report</h2>

</xpath>

</template>

Portretas
Marius Stedjan
Best Answer

The reason for the error is that other templates ("report_invoice_document_inherit_sale", "account_invoice_report_duplicate", "report_invoice_document_inherit_sale" and "report_invoice_layouted") are already inheriting the account.report_invoice_document template.
When you inherit it yourself and remove the code that the inheriting templates are looking for, Odoo throws an error.. because it can't find the code.

The solution I found was to first make a new template inheriting "account.report_invoice" (this is the template calling the "account.report_invoice_document" on every document), and make this new template call my custom report_invoice_document template/report.

Something like this:

Inherit account.report_invoice to make it call my custom template/report:

<template id="report_invoice_inherit_mymodule" inherit_id="account.report_invoice">
<xpath expr="//t[@t-call='account.report_invoice_document']" position="replace">
            <t t-call="mymodule.report_invoice_document" t-lang="o.partner_id.lang"/>
</xpath>
</template>

Create new template for report_invoice_document

<template id="report_invoice_document">
<t t-call="report.external_layout">
<t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})" />
<div class="page">
My Custom Report Here...
</div>
</t>
</template>
3
Portretas
Atmesti
SonnyV

+1 for including a code-example of the suggested solution ;)

SHIV SHANKAR

Thanks for saving my day!! :)

Paolo M

Don't work on odoo 12, i have this error message:

Error to render compiling AST

AttributeError: 'dict' object has no attribute 'type'

Template: 1151

Path: /templates/t/t/t/t[1]

Node: <t t-set="lang" t-value="o.user_id.sudo().lang if o.type in ('in_invoice', 'in_refund')

Portretas
Art
Autorius Best Answer

So I added attribute primary=”True” inside the <template> tag and error was gone. But now no matter what I do with the report customization it doesn't affect anything and it prints out the original report.

So I still have a problem with the report inheritance.

1
Portretas
Atmesti
SonnyV

primary="True" Means your report does not inherit from any other report. So Xpath expressions are of no use here since you just told Odoo this report is a new one.

This could be good, but then you will need to update the action (clicking the print invoice button for example) to call your new report and not the original invoice-layout.

Portretas
SonnyV
Best Answer

Hello Art

The problem you are facing here is because you are replacing the entire page and another installed module inherits a part of this page you are replacing.

I checked the github odoo10 code and searched for <xpath expr="//div[@name='invoice_address']">
This made me notice the file addons/sale/report/invoice_report_templates.xml

In this file they inherit the report you are trying to inherit. When you update your module the invoice report gets reloaded and all it's 'children' as well. Since you remove everything from the report, Odoo is unable to validate the view in the sale addon above, since the xpath is looking for something inside the page and that is gone now, since the xml only consists of the page and the h2.

SO, you can test if I am right or not by adding a div with name invoice_address to your page, then install or update your module, this should solve your error, but you have an unwanted div in the report now.

What I would suggest is that you create a whole new report and an action, or find out how to make the existing action link to another xml file (your new xml file).

The problem with creating a whole new action would be that when you send the invoice by mail, the default layout would still be called and not your new one, so if you decide to go this road, bear in mind that there are references that should also be updated.


I hope I helped you or at least gave you a push in the right direction.

Sincerely

Sonny V.
ERP-consultant @ Cats and Dogs, BE


0
Portretas
Atmesti
Marius Stedjan

Wow.. we replied at exactly the same time :-D

Check my answer for a solution to the "new action" problem.

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

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

Registracija
Related Posts Replies Rodiniai Veikla
[V.10] How to add Google Font in report odoo
qweb report odoo10
Portretas
Portretas
1
lapkr. 17
6639
Change pdf file name in report definition Odoo 10 Solved
qweb report odoo10
Portretas
Portretas
Portretas
Portretas
4
spal. 17
27257
Inherit Qweb Solved
v8 qweb inherit report
Portretas
Portretas
Portretas
Portretas
4
vas. 24
49881
how to pass value of custom field to existing report and comput on it?
qweb inherit report v15
Portretas
0
geg. 22
4144
odoo10: How too call an attachment in an other qweb report ?
attachment qweb report odoo10
Portretas
Portretas
1
rugs. 19
4398
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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