İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

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

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

Cleaning Up Model Relationships After Field Removal

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
fieldsmodelscustomkeyerrormodels.Model
2 Cevaplar
1357 Görünümler
Avatar
Kavin C

I removed a field (dummy_field_ids) that was used in a One2many relationship in a model, but Odoo is still referencing it. How can I safely clean up all the relationships and data that depended on this fields.


DetailsExplanation:

I recently removed a custom module from my Odoo installation, which contained several fields and models. After removing the module code, I started encountering errors in the system, specifically KeyError messages referencing a field (dummy_field_ids) that I had deleted from the code.

From what I understand, even though the Python code defining the field no longer exists, Odoo's database still contains metadata and possibly table columns related to this field. This causes the system to continue expecting the field, which breaks views, forms, and certain automated actions.

Here's a summary of the situation:

  • The module has been removed, including all model definitions for dummy_field_ids.
  • The database still contains references to this field in the ir_model_fields table and in the actual table for the model.
  • Attempts to open forms or pages that previously used this field now throw errors.
  • I cannot uninstall the module (it's already removed) and manually deleting database columns seems risky due to foreign keys, constraints, and large amounts of data.

What I want to achieve:

  1. Remove the field completely from Odoo's metadata (ir_model_fields).
  2. Remove the actual column from the database table safely.
  3. Ensure that no views, actions, or reports reference this field anymore to prevent errors.
  4. Do this without uninstalling any modules and without losing other unrelated data.

I've seen some discussions suggesting writing a script to delete the field on server start or using SQL directly, but I want a safe, recommended approach that works with Odoo's ORM and handles both the metadata and database side.

Has anyone dealt with a similar situation? What is the recommended way to clean up removed fields from both the Odoo models and the database? Any scripts, methods, or best practices would be very helpful.


0
Avatar
Vazgeç
Kavin C
Üretici

The previously implemented code has been removed from the project. I created a new model named x.custom.model, which includes four new fields and a ForeignKey field (x_dummy_fk) referencing the x.base.model table. The x.base.model also includes a One2many field named x_dummy_one2many, pointing to x.custom.model using x_dummy_fk as the inverse_name.

Although the old code has been deleted, I'm still encountering an error related to x_dummy_one2many. I need to ensure that all references to this field are fully removed from both the database and the source code. Please help identify and clean up any remaining dependencies

x_dummy_one2many = fields.One2many(

    "x.custom.model",

    inverse_name="x_dummy_fk",

    string="Dummy Rebate",

)


could you please help me to erase all related code.

Avatar
Kavin C
Üretici En İyi Yanıt

The previously implemented code has been removed from the project. I created a new model named x.custom.model, which includes four new fields and a ForeignKey field (x_dummy_fk) referencing the x.base.model table. The x.base.model also includes a One2many field named x_dummy_one2many, pointing to x.custom.model using x_dummy_fk as the inverse_name.

Although the old code has been deleted, I'm still encountering an error related to x_dummy_one2many. I need to ensure that all references to this field are fully removed from both the database and the source code. Please help identify and clean up any remaining dependencies


x_dummy_one2many = fields.One2many(

    "x.custom.model",

    inverse_name="x_dummy_fk",

    string="Dummy Rebate",

)


could you please help me to erase all related code.

0
Avatar
Vazgeç
Avatar
Cybrosys Techno Solutions Pvt.Ltd
En İyi Yanıt

Hi,


Odoo stores field definitions in the database (ir_model_fields) and also physically adds columns to the underlying PostgreSQL table for the model.

If the Python code is gone but the metadata remains, Odoo will still try to load those fields, leading to the KeyError: 'dummy_field_ids' problem you’re seeing.


When you uninstall a module from inside Odoo, it removes:

            - The ir_model_fields records for its fields.

           - The database columns for non-stored computed fields and certain m2m/o2m rel tables.

           - View XML references to those fields.


If you delete the module files without uninstalling, Odoo:

           - Can’t execute the cleanup hooks.

           - Leaves behind database records and sometimes columns that reference the removed fields.

          - This makes the ORM and view loader fail when they try to render a view containing the field.


Methods

1- Remove metadata (Odoo ORM way):\

    self.env['ir.model.fields'].search([('name', '=', 'dummy_field_ids')]).unlink()


2- Remove references in views:

      self.env['ir.ui.view'].search([('arch_db', 'ilike', 'dummy_field_ids')]).unlink()


3-Drop the database column

      - If the field was store=True (most o2m/m2m are), it will have a column or a related table in PostgreSQL.If present, drop it:

                     ALTER TABLE table_name_for_your_model DROP COLUMN dummy_field_ids;

Note:- Be sure no remaining code or module expects this field before dropping.


4- Clear caches & restart


Hope it helps

0
Avatar
Vazgeç
Enjoying the discussion? Don't just read, join in!

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

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
Odoo 15 Community: Use Inherited Views to show Custom Field from sale.order in account.move.form
fields models custom
Avatar
0
Tem 22
3476
How to update a computed field based on a dependency from another model? Çözüldü
fields models custom dependencies computed
Avatar
Avatar
Avatar
2
Eki 23
14034
How to add custom field into the Sales Order PDF Print? Çözüldü
pdf fields models custom sale.order
Avatar
Avatar
Avatar
3
Mar 21
15680
Cannot add custom fields in models anymore
fields database models custom bug
Avatar
0
Eki 17
5075
View a field from one model in another model Çözüldü
fields models
Avatar
Avatar
1
Kas 25
6149
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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