Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

[SOLVED] Call a report from a wizard (odoo 8)

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
reportswizardsodoo8.0
2 Risposte
23010 Visualizzazioni
Avatar
dlsuarez

I need help to generate a report from a button in a wizard view.

I use qweb in odoo 8.0.

This is my code:

wizards/stats,py

@api.multi
    def compute_stats(self):
        stats = self._get_stats()
        leads = self._get_leads(
            stats.salesperson_ids.mapped("id"),
            stats.source_ids.mapped("id"),
            stats.stage_ids.mapped("id"),
            stats.reason_ids.mapped("id")
        )
        report_obj = self.env['report']
        report = report_obj._get_report_from_name('crm_ticket_platforms.crm_stats')
        docargs = {
            'doc_ids': self._ids,
            'doc_model': report.model,
            'docs': self,
        }
        return report_obj.render('crm_ticket_platforms.crm_stats', docargs)

report/crm_stats.xml

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>
        <report
            id="crm_ticket_platforms_report_crm_stats"
            model="stats"
            string="CRM Stats"
            report_type="qweb-pdf"
            name="crm_ticket_platforms.crm_stats"
            file="crm_ticket_platforms.crm_stats"
            attachment_use="False"
            attachment="(object.filename+'.pdf')"
        />
        <template id="report_crm_stats_document">
            <t t-call="report.html_container">
                <t t-foreach="docs" t-as="doc">
                    <t t-call="report.external_layout">
                        <div class="page">
                            <p><h2>Id:</h2> <span t-field="doc.id"/></p>
                            <separator/>
                        </div>
                    </t>
                </t>
            </t>
        </template>
        <template id="crm_stats">
            <t t-call="report.html_container">
                <t t-foreach="doc_ids" t-as="doc_id">
                    <t t-raw="translate_doc(doc_id, doc_model, 'lang', 'crm_ticket_platforms.report_crm_stats_document')"/>
                </t>
            </t>
        </template>
    </data>
</openerp>

This apparently works but not show/save the 'pdf' report.

Thanks!

4
Avatar
Abbandona
Avatar
Vasanth
Risposta migliore

Hi,

You can use the folowing code in the xml view( report_session.xml ) and then call the report from the wizard button

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

        <template id="report_session">
            <t t-call="report.html_container">
                <t t-foreach="docs" t-as="doc">
                    <t t-call="report.external_layout">
                        <div class="page">
                            <div class="oe_structure" />
                            <div class="text-center"><h1><span t-esc="doc.name"></span></h1></div>
                        </div>
                    </t>
                </t>
            </t>
        </template>

 

        <report id="report_print"
                string="Report"
                model="res.partner"
                report_type="qweb-pdf"
                file="res_partner.report_session"
                name="res_partner.report_session" />

</data>

</openerp>

1
Avatar
Abbandona
Avatar
Ankit H Gandhi(AHG)
Risposta migliore

Hello dlsuarez,
    
step 1 create report template using template tag
    
example like
    
<?xml version="1.0" encoding="utf-8"?>

<openerp> 
    <data>

        <template id="report_student_master_qweb">
            <t t-call="report.html_container"> 
                <t t-foreach="docs" t-as="o"> 
                    <t t-call="report.external_layout">
                        <div class="page">
                            <div class="oe_structure"/>
                            <div class="row">
                                <span class="text-center"><h1>Student Information</h1></span>
                                <table class="table table condensed">
                                    <tr>
                                        <td><h3><strong>GRN No:</strong></h3></td>
                                        <td><h3 t-field="o.code"/></td>
                                    </tr>
                                    <tr>
                                        <td><h3><strong>First Name:</strong></h3></td>
                                        <td><h3 t-field="o.fname"/></td>
                                    </tr>
                                    <tr>
                                        <td><h3><strong>Middle Name:</strong></h3></td>
                                        <td><h3 t-field="o.mname"/></td>
                                    </tr>
                                    <tr t-if="o.lname">
                                        <td><h3><strong>Last Name:</strong></h3></td>
                                        <td><h3 t-field="o.lname"/></td>
                                    </tr>
                                    <tr t-if="o.gender">
                                        <td><h3><strong>Gender:</strong></h3></td>
                                        <td><h3 t-field="o.gender"/></td>
                                    </tr>
                                    <tr t-if="o.dob">
                                        <td><h3><strong>Date of Birth:</strong></h3></td>
                                        <td><h3 t-field="o.dob"/></td>
                                    </tr>
                                    <tr t-if="o.join_date">
                                        <td><h3><strong>Joining Date:</strong></h3></td>
                                        <td><h3 t-field="o.join_date"/></td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </t>
                </t>
            </t> 
        </template>

    </data>
</openerp>

step 2 registration that report using report tag
    
example like
    
<?xml version="1.0" encoding="utf-8"?>
<openerp> 
    <data>
        <report id="school_management_qweb_report"
                string="school Management Report Qweb"
                model="student.master"
                report_type = "qweb-pdf"
                file="school_management.report_student_master_qweb"
                name="school_management.report_student_master_qweb" />
    </data>
</openerp>
    
step 3 create py file of wizard.
    
example like
    
from openerp.osv import orm, fields
from openerp.tools.translate import _

class wiz_student_report(orm.TransientModel):
    _name = 'wiz.student.report'
    _columns = {
        'student_id': fields.many2one('student.master', 'Student Name'),
        'birth_sdate': fields.date('Start Date'),
        'birth_edate': fields.date('End Date'),
    }

    def student_report(self, cr, uid, ids, context=None):
        student_obj = self.pool.get('student.master')
        cur_obj = self.browse(cr, uid, ids, context=context)
        datas = {}
        if cur_obj.birth_sdate >= cur_obj.birth_edate:
            raise orm.except_orm(_('Warning!'),_('End date is %s must be greater then start date is %s') % (cur_obj.birth_edate,cur_obj.birth_sdate))
        student_ids = student_obj.search(cr, uid, [('fname', '=', cur_obj.student_id.fname),('dob','>=',cur_obj.birth_sdate),('dob','<=',cur_obj.birth_edate)], context=context)
        if student_ids:
            data = self.read(cr, uid, ids, context=context)[0]
            datas = {
            'ids': student_ids,
            'model': 'wiz.student.report', # wizard model name
            'form': data,
            'context':context
            }
            return {
                   'type': 'ir.actions.report.xml',
                   'report_name': 'school_management.report_student_master_qweb',#module name.report template name
                   'datas': datas,
               }
               
step 4 create xml file of wizard
    
example like
    
<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

        <record model="ir.ui.view" id="wiz_student_report_form">
            <field name="name">wiz.student.report.form</field>
            <field name="model">wiz.student.report</field>
            <field name="arch" type="xml">
                <form string="Student Report">
                    <group>
                        <group string="Student Name">
                            <field name="student_id" nolabel="1" options="{'no_create': True}" required="1"/>
                        </group>
                    </group>
                    <group string="Birth Date Between" col="4" colspan="4">
                        <field name="birth_sdate" required="1"/>
                        <field name="birth_edate" required="1"/>
                    </group>
                    <footer>
                        <button string="Report" name="student_report" type="object" class="oe_highlight"/>
                        or
                        <button string="Cancel" class="oe_link" special="cancel" />
                    </footer>
                </form>
            </field>
        </record>

        <record model="ir.actions.act_window" id="wiz_student_report_action">
            <field name="name">Student Wize Report</field>
            <field name="res_model">wiz.student.report</field>
            <field name="type">ir.actions.act_window</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="target">new</field>
        </record>
        
    </data>
</openerp>

step 5 put this code in view xml file for pop up the wizard using button click.
    
example like
    
<button name="%(wiz_student_report_action)d" string="Student Wize Report" type="action"/>
    
if you find this answer helpful, please give me a thumbs up vote    

Regards,

Ankit H Gandhi
 

6
Avatar
Abbandona
Pascal Tremblay

In the tag, why do you use "model="student.master"? What is this model?

Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
Can anyone give the link for excel report customization for odoo? Risolto
reports excel odoo8.0
Avatar
Avatar
Avatar
2
giu 23
5093
How to create div in QWeb that is always at the bottom of the page? Risolto
qweb reports odoo8.0
Avatar
Avatar
Avatar
Avatar
Avatar
14
mag 22
48326
Print a py3o report from wizard Risolto
reports wizards odoo11
Avatar
Avatar
1
feb 21
4589
Background image gets cut off on the last page of a QWeb report (Odoo8) Risolto
qweb reports odoo8.0
Avatar
1
feb 24
6042
Where is the python file for report_payslip.xml file? - Odoo 8
hr_payroll reports odoo odoo8.0
Avatar
0
mar 15
5652
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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