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
    • Artificial Intelligence
    • 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
    • Property Management
    • 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
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

Dynamic res_id in action

Odoberať

Get notified when there's activity on this post

This question has been flagged
xmlwindow_actionres.usersuid
2 Replies
10726 Zobrazenia
Avatar
Billel Guernouti

Hello i'm currently using odoo 14.
What i want to do is to create a window action with  a dynamic record ID "res_id", and this last i want it to be the current user "uid".

<record model="ir.actions.act_window" id="action_window_id">
    <field name="name">my_module.model.action</field>
    <field name="res_model">model.model_one</field>
    <field name="view_mode">form</field>
    <field name="res_id" eval="THE CURRENT UID HERE" />
</record>

i've tried "self.env.uid","obj()"... with no result.
do you have any idea about this !
Thank you very much.

0
Avatar
Zrušiť
Sehrish

Try Server Action: https://learnopenerp.blogspot.com/2020/01/odoo-server-action.html

Avatar
Billel Guernouti
Autor Best Answer

I have ended this battle, by steps below:

1- Create method in my model which do the logic for res_id field and return a window action.

def alternative_action(self):
    exist = self.sudo().search([["user_id", "=", self.env.uid]], limit=1)
    # user_id is a field declared into my model. 
    res_id = self.env.uid
    return {
        "type" : "ir.actions.act_window",
        "res_model" : self._name,
        "view_mode": "form", 
        "res_id": exist.id if exist.id else False
    }

2- Create a server action which will call the method below:

<record model="ir.actions.server" id="id_act_server"> 
    <field name="name">resume res_id action</field> 
    <field name="model_id" ref="module_name.model_name"/> 
    <field name="state">code</field> 
    <field name="code"> 
        action = model.sudo().alternative_action() 
    </field> 
</record>
3- When creating the menu, we call the server action rather than calling the act_window as usual

<menuitem name="My module menu" id="my_module_menu" action="id_act_server"/>

and ... that's it.
This solution may work for different use cases not only mine, we can also give it a title like :
"customize the menu link".

Hopefully this will help some. Thanks

1
Avatar
Zrušiť
Avatar
Federico Bau
Best Answer

Thanks man 

0
Avatar
Zrušiť
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
uid in action domain gets always evaluated as Administrator
domain window_action uid
Avatar
0
júl 15
6988
Why openerp javascript tutorial fail ?
xml view window_action
Avatar
0
mar 15
5549
Odoo14 Action Server Error - Unable to call fields of current model in context correctly
xml window_action server_actions v14
Avatar
1
jan 24
3996
How to show specific users related to a service?
xml res.users python3 odoo11
Avatar
Avatar
2
mar 18
6198
View Error, can not view user accounts
error xml view res.users
Avatar
Avatar
1
mar 15
6207
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 Svenska ภาษาไทย 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