Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

How can I return a record after deletion

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
viewbuttonform_viewOdoo13.0
1 Beantwoorden
7206 Weergaven
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
Annuleer
Avatar
Begineer
Beste antwoord

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
Annuleer
Duy Le
Auteur

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
Auteur

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
Auteur

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
Auteur

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
Auteur

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.

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
View Override - Add attribute on action button
view inheritance button
Avatar
Avatar
Avatar
3
dec. 23
3676
Specify position or order of smart buttons on partner form views Opgelost
button form_view smart
Avatar
Avatar
1
jun. 22
13971
Open the tree view after clicking on a button on a form view Opgelost
button form_view Odoo12.0
Avatar
Avatar
Avatar
4
sep. 21
16835
Return a new tree view for account.move.line
accounting button Odoo13.0
Avatar
Avatar
1
sep. 21
4313
Create menuitems dynamically in Odoo 13 Opgelost
view dynamically Odoo13.0
Avatar
Avatar
1
aug. 21
8337
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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