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

How to use a button to show a form to edit data?

Odoberať

Get notified when there's activity on this post

This question has been flagged
treeviewformvieweventbuttoneditpopup
2 Replies
8516 Zobrazenia
Avatar
Ratmil Torres

I have inserted a button as a cell in a tree view for my model. When the button is clicked it is suppose to pop up a form to edit the current record, the record is in the same row where the button is.

This is the code to handle the clicking of the button:

-----------------------------

def open_details(self, cr, uid, ids, context=None):
        view = {
            'name': _('Details'),
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'my.model',
            'view_id': False,
            'type': 'ir.actions.act_window',
            'target': 'new',
            'readonly': True,
            'res_id': ids[0],
        }
        return view

--------------------------------

It is not working. The form is shown but no data is loaded, and there isn´t either save or cancel button.

What is wrong in this code?

0
Avatar
Zrušiť
Avatar
Ben Olsen
Best Answer

Hey Ratmil, looks like I wasn't careful enough when copy-and-pasting my previous answer. Note that one of the options in that view you're creating is:

'readonly': True,

Obviously if the form is readonly it won't have save/cancel buttons. Sorry about that.

As for the data not loading, the rest of it looks right to me. Maybe the "ids" arg isn't getting passed in? Right before the "view = {" line, I'd put in a "print(ids)" and check the output when you load that page. If "ids" isn't getting passed in correctly, that's definitely a problem. And are you sure you're replacing "my.model" with the actual model name that you want to edit? Let us know what the output of print(ids) is and maybe we can help from there.

0
Avatar
Zrušiť
Ratmil Torres
Autor

Hi, Ben. Thanks again for your response. I printed the ids var and I got [86]. In any case, a list with one item that is the id of record to edit. I set readonly to false ('readonly':False) and same result came out. Yes, by 'my.model' I mean the full name of my model. Actually I get the right form. The only problem is that field values are not loaded. And there are no save nor cancel button.

Ben Olsen

Well that's very curious. That is a good value for ids, so "'res_id': ids[0]" should work. I'm doing this exact thing in one of my modules and it works fine. Sorry I can't be more help.

Ratmil Torres
Autor

Hi, Ben. Well, I was defining my own view for editing the module. So, I removed this view definition and let OpenERP create the form view it self. And now data is loaded correctly. The only issue is that save button is not showing. Thank you very much for your help.

Ratmil Torres
Autor

Anyway, your solution is perfect, but I guess I just have a different problem in my code. Thanks again.

Avatar
Ratmil Torres
Autor Best Answer

Hi, Ben.

It all works fine except for the missing "save" and "discard" buttons.

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
What event is triggered when a form view is shown? Solved
form view event init
Avatar
Avatar
Avatar
6
dec 22
10267
Detail Form View with SQL View Model Solved
form view button sql
Avatar
Avatar
2
júl 21
10708
Show model data in popup opened from button Solved
action treeview button popup
Avatar
Avatar
1
mar 20
14603
How to hide form Edit button depends on field value? Solved
form hide button edit
Avatar
Avatar
Avatar
Avatar
Avatar
4
dec 23
24213
Disable Create button in Tree view but keep Import
import treeview view tree button
Avatar
0
júl 25
12143
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