Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Print Button in New Model

Odoberať

Get notified when there's activity on this post

This question has been flagged
salesfunctionpdf
3 Replies
1482 Zobrazenia
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
Zrušiť
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
Zrušiť
Avatar
Óptica Marcopolo
Autor Best Answer

Thank you very much, I will add it

0
Avatar
Zrušiť
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
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
adding custom field in quotation/invoice
sales pdf
Avatar
Avatar
1
nov 25
419
Odoo 18 Quotation Builder Header/Footer Print Problem Solved
sales pdf
Avatar
Avatar
2
aug 25
4474
Digital products
sales pdf
Avatar
Avatar
1
feb 25
8050
How to hide units of measure in PDF reports?
sales debug pdf
Avatar
Avatar
Avatar
3
okt 25
585
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
1274
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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