Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

How can I return a record after deletion

Odebírat

Get notified when there's activity on this post

This question has been flagged
viewbuttonform_viewOdoo13.0
1 Odpovědět
7209 Zobrazení
Avatar
Duy Le

Hi, Im making a customize delete button for my model in form view like this


But after the delete, the browser goes blank:


I want it to return an existing record that is there in my model, so how can I fix it? This is my delete button's code:

def delete_linked_user(self):
for rec in self:
holder = rec.user_id.partner_id
print(rec.user_id,' ',holder)
view = rec.user_id.unlink()
holder.unlink()
return {'type': 'ir.actions.client', 'tag': 'reload', }
1
Avatar
Zrušit
Avatar
Begineer
Nejlepší odpověď

Hello,

        While returning you can try to include 'action' and call your act window or you can give a try with 'type' : 'ir.actions.act_window'

0
Avatar
Zrušit
Duy Le
Autor

Hi Karthikeyan

I tried ur way too but didn't actually work, can you give me a specific example?

best regard

Begineer

Hey Duy le,

Please can you be more specific?? I guess your requirement is to delete only the User and Partner that is linked with the current record and return the form view of current record. Is your model hr.employee or a customized one.??

Begineer

Hi,

Your code works perfectly fine for me and i have tested in my local database too.

As your requirement, the User and its related Partner gets deleted and returns the current employee.

But the only con is it takes around one minute to delete and return the record.

Maybe due to lack of your server speed i.e cpu limit time you are not getting your record refreshed.

Try running your server with these in order to increase your cpu time limit

--limit-time-cpu=9999999999 --limit-time-real=99999999

Duy Le
Autor

thanks Karthikeyan, I appreciate your help very much

My problem is that I want my button to work just like the normal delete (unlink) action. When the record is deleted, I want to show onto the client a record in form view belong to my model, not just a blank space.

Again, thank you very much for your help ^^

Begineer

Hello Duy le,

The blank page appears only when you return a record which does not exist or the page that has not refreshed properly. Say you have 10 records and you are deleting the first one and you want to return the form view of second record? Is this your need ??

Duy Le
Autor

yes that's right!!! You got me!

I want browser to display another record but still don't know how to do it with action :D

Begineer

Hey Duy le,

I just now noticed that, you are not deleting your current record itself, you are deleting only the partner and user . The current record model is different from Partner and User.

In order to delete your current record you should add rec.unlink() as below,

def delete_linked_user(self):

for rec in self:

holder = rec.user_id.partner_id

print(rec.user_id,' ',holder)

view = rec.user_id.unlink()

holder.unlink()

rec.unlink()

return {'type': 'ir.actions.client', 'tag': 'reload', }

Duy Le
Autor

Thank you very much for your enthusiastic support ^^

I tried ur way too, but the problem is this:

At first, I have a record with id 14 and in this url

http://localhost:8070/web?#id=14&action=243&model=bsmart.employee&view_type=form&cids=&menu_id=252

But after deletion, when I triggered the {'type': 'ir.actions.client', 'tag': 'reload'}, it loaded the same record (which is deleted now) so it still went blank

How can I redirect this action to load an other record then?

Begineer

Hey Duy le,

@api.multi

def delete_linked_user(self):

action = self.env.ref('hr.open_view_employee_list_my').read()[0]

for rec in self:

holder = rec.user_id.partner_id

view = rec.user_id.unlink()

holder.unlink()

rec.unlink()

return action

In action mention your required module and your act window id

This works perfectly for me.

Thanks.

Duy Le
Autor

Hi, sorry for the late reply, your solution works nicely ^^ Maybe not as I thought how it would be but finest so far, thanks a lot Karthikeyan ^^

Begineer

Hi ,

Thanks for your vote, Glad to help.

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

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
View Override - Add attribute on action button
view inheritance button
Avatar
Avatar
Avatar
3
pro 23
3676
Specify position or order of smart buttons on partner form views Vyřešeno
button form_view smart
Avatar
Avatar
1
čvn 22
13974
Open the tree view after clicking on a button on a form view Vyřešeno
button form_view Odoo12.0
Avatar
Avatar
Avatar
4
zář 21
16835
Return a new tree view for account.move.line
accounting button Odoo13.0
Avatar
Avatar
1
zář 21
4314
Create menuitems dynamically in Odoo 13 Vyřešeno
view dynamically Odoo13.0
Avatar
Avatar
1
srp 21
8338
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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