Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Custom qweb report from sql view showing empty

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
qwebcustom
2 Răspunsuri
9701 Vizualizări
Imagine profil
Justice

Dear All,

Am trying to create a qweb report to basically print out a table of all Vehicle service logs using a custom sql view, but my report always shows blank besides the table headers. Am using odoo 10  CE.  not sure what am doing wrong and or help will be greatly appreciated

my fleet.rpt.py

from odoo import fields, models, tools, api
class FleetRptView(models.Model):
  _name = 'fleet.vehicle.report.view'
  _description = 'Custom fleet Report'
  _auto = False
  id = fields.Integer('Service')
  date = fields.Date('Date')
  vehicle = fields.Char('Vehicle Name')
  maintype = fields.Char('Service Description')
  servicetype = fields.Char('ServiceType')
  total = fields.Float('TotalAmt')
  unitprice = fields.Float('UnitPrice')
  odometer = fields.Integer('Odometer')
  service_id = fields.Integer('ServiceId')
  parent_id = fields.Integer('ParentId')
  actotal = fields.Integer('ActualTotal')
  vehicle_id = fields.Integer('VehicleId')
  purchaser_id = fields.Many2one('res.partner','Purchaser')
  vendor_id = fields.Many2one('res.partner','Vendor')
  @api.model_cr
  def init(self):
  tools.drop_view_if_exists(self.env.cr, self._table)
  self.env.cr.execute("""CREATE or REPLACE VIEW %s as ( 
  WITH cte_cost AS(
  SELECT p.id
  ,p.parent_id
  ,t.name as maintype
  ,t2.name as type
  ,p.cost_type
  ,p.amount
  ,c.date
  ,c.name as vehicle
  ,p.vehicle_id
  ,c.odometer_id
  FROM fleet_vehicle_cost c
  JOIN fleet_vehicle_cost p ON c.id=p.parent_id --parent join
  JOIN fleet_service_type t ON c.cost_subtype_id=t.id
  JOIN fleet_service_type t2 ON p.cost_subtype_id=t2.id
  )
  SELECT 
  c.id as id
  ,c.date 
  ,c.vehicle as vehicle
  ,c.maintype as maintype
  ,c.type as servicetype
  ,s.cost_amount as total
  ,c.amount as unitprice
  ,o.value as odometer
  ,s.id as service_id
  ,c.parent_id as parent_id
  ,SUM(c.amount) OVER (PARTITION BY c.parent_id) as actotal
  ,c.vehicle_id
  ,s.purchaser_id
  ,s.vendor_id
  FROM fleet_vehicle_log_services s
  JOIN cte_cost c ON s.cost_id=c.parent_id and cost_type='services'
  LEFT JOIN fleet_vehicle_odometer o ON c.odometer_id=o.id
  ORDER BY c.date desc, c.id,c.parent_id
  )""" % (self._table))


report xml: fleet_report.xml

<?xml version="1.0" encoding="utf-8"?>
<odoo>
  <report id="action_fleet_rpt_report"
  string="Custom Fleet Report"
  model="fleet.vehicle.report.view"
  report_type="qweb-html"
  name="fleet_rpt.rpt_template"
  />
  <template id="rpt_template">
  <t t-call="report.html_container">
  <t t-call="report.external_layout">
  <div class="page">
  <table class="table table-striped">
  <tr>
  <th>Date </th>
  <th>Vehicle </th>
  <th>Type of Service </th>
  <th>km Covered </th>
  <th>Problem/ Service details</th>
  <th>Unit Price</th>
  <th>Total</th>
  </tr>
  <t t-foreach="docs" t-as="o">
  <tr>
  <td>
  <span t-field="o.date" />
  </td>
  <td>
  <span t-field="o.vehicle"/>
  </td>
  <td>
  <span t-field="o.maintype"/>
  </td>
  <td>
  <span t-field="o.odometer"/>
  </td>
  <td>
  <span t-field="o.servicetype"/>
  </td>
  <td>
  <span t-field="o.unitprice"/>
  </td>
  </tr>
  </t>
  </table>
  </div>
  </t>
  </t>
  </template>
</odoo>
0
Imagine profil
Abandonează
Imagine profil
Justice
Autor Cel mai bun răspuns

Thanks Sehrish for the response.  Could you provide some more info on how i can do that please. I did follow a couple of tutorials but didn't manage to get it to work. Thanks

0
Imagine profil
Abandonează
Sehrish

check out below links

1- http://learnopenerp.blogspot.com/2016/11/how-to-create-qweb-reports-in-openerp.html

2- http://learnopenerp.blogspot.com/2016/09/how-to-create-custom-reports-in-odoo.html

Hope its help you.

Imagine profil
Sehrish
Cel mai bun răspuns

I think You are not rendering your data into template.

0
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Why openERP don't find my custom View ?
views qweb custom
Imagine profil
Imagine profil
Imagine profil
2
mar. 15
6933
odoo custom homepage issue redirection
qweb custom website
Imagine profil
0
mar. 15
4202
Odoo 18: Display image from char field containing url in qweb form
qweb
Imagine profil
Imagine profil
1
iul. 25
3129
PDF Export Option for QWeb Reports in odoo 17.0
qweb
Imagine profil
Imagine profil
1
mai 25
4107
QWeb: use t-if to check birthday date Rezolvat
qweb
Imagine profil
Imagine profil
1
apr. 25
3394
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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