Contributors mailing list archives
contributors@odoo-community.org
Browse archives
Re: Needs a tuto on V9 and Qweb
by
Karthik Arumugam
Hi
Your module name is custom_report
but here
_name = 'report.custom_reports.x_invoice_report'
_inherit = 'report.abstract_report'
_template = 'custom_reports.x_invoice_report'
_wrapped_report_class = invoice_parser
you have custom_reports please change that and check
Thanks
you have custom_reports please change that and check
Thanks
On Tuesday 26 July 2016 07:38 PM,
Michael Delvoye wrote:
<blockquote
cite="mid:CADMZLWf9L08rerXybq3M_5GtypOqcx-yHHJWD93KjK5jLY=pyA@mail.gmail.com"
type="cite">
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 = V9
Module's name = custom_report
--
Parser Class = report/ invoice_parser.py
Template = views/report_invoice.xml
Invoice_parser.py
------------------------
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and
licensing details.
import time
from openerp.report 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)
self.localcontext.update({
'time': time,
'get_message': self._get_message,
})
self.context = context
def _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_parser
report_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: 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>
</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
Delvoye
Directeur Technique
MISYL 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