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
    • eLearning
    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
    • Información
    • 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 taberna
    • 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
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • 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
    Browse all Industries
  • 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
    • Services for 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

How can I add custom fields to the sale order print template?

Suscribirse

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

Se marcó esta pregunta
v8printsale.order
3 Respuestas
13629 Vistas
Avatar
Peter Nietz

We have added some extra fields to the model sale.order.line. The values in these fields are needed for some automatic calculations we do in our modules. Our code looks similar to this (minimal example):

class sale_order_line(models.Model):
    _inherit = 'sale.order.line'
    myfield1 = fields.Char(string='License key', required=False)
    myfield2 = fields.Date(string='Start date', required=False)

However we need to show these values on the printed sale order as well. Therefore we tried to extend the sale order template to include these values right behind the name field. This looks like follows:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <template id="my_report_saleorder_document" inherit_id="sale.report_saleorder_document">
            <xpath expr="//span[@t-field='l.name']" position="after">
                <span t-field="l.myfield1"/>
                <span t-field="l.myfield2"/>
            </xpath>
        </template>
    </data>
</openerp>

Unfortunately this extended template seems to have no effect. Odoo still uses the standard template and our custom fields are not shown. How can we tell Odoo to use the modified template?

 

EDIT: In the meantime we investigated a little more on the inner workings of sale order printing. It seems to be the case that Odoo has a template 'sale.report_saleorder' which in turn includes the template 'sale.report_saleorder_document':

<template id="report_saleorder">
    <t t-call="report.html_container">
        <t t-foreach="doc_ids" t-as="doc_id">
            <t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'sale.report_saleorder_document')"/>
        </t>
    </t>
</template>

Our inherited version of the included template of course has a different ID 'mymodule.my_report_saleorder_document'. Maybe the problem is that the "master template" still includes the old version of the "inner template" instead of our new inherited version? But this would mean that there are two different types of "inheritance" in Odoo? Also the module sale_layout seems to do it the same way we do it? We are confused...

 

0
Avatar
Descartar
Avatar
Muhammad Hassan
Mejor respuesta

I applied same logic but my field value is not displaying and parent view can not be located error occurs

0
Avatar
Descartar
Avatar
Zbik
Mejor respuesta
  1. Probably you need a record:

    'depends': [ 'sale' ],

in your module, in __openerp__.py

2. You change

myfield1 = fields.Char()
myfield2 = fields.Date()

by

myfield1 = fields.Char('FOO NAME')
myfield2 = fields.Date('FOO DATE NAME')

3. Probably the values in these fields are empty and therefore do not see them in report

0
Avatar
Descartar
Peter Nietz
Autor

We already have that in our module: "depends" : [ "base", "web", "account", "sale" ]

Zbik

You have installed sale_layout module?

Peter Nietz
Autor

No, we did not have sale_layout installed. We have catched up with that now, but apparently it does not make any difference whether it is installed or not.

Zbik

Answer updated

Peter Nietz
Autor

Okay, apparently we reduced the code too much to provide a minimal example. We have changed the example code above to be closer to our actual production code. We also added another thought above.

Zbik

You code works without any problem in my test system.

Zbik

You inherit sale.order in other custom module? Eg. if sale_layout is installed he would replace a part of the report template (this with your code).

Avatar
Ankit H Gandhi(AHG)
Mejor respuesta

Hello Peter Nietz,

Use below code may be help you.

<template id="my_report_saleorder_document" inherit_id="sale.report_saleorder_document">
                <xpath expr="//table[@class='table table-condensed']/thead/tr/th[1]" position="after">
                       <th>License key</th>
                       <th>Start date</th>
                </xpath>
                <xpath expr="//table[@class='table table-condensed']/tbody[@class='sale_tbody']/tr/td[1]" position="after">
                       <td><span t-field="l.myfield1"/></td>              
                       <td><span t-field="l.myfield2"/></td>
                </xpath>
        </template>

if you find this answer helpful, please give me a thumbs up vote

Regards,

Ankit H Gandhi

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
Create a print view for a tree view
v8 print
Avatar
Avatar
1
jul 15
9791
Email template is failed to render ? [SOLVED] Resuelto
v8 sale.order email_template
Avatar
Avatar
Avatar
Avatar
4
ene 19
33126
How to modify count total amount in sale order? [SOLVED] Resuelto
v8 sale.order override
Avatar
Avatar
Avatar
3
ene 18
10045
Where is it possible to view the "Warning message" as defined in product form?
message v8 sale.order
Avatar
0
may 16
4511
v8: Error when print BoM
v8 print bom
Avatar
0
mar 15
4758
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