Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Print Button in New Model

Subscribe

Get notified when there's activity on this post

This question has been flagged
salesfunctionpdf
3 Replies
1508 Views
Avatar
Óptica Marcopolo

Hola, buenas tardes. Agregué una nueva plantilla a mi módulo de ventas, basada en el diseño del presupuesto, pero orientada a un certificado específico que requiere nuestra empresa. Busco información sobre cómo activar las opciones de impresión o guardar como PDF dentro de esta plantilla. Les agradecería mucho su ayuda.


​

0
Avatar
Discard
Avatar
Piyush H
Best Answer

¡Hola! Entiendo que has creado una nueva plantilla de impresión en tu módulo de ventas y quieres habilitar las opciones de impresión y guardar como PDF. Aquí te explico cómo hacerlo:

Pasos para Activar la Impresión y Guardar como PDF

El proceso general implica definir un "report action" en Odoo y asociarlo a tu modelo. Aquí te detallo los pasos:

  1. Crear un Report Action (Acción de Reporte) en XML:
    • Dentro de tu módulo, crea o edita un archivo XML (por ejemplo, views/report_views.xml).
    • Define un ir.actions.report record. Este record le dice a Odoo cómo generar el PDF.
    <odoo>
        <data>
            <report
                id="action_report_mi_certificado"
                model="tu.modelo"  <!-- Reemplaza con el nombre de tu modelo -->
                string="Imprimir Certificado"
                report_type="qweb-pdf"
                name="tu_modulo.reporte_mi_certificado_template"  <!-- Reemplaza con el nombre de tu template -->
                file="tu_modulo.reporte_mi_certificado"  <!-- Reemplaza con el nombre del archivo base -->
                print_report_name="'Certificado - %s' % (object.name)"  <!-- Opcional: Nombre del archivo PDF -->
                binding_model_id="ref('model_tu_modelo')"  <!-- Reemplaza con la referencia al modelo -->
                binding_type="report"
            />
        </data>
    </odoo>
    
    Explicación de los campos:
    • id: Un identificador único para tu report action.
    • model: El nombre del modelo al que pertenece este reporte (ej., sale.order, tu.modelo). Reemplaza tu.modelo con el nombre real de tu modelo.
    • string: El texto que aparecerá en el menú de impresión (ej., "Imprimir Certificado").
    • report_type: qweb-pdf indica que estás usando QWeb para generar el PDF.
    • name: El nombre técnico del reporte. Sigue la convención tu_modulo.nombre_del_template. Reemplaza tu_modulo.reporte_mi_certificado_template con el nombre correcto de tu template QWeb.
    • file: El nombre base del archivo PDF generado. Sigue la convención tu_modulo.nombre_del_archivo. Reemplaza tu_modulo.reporte_mi_certificado con un nombre apropiado.
    • print_report_name: (Opcional) Define el nombre del archivo PDF que se descargará. Puedes usar expresiones Python para hacerlo dinámico (ej., incluir el nombre del cliente). object se refiere al registro actual.
    • binding_model_id: Una referencia al modelo al que se asocia el reporte. Necesitas crear una referencia al modelo en XML.
    • binding_type: report indica que este es un reporte imprimible.
  2. Crear una Referencia al Modelo (si no existe):
    • Si no tienes una referencia a tu modelo en XML, necesitas crearla. Esto se hace en el mismo archivo XML (views/report_views.xml o donde prefieras).
    <record id="model_tu_modelo" model="ir.model">
        <field name="model">tu.modelo</field>  <!-- Reemplaza con el nombre de tu modelo -->
        <field name="name">Tu Modelo</field>  <!-- Reemplaza con un nombre legible para tu modelo -->
    </record>
    
    • Reemplaza tu.modelo con el nombre real de tu modelo.
    • Reemplaza "Tu Modelo" con un nombre descriptivo para tu modelo.
  3. Asegurarte de que tu Template QWeb Existe:
    • Tu template QWeb (el archivo que define el diseño del reporte) debe existir y tener el nombre correcto (el que usaste en el campo name del report action).
    • El template debe estar en un archivo XML (ej., views/report_templates.xml).
    <template id="reporte_mi_certificado_template">
        <t t-call="web.html_container">
            <t t-call="web.external_layout">
                <div class="page">
                    <!-- Aquí va el contenido de tu certificado -->
                    <h1>Certificado</h1>
                    <p>Este es un certificado para: <t t-esc="object.name"/></p>
                </div>
            </t>
        </t>
    </template>
    
    Explicación:
    • id: El identificador único del template. Debe coincidir con el nombre que usaste en el name del report action (ej., tu_modulo.reporte_mi_certificado_template).
    • <t t-call="web.html_container"> y <t t-call="web.external_layout">: Estos templates proporcionan la estructura HTML básica para el reporte (encabezado, pie de página, etc.).
    • <div class="page">: Define una página en el reporte.
    • <t t-esc="object.name"/>: Imprime el valor del campo name del registro actual. object se refiere al registro que estás imprimiendo.
  4. Incluir los Archivos XML en el __manifest__.py:
    • Asegúrate de que los archivos XML que creaste (ej., views/report_views.xml y views/report_templates.xml) estén listados en el data del archivo __manifest__.py de tu módulo.
    {
        'name': 'Mi Módulo de Certificados',
        'version': '1.0',
        'depends': ['sale'],
        'data': [
            'views/report_views.xml',
            'views/report_templates.xml',
        ],
        'installable': True,
        'application': False,
    }
    
  5. Actualizar el Módulo:
    • Después de hacer estos cambios, actualiza tu módulo en Odoo para que los cambios surtan efecto. Ve a la lista de aplicaciones, busca tu módulo y haz clic en "Actualizar".

Cómo Usar la Impresión

Una vez que hayas hecho esto, deberías ver una opción de "Imprimir Certificado" (o el texto que hayas puesto en el campo string del report action) en el menú "Imprimir" (Print) de tu modelo. También deberías poder guardar el reporte como PDF.

Consejos Adicionales

  • Diseño del Reporte: Usa CSS para diseñar tu reporte QWeb. Puedes incluir CSS directamente en el template o enlazar a un archivo CSS externo.
  • Imágenes: Para incluir imágenes en tu reporte, puedes usar la función base64 para codificar la imagen en el XML o usar un enlace a una imagen externa.
  • Depuración: Si tienes problemas, revisa los logs de Odoo para ver si hay errores. También puedes usar el debugger de Python para depurar tu template QWeb.


🚀 Did This Solve Your Problem?

If this answer helped you save time, money, or frustration, consider:

✅ Upvoting (👍) to help others find it faster

✅ Marking as "Best Answer" if it resolved your issue

Your feedback keeps the Odoo community strong! 💪

(Need further customization? Drop a comment—I’m happy to refine the solution!)


0
Avatar
Discard
Avatar
Óptica Marcopolo
Author Best Answer

Thank you very much, I will add it

0
Avatar
Discard
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi, 


To print your custom template, you must create a menu item in Odoo that links to your model and view. This involves defining a menu, an action (typically a window action), and associating that action with a specific model and view.


Menu Action

<record id="action_report_sale_template" model="ir.actions.report">
<field name="name">Sale Report </field>
<field name="model">sale.order</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">module_name.your_template_id</field>
<field name="report_file">module_name.your_template_id</field>
<field name="binding_model_id" ref="sale.model_sale_order"/>
<field name="binding_type">report</field>
</record>

Template


<template id="your_template_id">
<xpath expr="//t[@t-call='web.external_layout']" position="replace">
<t t-call="web.html_container">
#
#
#
#
#
#
</t>
</xpath>
</template>


Hope it helps

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
adding custom field in quotation/invoice
sales pdf
Avatar
Avatar
1
Nov 25
433
Odoo 18 Quotation Builder Header/Footer Print Problem Solved
sales pdf
Avatar
Avatar
2
Aug 25
4499
Digital products
sales pdf
Avatar
Avatar
1
Feb 25
8085
How to hide units of measure in PDF reports?
sales debug pdf
Avatar
Avatar
Avatar
3
Oct 25
626
How to keep footer always at the bottom of the very last page in QWeb PDF report
sales debug pdf
Avatar
Avatar
Avatar
2
Aug 25
1299
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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