Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Active ids not getting in wizard selection field function in Odoo17

Odoberať

Get notified when there's activity on this post

This question has been flagged
v17
1 Odpoveď
3416 Zobrazenia
Avatar
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
Avatar
Zrušiť
Avatar
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
Avatar
Zrušiť
Anil Issac
Autor

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
Autor

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
Autor

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
Autor

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!

Registrácia
Related Posts Replies Zobrazenia Aktivita
Ya es posible hacer Upgrade de v17 a v17.1 ?
v17
Avatar
Avatar
1
okt 25
1471
How to add a new Many2one field in res.config.settings? Solved
v17
Avatar
Avatar
Avatar
Avatar
4
okt 25
4114
Add field to ALL models in Odoo
v17
Avatar
Avatar
Avatar
2
sep 25
2664
How to disable Email notification - You have been assigned to Solved
v17
Avatar
Avatar
Avatar
Avatar
4
sep 25
8222
Selection Field Options Disappear from Database (PostgreSQL enum) on Module Upgrade
v17
Avatar
0
aug 25
1451
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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