Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

Passing data from a wizard to a custom report

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
1 Antworten
13873 Ansichten
Avatar
David Fernández Sancho / NIF 53781829D

Hello everyone, 

I'm working on a module to allow printing more than one barcode label for each product. The idea is that the user opens a wizard from the action menu when viewing a product / product template. That wizard has a field to set the number of labels to print. And then a pdf report should be generated showing that labels. 

Well, I've got the first part. The wizard appears asking for the number of labels, but then I really don't know how to pass the product info together with the number of labels to print. 

And what I'm trying only gives me an error (TypeError: product.template is not JSON serializable) so far. 

So this is my wizard:

class Wizard(models.TransientModel):
    _name = "labels.wizard" labels_number = fields.Integer("Labels to print", required=True)

    @api.multi
     def print_report(self):
            product = self.env['product.template'].browse(self._context.get('active_ids'))

            labels_to_print = self.labels_number

             docs = {product, labels_to_print}

            return self.env['report'].get_action(self, 'mymodule.report_report_product_all_labels', docs)

And this is my report template (for testing I'm just trying to print the number of labels from the previous step, not the label. Once I can access to the number of labels I think I'll be able to complete the rest by myself):

<template id="report_report_product_all_labels">
 <t t-call="report.html_container">
         <t t-foreach="docs" t-as="product">
            <div class="page">

                <span t-field="product.labels_to_print"/>

            </div>

        </t>

    </t>

</template>

I have the feeling that the XML part is completely wrong - but I'm really struggling with the Odoo API here, specially with all these XML logic that I can't debug (which is driving me crazy). I've taken at the docs but couldn't figure out how to do this, and after searching for a while all the results I've found are either incomplete or using the old API. 

So... Can anybody help?

Thank you!


0
Avatar
Verwerfen
Avatar
Jesni Banu
Beste Antwort

Hi David,

I think following code will help you to print bar-code for products.

class PrintBarcodeWizard(models.Model):
    _name = 'wizard.barcode'

    print_qty = fields.Integer("No of Copies", default=1)   
    product_name = fields.Char(invisible=True)   
    product_barcode = fields.Char(invisible=True)
   

    @api.multi    def print_report1(self):
        context = self._context        obj = self.env['stock.pack.operation'].search([('id', '=', context.get('product_id'))])                self.product_name = obj.product_id.name       
        self.product_barcode = obj.product_id.barcode           
        if obj.product_id.barcode:
            return self.env['report'].get_action(self, 'print_barcode.report_barcode')           
        else:
            raise Warning((_("Please set barcode for the product %s") % obj.product_id.name))


You can write button definition as follow

<button name="%(wizard_barcode_act)d" string="Print" type="action" class="oe_highlight"                
                                context="{'product_id':id}"/>

Then you can write template as follow,

<openerp>    
    <data>       
        <template id="report_simple_label">        
            <t t-call="report.html_container">               
                <div class="page">                   
                    <div class="col-xs-4" style="padding:0;">                       
                        <t t-foreach="docs" t-as="obj">                           
                            <table style="border-spacing:0;margin-bottom:0;height:122px;" class="table">                               
                                <thead>                                   
                                                            
                                </thead>                               
                            <tbody>                                   
                                <tr style="width: 1in;">                                       
                                    <td style="border: 2px solid black;text-align: center; vertical-align: middle;" colspan="2" class="col-xs-5">                                           
                                                                   
                                        <span t-esc="obj.product_name"/>                                           
                                        <br/>                                           
                                        <img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', obj.product_barcode, 600, 100)" style="width:300px;height:50px"/>                                       
                                    </td>                                   
                                 </tr>                               
                            </tbody>                           
                        </table>                       
                      </t>                   
                    </div>               
                </div>           
              </t>       
        </template>       
        <template id="report_barcode">           
            <t t-foreach="docs" t-as="o">               
                <t t-foreach="range(0, o.print_qty)" t-as="i">                   
                    <t t-call="print_barcode.report_simple_label"/>               
                </t>           
             </t>      
        </template>       
        <report id="action_print_barcode" model="wizard.barcode" report_type="qweb-pdf" string="Barcode" name="print_barcode.report_barcode" file="print_barcode.report_barcode"/>   
    </data>
</openerp>    

2
Avatar
Verwerfen
David Fernández Sancho / NIF 53781829D
Autor

Hello Jesni, thank you for your reply.

I'm trying to implement this solution but I still have an issue: the name="%(wizard_barcode_act)d" on the button- how should be the referenced labels_wizard_act?

I currently have one act_windows to show the button under the Actions menu but I guess this should be a different one.

Thank you.

Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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