Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Guest House
    • Drankenhandelaar
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Solar Energy Systems
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC Services
    Others
    • Nonprofit Organization
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

How to use python function in my QWeb report?

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
pythonqwebreportodooV8
3 Antwoorden
22996 Weergaven
Avatar
Gary Heldmann

I would like to use in my QWeb report the element "item". What I should write in my report ? "item" is an attribute in tabData. You can see my python code below. I have already conffigure the report parser and it works.

This is my python code :

def getLines (self, objects):

            tabData = []
            print objects
            for i in range (7):
                tabData.append({})
                tabData [i] ['jour']      = self.tabJour [i]
                tabData [i] ['commandes'] = {}

            for o in objects:
                indJour = int(o.jour) - 1

                if indJour not in range(7): continue

                commande = o.order_id.name

                if not (tabData [indJour]['commandes'].has_key (commande)):
                    tabData [indJour]['commandes'][commande] = {}
                    tabData [indJour]['commandes'][commande]['items'] = []
                    tabData [indJour]['commandes'][commande]['partner'] = o.order_partner_id.name




                bois    = o.bois1.code_fini
                bois2   = o.bois2.code_fini
                metal   = o.metal.code_fini
                tissus  = o.tissu.code_fini
                poignee = o.poignee.code_fini
                patte   = o.patte.code_fini
                cfg     = o.config


                optionTissu = o.tissu.couleur_finifr

                qty           = int(o.product_uom_qty)
                qtyEmballe    =  0
                qtyPeinture   = qty - qtyEmballe - int(o.FabPeint)
                qtyTeinture   = qty - qtyEmballe - int(o.FabTeint)
                qtyRembourage = qty - qtyEmballe - int(o.ProdFTissus)
                qtyMetal      = qtyPeinture - int(o.ProdFMetal)
                qtyBois       = qtyTeinture - int(o.ProdFBois)

                if not (qtyMetal) or qtyMetal < 0:
                    qtyMetal = 0
                if not (qtyBois) or qtyBois < 0:
                    qtyBois = 0
                if not (qtyPeinture) or qtyPeinture < 0:
                    qtyPeinture = 0
                if not (qtyTeinture) or qtyTeinture < 0:
                    qtyTeinture = 0
                if not (qtyRembourage) or qtyRembourage < 0:
                    qtyRembourage = 0

                if bois == '.':
                    bois = None
                if bois2 == '.':
                    bois2 = None
                if metal == '.':
                    metal = None
                if tissus == '.':
                    tissus = None
                if poignee == '.':
                    poignee = None
                if patte == '.':
                    patte = None
                if cfg == '.':
                    cfg = None

                if optionTissu == "NONE":
                    optionTissu=None

                tabData [indJour]['commandes'][commande]['items'].append ({
                        'item': o.product_id.default_code,
                        'qty': qty,
                        'metal': metal,
                        'bois': bois,
                        'bois2': bois2,
                        'tissus': tissus,
                        'poignee': poignee,
                        'patte': patte,
                        'optionTissu': optionTissu,
                        'cfg': cfg,
                        'notes': o.notes,
                        'qtyEmballe': qtyEmballe,
                        'qtyMetal': qtyMetal,
                        'qtyBois': qtyBois,
                        'qtyPeinture': qtyPeinture,
                        'qtyTeinture': qtyTeinture,
                        'qtyRembourage': qtyRembourage,
                    })
            print "FIN"
            return tabData

Thank you for your help.

0
Avatar
Annuleer
Avatar
Niraj Pajwani
Beste antwoord

Create .py file to call python function:

  • .py

    # -*- coding: utf-8 -*-

    from openerp import api, models

    class first_report_method(models.AbstractModel):

         _name = 'report.module_name.report_template'

         @api.multi

         def render_html(self, data=None):

              report_obj = self.env['report']

             report = report_obj._get_report_from_name('module_name.report_template')

             docargs = {

                 'doc_ids': self._ids,

                  'doc_model': report.model,

                 'docs': self,

                 'getLines': self._getLines,

             }

              return report_obj.render('module_name.report_template', docargs)

         def _getLines(self, object):

             # function body...

             return tabData

    # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:


  • Call python function from .xml(report template) using:

    <div t-esc="getLines(o)"/>

7
Avatar
Annuleer
Avatar
Prakash
Beste antwoord
<t t-set="lines" t-value="o.getLines()"></t>


#Place the method in the model of active object .

#set it's values in side the lines variable. 

#Now iterate it's values using for-each 



3
Avatar
Annuleer
Avatar
Niyas Raphy (Walnut Software Solutions)
Beste antwoord

Hi,

There is a function in Odoo, which will get executed automatically while printing the PDF report in Odoo. See this: How To Call A Python Function While Printing PDF Report in Odoo

Thanks

0
Avatar
Annuleer
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
“QWebException None type object” - QWEB Report using python method Opgelost
python qweb report odooV8 QWebException
Avatar
Avatar
2
jan. 21
8875
How to restrict user to save print report in their local system?
qweb report odooV8
Avatar
0
dec. 17
4387
How to dynamically change report Name odoo v8
qweb report odooV8
Avatar
Avatar
1
sep. 17
5861
How to print invoices with there payments
python qweb odooV8
Avatar
Avatar
Avatar
Avatar
4
jul. 17
7962
How to create report (fields based on existing model)
qweb report odooV8
Avatar
Avatar
2
feb. 17
8056
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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