Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • e-learning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Cervecería
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y soporte técnico
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Explorar todos los sectores
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Servicios para partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Custom qweb report from sql view showing empty

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
qwebcustom
2 Respuestas
9678 Vistas
Avatar
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
Avatar
Descartar
Avatar
Justice
Autor Mejor respuesta

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

Avatar
Sehrish
Mejor respuesta

I think You are not rendering your data into template.

0
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
Why openERP don't find my custom View ?
views qweb custom
Avatar
Avatar
Avatar
2
mar 15
6932
odoo custom homepage issue redirection
qweb custom website
Avatar
0
mar 15
4195
Odoo 18: Display image from char field containing url in qweb form
qweb
Avatar
Avatar
1
jul 25
3118
PDF Export Option for QWeb Reports in odoo 17.0
qweb
Avatar
Avatar
1
may 25
4092
QWeb: use t-if to check birthday date Resuelto
qweb
Avatar
Avatar
1
abr 25
3388
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

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