Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Kov
    • Nábytek
    • Jídlo
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • IT hardware a podpora
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

Odoo V8 problem: Custom Module inheriting account.invoice still loads standard invoice template - what am I doing wrong?

Odebírat

Get notified when there's activity on this post

This question has been flagged
v8modulesinheritancereportingaccount.invoice
3 Odpovědi
7946 Zobrazení
Avatar
NSC

My issue, see above... I created a custom module while studying some information about that in the web. But yet without any real success... I can install my module without any error messages and the appropriate menu entry appears in account.invoice view, but when pressing it, the old standard template is shown and not my own report template which is inside my external module. Can you tell me why not? I think, I did not do anything other than in former times for OpenERP v7, only considering API and report engine changes of Odoo v8.

What I have not yet understood, is how new report engine has to find my .xml report template (which replaces old .rml one). One of the blog entries I read about that claims, this template needs to be in folder "views" inside my module folder (not any more in folder "reports" like before with RML reporting) and that it is found there via its template_id. I did so - I put it there, but obviously, it is NOT found this way. But no example in the web regarding that issue uses an entire path to this report template like before with rml! Can anybody explain me how I have to "explain" the module where my own report template is located?

I used these tutorials as a base (sorry, I did not manage to insert them as links - this did not work; dunno why not):

http://www.zbeanztech.com/blog/qweb-report

http://blog.emiprotechnologies.com/create-qweb-report-odoo/


Here are some code sequences (please tell me where they are erroneous or incompatible with Odoo V8):

Report Parser and simple minimal report template to get started:

# -*- coding: utf-8 -*-
##############################################################################
# Modification of standard invoice template
##############################################################################

import time
from openerp.report import report_sxw
from openerp.osv import osv

class my_account_invoice(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(fq_account_invoice, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
})

#remove previous sale.report service :
#from netsvc import Service
#del Service._services['account.report_invoice']

class myreportinvoice(osv.AbstractModel): #individual name, but extending osv.AbstractModel
_name = 'report.account.report_invoice' #_name = ‘report.<module_name>.<report_name>’
_inherit = 'report.abstract_report'
_template='account.report_invoice' #_template = ‘<module_name>.<report_name>’
_wrapped_report_class=my_account_invoice #_wrapped_report_class = <parser_class_name>

<template id="report_invoice">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="report.external_layout">
<div class="page">
<h2>New Invoice Template</h2>
<p>This object's name is <span t-field="o.name"/></p>
</div>
</t>
</t>
</t>
</template>

Menu Entry:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
id="my_account_invoices"
model="account.invoice"
string="My New Invoice"
report_type="qweb-pdf"
name="account.report_invoice"
file="account.report_invoice"
attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
attachment_use="False"
/>
</data>
</openerp>

If I replace the original ID 'report_invoice' to an own, individual one, for example 'report_my_invoice', I get the following error:
QWebTemplateNotFound: External ID not found in the system: account.report_my_invoice

But in settings --> reports, it looks like my new report is registered in a right way: The old original one has its own views, and my new one, too. Looks good, so far, but nevertheless, I can not print it because of this error. If it is registered with this ID in settings --> reports, why this error? Any idea ???



2
Avatar
Zrušit
Avatar
David Bertha
Nejlepší odpověď

The module name should be your module name, not the name of the inherited module.

What's in your __openerp__.py file ?

I made a custom report for invoice too :

report_group_invoice.xml :

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_group_invoice_document">
...
</template>
<template id="report_group_invoice">
<t t-call="report.html_container">
<t t-foreach="doc_ids" t-as="doc_id">
<t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'delivery_carrier_pickingup.report_group_invoice_document')"/>
</t>
</t>
</template>
</data>
</openerp>


report.xml :


<report 
id="delivery_grouped_invoice"
model="account.invoice"
string="Grouped invoice"
report_type="qweb-pdf"
name="delivery_carrier_pickingup.report_group_invoice"
file="delivery_carrier_pickingup.report_group_invoice"
attachment_use="True"
attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
/>

Those 2 files are in the "data" list of my openerp.py file

If you want to add arguments to the qweb engine :


class GroupedInvoiceReport(models.AbstractModel):
_name = 'report.delivery_carrier_pickingup.report_group_invoice'
def render_html(self, cr, uid, ids, data=None, context=None):
"""Add period start and period end from context to args of report template"""
if context is None :
    context= {}
report_obj = self.pool['report']
report = report_obj._get_report_from_name(cr, uid, 'delivery_carrier_pickingup.report_group_invoice')
docargs = {
'doc_ids': ids,
'doc_model': report.model,
'docs': self.pool.get('account.invoice').browse(cr,uid, ids,context=context),
}
docargs.update(<arguments>)
return report_obj.render(cr, uid, ids, 'delivery_carrier_pickingup.report_group_invoice', docargs, context=context)

My answer to NSC :
A report entry (with the <report/> tag) define a report, not a menu entry : https://www.odoo.com/documentation/8.0/reference/reports.html


1
Avatar
Zrušit
NSC
Autor

Okay then, maybe pointing out this misunderstanding of mine has already cleared up my mind for that - if report-tag is not only for menu entry but all the report definition, then model-tag inside seems to be underlying data source for it...

Avatar
NSC
Autor Nejlepší odpověď

This is an answer of @David Bertha's post - I can do what I want; it will not appear under the post it refers to :(:

Thank you for this, David! I think, you have just acknowledged what I found out later in the night! When refering to my own module overall and not any more to account, I was able to load my minimal template to get started when pressing the menu item! The only location left where I referenced account model is model field in menu entry (report.xml in your example). But this is only for the menu to know where to appear, isn't it?

What I am still wondering about is, how the module can know which data models it can access... I have not yet accessed any field for account.invoice in my getting-started-minimal-template (it is still nothing else than a skeleton), but I will try later on, if I can access any field.

In every case, if the "original" id/model should not be referenced, this does not definitely seem to be a "real" inheritance mechanism, but full autonomism of custom report module. The only question left for me would then be the one mentioned above - how to specify which data models the module may access. Could you, @David Bertha (or anybody else) clear up my mind regarding that?


//Edit:

Problem solved by only referencing to own module name and not the one of the model I wish to use data from in my report

1
Avatar
Zrušit
Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Model inheriance, how to override a default model in a module?
modules inheritance account.invoice model
Avatar
0
led 21
3515
How to get rid of the product name in account.invoice.line.name?
v8 modules invoice account.invoice account.invoice.line
Avatar
1
dub 16
6527
how to overide abstract model method Vyřešeno
inheritance reporting
Avatar
1
pro 22
2868
Inherit without changing original module
modules inheritance
Avatar
Avatar
Avatar
5
říj 20
8154
Invoice report is displaying an incorrect value Vyřešeno
v8 reporting
Avatar
Avatar
Avatar
4
říj 16
7345
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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