Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

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

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
v8modulesinheritancereportingaccount.invoice
3 Replies
7940 Tampilan
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
Buang
Avatar
David Bertha
Jawaban Terbai

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
Buang
NSC
Penulis

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
Penulis Jawaban Terbai

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
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
Model inheriance, how to override a default model in a module?
modules inheritance account.invoice model
Avatar
0
Jan 21
3510
How to get rid of the product name in account.invoice.line.name?
v8 modules invoice account.invoice account.invoice.line
Avatar
1
Apr 16
6525
how to overide abstract model method Diselesaikan
inheritance reporting
Avatar
1
Des 22
2866
Inherit without changing original module
modules inheritance
Avatar
Avatar
Avatar
5
Okt 20
8154
Invoice report is displaying an incorrect value Diselesaikan
v8 reporting
Avatar
Avatar
Avatar
4
Okt 16
7339
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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