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 to pass context from wizard to view and to and other action after?

Tilmeld

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

Dette spørgsmål er blevet anmeldt
actionwizardviewcontextpass
2 Besvarelser
45552 Visninger
Avatar
Pascal Tremblay

Hello all,

I have a new wizard who run well. This wizard allow user to choose a category.

When the user confirms the wizard, a new board.board view is started with the value of the choosen category in the context. Many graphs will be on this board according to the choosen category.

When the board.board view receive the context, how can it pass the context to the first graph action?

After this, how could the graph action use this context in its own domain?

I have a new field on stock.quant model (product_categ_id) and I want the first graph of my board only has quants with the category choosen by the user in the wizard.

Could you help please?


The wizard python (context has the choosen category in it) :

class wizard_choose_category(models.TransientModel):
    _name = 'wizard.choose.category'
    _description = 'Wizard that allow to choose a category'
    choose_category = fields.Many2one('product.category', string='Product category', domain=[('parent_id','!=', 1)])        #date = fields.Datetime('Date', default=fields.Datetime.now, required=True)        @api.multi    def open_table(self):
        self.ensure_one()
        ctx = dict(
            self._context,
            category=self.choose_category.id
            )
            
            res = {
            'domain': "[]",           
                'name': _('My dashboard by category'),
                'view_type': 'form',
                'view_mode': 'form',
                'res_model': 'board.board',
                'type': 'ir.actions.act_window',
                'context': ctx,
                'view_id': self.env.ref('vtm2_cavavin_inventory_graphs.inventory_by_category_form').id,
                'target': 'current',
            }

The view of boards (how to pass the received context to the called action?) :

<record id="inventory_by_category_form" model="ir.ui.view">
    <field name="name">Inventory dashboard form</field>
    <field name="model">board.board</field>
    <field name="arch" type="xml">
      <form string="Inventory dashboard">
            <board style="1-0">
                <column>
                    <action context="get.context()" string="Inventory pivot table"
                        name="%(action_inventory_pivot_1)d" />
                            
                </column>
            </board>
        </form>
    </field>
</record>


The action of the first graph (how to use the received context in the domain?) :

<record id="action_inventory_pivot_1" model="ir.actions.act_window">
            <field name="name">My inventory pivot #1</field>
            <field name="res_model">stock.quant</field>
            <field name="view_type">form</field>
            <field name="view_mode">graph</field>
            <field name="domain">[]</field>
            <field name="view_id" ref="inventory_pivot_1" />
        </record>


EDIT #1

I was certain that this line would work... But it is not the case...

<action string="Inventory of your choosen category - pivot table" name="%(action_inventory_pivot_1)d" 
    context="{'category': context.get('category')}" />



EDIT #2

With this line, all works fine. My graph displays all the quant from de category = 9. So the action tag of in a board view can pass the context to the called action. But the context.get() method doesn't seem to work in it...

<action string="Inventory of your choosen category - pivot table" name="%(action_inventory_pivot_1)d"
     context="{'category': 9}" />
4
Avatar
Kassér
Sehrish

How to to use context: http://learnopenerp.blogspot.com/2018/01/get-parent-form-value-in-one2many-form.html

Avatar
Pascal Tremblay
Forfatter Bedste svar

Here is our solution.


The action of the first graph (with the new domain who uses the context value) :

<record id="action_inventory_pivot_1" model="ir.actions.act_window">
            <field name="name">My inventory pivot #1</field>
            <field name="res_model">stock.quant</field>
            <field name="view_type">form</field>
            <field name="view_mode">graph</field>
            <field name="domain">[('product_category_id','=',context.get('category'))]</field>
            <field name="view_id" ref="inventory_pivot_1" />
        </record>


And we use Python to override the context of the board.board action because it doesn't want to understand context.get() method.

from lxml import etree

class board_board(osv.osv):
    _inherit = 'board.board'
    def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):

        result = super(board_board,self).fields_view_get(cr, user, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
       
        doc = etree.XML(result['arch'])
       
        for node in doc.xpath("//action"):
            set_context = "{'choosen_category': %s}" % context.get('category')
            node.set("context", set_context)
                result["arch"] = etree.tostring(doc)
        
        return result




3
Avatar
Kassér
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 disable wizard call in specific views ?
action wizard view
Avatar
0
mar. 15
4668
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
19266
Triggering an action from a function?
action function wizard trigger view
Avatar
Avatar
Avatar
2
mar. 15
12653
How to use the previous context in the action definition? Løst
action context
Avatar
Avatar
1
apr. 25
4372
Problem with opening full composer in send message
action wizard
Avatar
0
jan. 25
1996
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