Contributors mailing list archives
contributors@odoo-community.org
Browse archives
Re: Needs a tuto on V9 and Qweb
byFrom my point of view you should remove the leading underscore from your python code and in the qweb... at least for the get_message function
Hi Daniel,Same error :-(This is my parserimport timefrom openerp.report import report_sxwfrom openerp import api, modelsclass invoice_parser(report_sxw.rml_parse):def __init__(self, cr, uid, name, context):super(invoice_parser, self).__init__(cr, uid, name, context=context)self.localcontext.update({'time': time,'getmessage': self.__getmessage,})self.context = context@api.modeldef __getmessage(self):message = "Hello world"return messageclass report_invoice(models.AbstractModel):_name = 'report.custom_reports.x_invoice_report'_inherit = 'report.abstract_report'_template = 'custom_reports.x_invoice_report'_wrapped_report_class = invoice_parserQWebException: "'account.invoice' object has no attribute 'get_message'" while evaluating 'o.getmessage()'2016-07-28 20:08 GMT+02:00 Daniel Reis <dgreis@sapo.pt>:I think you're missing a leading underscore in the method name used in the QWeb.
--DanielHi Danielthanks for your helpWhen i see your answer i believed it was the solution butI have the same error :-(QWebException: "'account.invoice' object has no attribute 'get_message'" while evaluating 'o.get_message()'2016-07-27 0:08 GMT+02:00 Daniel Reis <dgreis@sapo.pt>:Hi Michael,
You might need to add @api.model to the "def _get_message(self)"
Since it is a object method, instead of
<div><span t-esc="get_message()"/></div>
try<div><span t-esc="o.get_message()"/></div>
Both the "Odoo Development Essentials" and the "Odoo Development Cookbook" cover QWeb and the other Odoo development topics.
You might find them useful.
Regards
Daniel Reis
Citando Michael Delvoye <mdelvoye@misyl-services.com>:
Hi,i'm new on OCA and i need help so as to understand qweb.I used to work with mako on V7 where i could write python function very simply.I search to do the same thing with qweb. I see in forum and other sites that it is possible but i don't succeed in implementing the method for my database test.If someone could give me some help, it would be great because i've turned around this problem since 2 weeks with no solution.when i 'll find the solution i'll give the code of my module on my github for people like me who wants to learn about qweb (TutoQweb light)This is my code :Odoo Version = V9Module's name = custom_reportParser Class = report/ invoice_parser.pyTemplate = views/report_invoice.xmlInvoice_parser.py------------------------# -*- coding: utf-8 -*-# Part of Odoo. See LICENSE file for full copyright and licensing details.import timefrom openerp.report import report_sxwfrom openerp import api, modelsclass invoice_parser(report_sxw.rml_parse):def __init__(self, cr, uid, name, context):super(invoice_parser, self).__init__(cr, uid, name, context=context)self.localcontext.update({'time': time,'get_message': self._get_message,})self.context = contextdef _get_message(self):#code = self.pool.get('ir.sequence').next_by_code(self.cr, self.uid, seq_code)message = "Hello world"return message
class report_invoice(models.AbstractModel):_name = 'report.custom_reports.x_invoice_report'_inherit = 'report.abstract_report'_template = 'custom_reports.x_invoice_report'_wrapped_report_class = invoice_parserreport_invoice.xml------------------------<?xml version="1.0" encoding="utf-8"?><openerp><data><template id="x_invoice_report" inherit_id="account.report_invoice_document"><xpath expr="//div[@class='page']" position="replace"><div class="page"><style type="text/css">h1 {font-size: 16; font-weight:bold;text-decoration:underline;}table#t01 {text-align: center;width: 75%; border-left: 1px solid black; border-right: 1px solid black;}.table1{border-collapse: collapse;width:100%;}.th1{padding:5px;vertical-align:top;border:1px solid black;text-align:center;}.td1{padding:5px;vertical-align:top;border-left:1px solid black;border-right:1px solid black;}.td2{padding:5px;vertical-align:top;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;}.td3{padding:5px;vertical-align:top;border:1px solid black;}.td4{padding:5px;vertical-align:top;border:none;}.mdel{color:purple;}</style><div class="row"><div class="col-xs-6"><div style="font-size: 20px;"><span>A l'attention de : </span> <span t-field="o.partner_id.name"/></div><div><span>document d'origine : </span> <span t-field="o.origin"/></div></div><div class="col-xs-6"><div style="font-size: 20px;"><span t-if="o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')">Facture N° </span><span t-if="o.type == 'out_invoice' and o.state == 'proforma2'">PRO-FORMA N°</span><span t-if="o.type == 'out_invoice' and o.state == 'draft'">Facture Brouillon</span><span t-if="o.type == 'out_invoice' and o.state == 'cancel'">Facture Annulée</span><span t-if="o.type == 'out_refund'">Avoir</span><span t-if="o.type == 'in_refund'">Remboursement N°</span><span t-if="o.type == 'in_invoice'">Facture N°</span><span t-field="o.number"/></div><div><span>du : </span> <span t-field="o.date_invoice"/></div><br/><div style="font-size: 20px;"><strong><span t-field="o.partner_id.parent_id.name"/></strong></div><div style="font-size: 18px;"><div><span t-field="o.partner_id.parent_id.street"/></div><div><span t-field="o.partner_id.parent_id.street2"/></div><div><span t-field="o.partner_id.parent_id.zip"/> <span t-field="o.partner_id.parent_id.city"/></div><div><span t-field="o.partner_id.parent_id.country_id.name"/></div></div></div></div><br/><div><span t-esc="get_message()"/></div><table class="table1"><thead><tr><th class="th1" style="width:100px;">Référence</th><th class="th1">Désignation</th><th class="th1" style="width:30px;">Qté</th><th class="th1" style="width:20px;">UV</th><th class="th1" style="width:70px;">P.U (€)</th><th class="th1" style="width:80px;">MT.HT (€)</th><th class="th1" style="width:30px;">TVA</th><!--<th t-if="display_discount" class="text-right" groups="sale.group_discount_per_so_line">Disc.(%)</th><th class="text-right">Taxes</th><th class="text-right">Price</th>--></tr></thead><tbody class="invoice_tbody"><tr t-foreach="o.invoice_line_ids" t-as="l"><td class="td1"><span t-field="l.product_id.name_template"/></td><td class="td1"><span t-field="l.name"/></td><td class="td1">xxx</td><td class="td1">xxx</td><td class="td1">xxx</td><td class="td1">xxx</td><td class="td1">xxx</td></tr></tbody></table></div> <!-- Fin page --></xpath></template>--Michael DelvoyeDirecteur TechniqueMISYL SERVICES_______________________________________________
Mailing-List: http://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: http://odoo-community.org/groups?unsubscribe
_______________________________________________
Mailing-List: http://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: http://odoo-community.org/groups?unsubscribe--Michael DelvoyeDirecteur TechniqueMISYL SERVICES_______________________________________________
Mailing-List: http://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: http://odoo-community.org/groups?unsubscribe_______________________________________________
Mailing-List: http://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: http://odoo-community.org/groups?unsubscribe--Michael DelvoyeDirecteur TechniqueMISYL SERVICES_______________________________________________
Mailing-List: http://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: http://odoo-community.org/groups?unsubscribe
Reference
-
Needs a tuto on V9 and Qweb
byMISYL SERVICES., Michael Delvoye-
Re: Needs a tuto on V9 and Qweb
byOpen Architects Consulting, Houssine BAKKALI -
Re: Needs a tuto on V9 and Qweb
byOpen Architects Consulting, Houssine BAKKALI -
Re: Needs a tuto on V9 and Qweb
byClosingAp Open Source Integrators Europe, LDA, Daniel Reis -
Re: Needs a tuto on V9 and Qweb
byClosingAp Open Source Integrators Europe, LDA, Daniel Reis