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

How can I pass a context from an action displaying a tree, to another action (a server action linked by MULTI)?

Tilmeld

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

Dette spørgsmål er blevet anmeldt
actioncontextmulti
10531 Visninger
Avatar
Luis Masuelli

Want to implement a server action (in the end, such action pops up an account.voucher dialog) for invoices. Only true invoices to clients / supplier are considered, while refunds are not considered. In the odoo core, such 4 actions (client invoice, client refund, supplier invoice, supplier refund) are defined like this:

    <record id="action_invoice_tree1" model="ir.actions.act_window">
        <field name="name">Customer Invoices</field>
        <field name="res_model">account.invoice</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form,calendar,graph</field>
        <field eval="False" name="view_id"/>
        <field name="domain">[('type','=','out_invoice')]</field>
        <field name="context">{'default_type':'out_invoice', 'type':'out_invoice', 'journal_type': 'sale'}</field>
        <field name="search_view_id" ref="view_account_invoice_filter"/>
        <field name="help" type="html">
            bla bla bla
        </field>
    </record>

This is just an example. By replacing out_invoice with the other 4 types, you have all the 4 actions.

Now the funny part: I want to implement a server action (my server action triggers an account.invoice function) that processes a bulk of selected invoices in the TREE, but taking the value in the "type" key in the context.

    <record id="action_massive_pay" model="ir.actions.server">
        <field name="state">code</field>
        <field name="type">ir.actions.server</field>
        <field name="model_id" ref="model_account_invoice"/>
        <field name="code">action = self.massive_invoice_pay_wizard(cr, uid, context.get('active_ids', []), context)</field>
        <field name="condition">True</field>
        <field name="name">Register Massive Payment</field> 
    </record>

    <record id="action_massive_pay_more_link" model="ir.values">
        <field name="model_id" ref="model_account_invoice" />
        <field name="name">Register Massive Payment</field>
        <field name="key2">client_action_multi</field>
        <field name="value" eval="'ir.actions.server,' + str(ref('action_massive_pay'))"/>
        <field name="key">action</field>
        <field name="model">account.invoice</field> 
    </record>

In the implementation of massive_invoice_pay_wizard, I expect to be able to access the "type" key in the context, as it was provided by the originating actions (actions that displayed the tree), but the "type" key is not present while I ask for it in the context (type, default_type, and stuff like that as specified in the original actions are not present when I debug the context in my method).

So I tried to add the tag `<field name="context">{'type': type}</field>` both in the ir.values and the new server action records, but nothing happened: ir.values does not expect a context, and somehow the server action does not receive the context from the original action.

Finally, my goal is to have processing for two different invoice types, disallow credit/debit notes, and present an account.voucher dialog (one for all the selected invoices). How can I pass such context?

0
Avatar
Kassér
Maduka Sopulu

ADD THIS TO THE code tage

<field name="code">

if records:

action = records.action_export_and_download()

</field>

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
How to use the previous context in the action definition? Løst
action context
Avatar
Avatar
1
apr. 25
4374
HOW CAN I GET CURRENT COMPANY ID IN CONTEXT OF ACTION USING JUST XML
action xml context odoo
Avatar
Avatar
1
jul. 24
2625
Context lost in button action
action buttons context v11.0
Avatar
Avatar
1
jun. 24
4403
Send and return values in action window button Løst
action v6.0 context window
Avatar
Avatar
1
nov. 22
50101
How to pass context to a called action with kanban view links or buttons? Løst
action view kanban context
Avatar
Avatar
1
okt. 21
19268
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