Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

Active ids not getting in wizard selection field function in Odoo17

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
v17
1 Atsakyti
3410 Rodiniai
Portretas
Anil Issac
I was using a function to load list in selection field. It was working in Odoo16. When I checked same code in Odoo17 It is not working. The code added below.



from odoo.exceptions import UserError
from odoo import models, api, _, fields
import logging

_logger = logging.getLogger(__name__)
class TestOrderShop(models.TransientModel):
    _name = 'test.shop.wizard'
    _description = 'Test Shop'
   
    @api.model
    def default_get(self, fields):
   
        res = super(TestOrderShop, self).default_get(fields)     

        selected_ids = self.env['sale.order']._context.get('active_ids', [])
        _logger.info('\n\n\n\n  selected_ids  =  %s \n\n\n\n' % (selected_ids) )     
       
        return res   
   
   
    def _get_radio_button(self):
        selection=[
            ('cancel', "Cancel"),
            ('pending', "Pending"),
            ('ready', "Ready"),
        ]
        selected_ids = self.env['sale.order']._context.get('active_ids', [])
        _logger.info('\n\n\n\n  selected_ids  =  %s \n\n\n\n' % (selected_ids) )   
        #Conext value worked in Odoo16 
        #Not getting Context value here in Odoo17
       
       
        order_id = self.env['sale.order'].sudo().search([('id', 'in', selected_ids)])
       
        _logger.info('\n\n\n\n  _get_selection  =  %s \n\n\n\n' % (order_id.id) )   
             
        if order_id:     
            if not order_id.custom_id:
                selection=[('new_order', "New Order"),]
                return selection

        return selection


    test_block_id = fields.Many2one('test.block')
    shop_selection = fields.Selection(_get_radio_button, string="Shop Action")
   



    def shop_selection_action(self):
        shop_id = self.test_block_id
        if self.shop_selection == "pending":
            self.env['sale.order'].shop_pending_order(shop_id)
        if self.shop_selection == "ready":
            self.env['sale.order'].shop_order_ready(shop_id)                           
        if self.shop_selection == "cancel":           
            self.env['sale.order'].shop_order_cancel(shop_id)

return


0
Portretas
Atmesti
Portretas
Kaushik Pathak
Best Answer

In context you get both active_model and active_ids. You can use self._context.get('') or self.env.context.get('') to get appropriate values.

For example,

self.env['active_model'].search('id', 'in', self._context.get('active_ids'))

0
Portretas
Atmesti
Anil Issac
Autorius

shop_selection = fields.Selection(_get_radio_button, string="Shop Action")

I am using _get_radio_button() function to load the radio button values as per conditions.
Context gives correct values other functions.

But when using same context code in the _get_radio_button() to get the currently active id of the sale_order,
it just return empty in Odoo17 for me.

Kaushik Pathak

You have to pass context for sale order id in the action from where you are open a wizard and then you can use this context value in your relative method of wizard.

Anil Issac
Autorius

I tried passing sale order id in context of the action that calls the wizard. But the data not getting inside the _get_radio_button() function.
In other functions like default_get(), I can access the context data.

Kaushik Pathak

Please paste the opening wizard method code here.. If I'm not wrong you're opening that wizard sale order, Right?

Anil Issac
Autorius

I am opening the wizard from the sale order actions. Above code is the wizard code.

when printing action i get below result in log.
context data is getting in the default_get().
Not in the _get_radio_button() function which used to return radio button list as per condition.

{'id': 585,
'name': 'Test Shop',
'type': 'ir.actions.act_window',
'xml_id': 'my_test_shop.action_test_shop_actions_wizard',
'help': False,
'binding_model_id': False,
'binding_type': 'action',
'binding_view_types': 'list,form',
'display_name': 'Test Shop',
'create_uid': (1, 'OdooBot'),
'create_date': datetime.datetime(2024, 1, 9, 7, 32, 32, 966062),
'write_uid': (1, 'OdooBot'),
'write_date': datetime.datetime(2024, 1, 15, 6, 13, 30, 916019),
'view_id': (1549, 'test.shop.wizard.form.view'),
'domain': False,
'context': "{'test_block_id': 1, 'order_id': 1167}",
'res_id': 0,
'res_model': 'test.shop.wizard',
'target': 'new',
'view_mode': 'form',
'mobile_view_mode': 'kanban',
'usage': False,
'view_ids': [],
'views': [(1549, 'form')],
'limit': 80, 'groups_id': [],
'search_view_id': False,
'filter': False}

Kaushik Pathak

sale_ids = fields.many2many()

@api.model
def default_get(self, fields):

res = super(TestOrderShop, self).default_get(fields)

selected_ids = self.env['sale.order']._context.get('active_ids', [])
res['sale_ids'] = [(4, selected_ids)]
_logger.info('\n\n\n\n selected_ids = %s \n\n\n\n' % (selected_ids) )

return res

You can use sale_ids in radio button method.

Anil Issac
Autorius

I tried similar and this method. But seems _get_radio_button() function is calling before the default_get() function.
So in log the variable value showed unknown in _get_radio_button() function.

selected_ids = _unknown()

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

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

Registracija
Related Posts Replies Rodiniai Veikla
Ya es posible hacer Upgrade de v17 a v17.1 ?
v17
Portretas
Portretas
1
spal. 25
1465
How to add a new Many2one field in res.config.settings? Solved
v17
Portretas
Portretas
Portretas
Portretas
4
spal. 25
4106
Add field to ALL models in Odoo
v17
Portretas
Portretas
Portretas
2
rugs. 25
2657
How to disable Email notification - You have been assigned to Solved
v17
Portretas
Portretas
Portretas
Portretas
4
rugs. 25
8212
Selection Field Options Disappear from Database (PostgreSQL enum) on Module Upgrade
v17
Portretas
0
rugp. 25
1448
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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