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