Contributors mailing list archives

Re: Needs a tuto on V9 and Qweb

ThinkOpen Solutions Portugal, Daniel Reis
- 28/07/2016 18:02:35
I think you're missing a leading underscore in the method name used in the QWeb.


No dia 28/07/2016, às 18:08, Michael Delvoye <> escreveu:

Hi Daniel
thanks for your help
When i see your answer i believed it was the solution but 
I have the same error :-( 

QWebException: "'account.invoice' object has no attribute 'get_message'" while evaluating

2016-07-27 0:08 GMT+02:00 Daniel Reis <>:

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>


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

Daniel Reis

Citando Michael Delvoye <>:

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 = V9
Module's name = custom_report
Parser Class = report/
Template = views/report_invoice.xml
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import time
from import report_sxw
from openerp import api, models
class invoice_parser(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(invoice_parser, self).__init__(cr, uid, name, context=context)
            'time': time,                      
            'get_message': self._get_message,
        self.context = context
    def _get_message(self):
        #code = self.pool.get('ir.sequence').next_by_code(, 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_parser
<?xml version="1.0" encoding="utf-8"?>
       <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;}
           <div class="row">
               <div class="col-xs-6">
                <div style="font-size: 20px;"><span>A l'attention de  : </span> <span t-field=""/></div>
                <div><span>document d'origine  : </span> <span t-field="o.origin"/></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><span>du : </span> <span t-field="o.date_invoice"/></div>
                <div style="font-size: 20px;"><strong><span t-field=""/></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=""/> <span t-field=""/></div>
                <div><span t-field=""/></div>
  <div><span t-esc="get_message()"/></div>
    <table class="table1">
                       <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>
               <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=""/></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>
          </div> <!-- Fin page -->
Michael Delvoye
Directeur Technique

Post to:


Post to:

Michael Delvoye
Directeur Technique