Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

print value of a field in wizard to report?

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
wizardv6.1valuesprintreport
3 Besvarelser
17485 Visninger
Avatar
evon_dun

I need to pass the value of my two fields i.e date_from n date_to from my wizard to the report it calls/prints. Following is my code. This is working fine but only problem is i am not able to find how to print these two fields. Any help is appreciated.

class my_wizard_report(osv.osv_memory):

    _name = 'my.wizard.report'
##    _inherit = 'account.invoice'
    _description = 'Test Report'  

    _columns = {
        'date_from':fields.date('Date From',store=True),
        'date_to':fields.date('Date To',store=True),
        'invoice_ids':fields.many2many('account.invoice', string='Filter on invoices',help="Only selected invoices will be printed"),
    }

    _defaults = {
        'date_from': lambda *a: time.strftime('%Y-%m-%d'),
        'date_to': lambda *a: time.strftime('%Y-%m-%d'),
    }

    def print_report(self, cr, uid, ids, context=None):
        datas = {}
        if context is None:
            context = {}
        data = self.read(cr, uid, ids,['date_from', 'date_to', 'invoice_ids'], context=context)
        date_from = data[0]['date_from'] 
        date_to = data[0]['date_to']
        obj = self.pool.get('account.invoice')
        ids = obj.search(cr, uid, [('date_invoice','>=',date_from),('date_invoice','<=',date_to)])
        datas = {
                 'ids': ids,
                 'model': 'account.invoice',
                 'form': data
                }
        return {'type': 'ir.actions.report.xml', 'report_name': 'account.invoice.rnd5c3tV', 'datas': datas}





my_wizard_report()



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

<!-- cancel order  -->

        <record id="view_my_wiz_form" model="ir.ui.view">
            <field name="name">print.report.form</field>
            <field name="model">my.wizard.report</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Print Report">
                    <group colspan="4" >
                        <field name="date_from" filter_domain="[('date_invoice','&gt;=',self)]" />
                        <field name="date_to" filter_domain="[('date_invoice','&lt;=',self)]"  />
                    </group>
                        <separator string="Print Only" colspan="4" />
                        <group colspan = "4">
                            <field name="invoice_ids" colspan="4" nolabel="1"/>
                        </group>
                    <group colspan="4" col="6">                     
                        <button  icon="gtk-ok" name="print_report" string="Print" type="object"/>
                   </group>
               </form>
            </field>
        </record>

        <record id="action_my_wiz_form" model="ir.actions.act_window">
            <field name="name">Print Report</field>
            <field name="res_model">my.wizard.report</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
           <field name="view_id" ref="view_my_wiz_form"/>
           <field name="target">new</field>        
        </record>

        <act_window id="action_my_wiz_form_values"
            key2="client_action_multi" name="Print Report"
            res_model="my.wizard.report" src_model="add.penalty"
            view_mode="form" target="new" view_type="form"/>

    </data>
</openerp>

C:\fakepath\screen2.png

C:\fakepath\screen1.png

C:\fakepath\reports.png

0
Avatar
Kassér
Avatar
Abhishek H Menon
Bedste svar

Use data = self.read(cr, uid, ids,)[-1] in your print_report method and you will get the details that you entered via the wizard. It will a dictionary in which you will have keys and values as per the above defined fields

0
Avatar
Kassér
Avatar
Anuradha
Bedste svar
I didnt understand your requirement properly, If you want to print something you can use
import logging 
_logger = logging.getLogger(__name__)
_logger.info('Create a with vals ..............................%s', res)
Is that your requirement?
0
Avatar
Kassér
evon_dun
Forfatter

I don't understand what you said above but my requirement is very simple. The report is created by me already using Openoffice(base report designer) then i created a wizard in my custom module, i defined two fields date_from and date_to on the wizard and whatever dates are selected there i want to print them on my report which i called from here. Now its clear i hope. Please let me know if you have a solution to it.

evon_dun
Forfatter

I added few screen shots above.

Anuradha

@evon sorry I dnt have any idea :(

Avatar
babis peroukas
Bedste svar

I copy the code from sale.py that I edited to send some fields to my invoice.

   def _prepare_invoice(self, cr, uid, order, lines, context=None):
    """Prepare the dict of values to create the new invoice for a
       sales order. This method may be overridden to implement custom
       invoice generation (making sure to call super() to establish
       a clean extension chain).

       :param browse_record order: sale.order record to invoice
       :param list(int) line: list of invoice line IDs that must be
                              attached to the invoice
       :return: dict of value to create() the invoice
    """
    if context is None:
        context = {}
    journal_ids = self.pool.get('account.journal').search(cr, uid,
        [('type', '=', 'sale'), ('company_id', '=', order.company_id.id)],
        limit=1)
    if not journal_ids:
        raise osv.except_osv(_('Error!'),
            _('Please define sales journal for this company: "%s" (id:%d).') % (order.company_id.name, order.company_id.id))
    invoice_vals = {
        'name': order.client_order_ref or '',
        'origin': order.name,
        'type': 'out_invoice',
        'reference': order.client_order_ref or order.name,
        'account_id': order.partner_id.property_account_receivable.id,
        'partner_id': order.partner_invoice_id.id,
        'journal_id': journal_ids[0],
        'invoice_line': [(6, 0, lines)],
        'currency_id': order.pricelist_id.currency_id.id,
        'comment': order.note,
        'payment_term': order.payment_term and order.payment_term.id or False,
        'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id,
        'date_invoice': context.get('date_invoice', False),
        'company_id': order.company_id.id,
        'user_id': order.user_id and order.user_id.id or False,
        'x_destplace': order.x_destplace,
        'x_loadplace': order.x_loadplace,
        'x_vehivle': order.x_vehicle
    }

    # Care for deprecated _inv_get() hook - FIXME: to be removed after 6.1
    invoice_vals.update(self._inv_get(cr, uid, order, context=context))
    return invoice_vals

I 've added the x_ fields in both models (sales.order and account.invoice) and with this addition to the code (in invoice_vals) it just copies their values. So if you want to send those values to your invoice and then print it you have to create something like a _prepare_invoice function.

0
Avatar
Kassér
evon_dun
Forfatter

the account.invoice model doesn't contain these fields, these are in the wizard.

babis peroukas

Ah then you have to send those fields from your form to the account.invoice. Wait a minute I 'll copy a code.

babis peroukas

sry I dont know how to post a code clearly

babis peroukas

Also check this video http://www.youtube.com/watch?v=5dDoPcm6pVM

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

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
repport that contains the list of users
wizard print report reports
Avatar
0
mar. 15
4378
Printing report from the form view...
wizard print report record browse
Avatar
Avatar
1
mar. 15
10670
Change PDF report name on wizard
wizard report
Avatar
Avatar
2
jul. 24
4188
Blank report PDF from Wizard Løst
wizard report
Avatar
Avatar
2
apr. 24
3712
External ID not found in the system
wizard report
Avatar
4
okt. 20
6635
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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