Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

Record does not exist or has been deleted

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
pythonimportingduplicatesv14
1 Odpowiedz
6976 Widoki
Awatar
Pierre de Giorgio

I have an automated action that triggers on Update and Create.  It is intended to be used to prevent duplicate emails being imported into the email contact list.  When a duplicate is found I get the error "Record does not exist or has been deleted".

I would like it to just delete that record or cancel importing that record. Is the problem happening because the record has  not yet been created? My objective is to just skip over that record and not create it and move on to the next one.

new_value = record.email
existing_records = env['mail.mass_mailing.contact'].search([('email', '=ilike', new_value),('id','!=',record.id)])
if existing_records:
record.unlink()

0
Awatar
Odrzuć
Pierre de Giorgio
Autor

Some help on this would be greatly appreciated if someone could help me out.

Pierre de Giorgio
Autor

Are there really no experts out there who can help to answer this?

Awatar
Cybrosys Techno Solutions Pvt.Ltd
Najlepsza odpowiedź

Hi,

The error message "Record does not exist or has been deleted" typically occurs when you attempt to perform an operation on a record that doesn't exist. In your code, you're trying to delete a record using record. unlink(), but it seems like the record may not exist or hasn't been created yet when the action is triggered, leading to this error.

new_value = record.email
existing_records = env['mail.mass_mailing.contact'].search([('email', '=ilike', new_value), ('id', '!=', record.id)])

if existing_records:
    raise ValidationError("A record with this email already exists.")

By raising a ValidationError when a duplicate email is found, you will prevent the creation of a new record and generate an error message. This will effectively skip over the duplicate record and move on to the next one, without creating duplicates in the first place.

or If you want to resolve the "Record does not exist or has been deleted" issue when attempting to delete a record with record.unlink(), you need to ensure that the record exists and that it hasn't been deleted before calling the unlink method.
new_value = record.email
existing_records = env['mail.mass_mailing.contact'].search([('email', '=ilike', new_value), ('id', '!=', record.id)])

if existing_records:
    # Check if the record exists before attempting to delete it
    if record.exists():
        record.unlink()
    else:
        # Handle the case where the record doesn't exist
        # You can choose to log a message or take other actions as needed
        pass

Here's how you can create a constraint in your code to prevent the creation of a new record when a duplicate email is found and generate an error message:

from odoo import models, fields, api
from odoo.exceptions import ValidationError

class MassMailingContact(models.Model):
    _name = 'mail.mass_mailing.contact'

    email = fields.Char(string='Email', required=True, unique=True)

    @api.constrains('email')
    def _check_duplicate_email(self):
        for record in self:
            existing_records = self.search([('email', '=ilike', record.email), ('id', '!=', record.id)])
            if existing_records:
                raise ValidationError("A record with this email already exists.")


Hope it helps

0
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
How to round sum of if code Rozwiązane
python v14
Awatar
Awatar
1
maj 22
5410
I am getting this error when i try to start the odoo service in the server.can anyone help me with this?
python v14
Awatar
0
lis 21
21
Payment via python on Odoo 14
python v14
Awatar
0
lis 21
4398
How to correctly create subfolders of models
python importing v15
Awatar
Awatar
1
mar 23
3457
My custom report is changing when user Configured the Document Layout Rozwiązane
python qweb v14
Awatar
Awatar
1
sty 23
3401
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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