İç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

delegation inheritance, parent to child, child to parent, odoo 11

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
inheritanceinheritdelegationinheritsodoo11
1 Cevapla
12755 Görünümler
Avatar
ai

I have 3 classes:

class Parent(models.Model):

    _name='parent.parent'


class Child1(models.Model):

    _name="child.child1"

    _inherits={'parents.parents': 'parent_id'}

    parent_id = fields.Many2one('parent.parent', required=True, ondelete="cascade")

class Child2(models.Model):

    _name="child.child2"

    _inherits={'parents.parents': 'parent_id'}

    parent_id = fields.Many2one('parent.parent', required=True, ondelete="cascade")

How can I navigate from parent.parent to his (all) children? Do I need to declare to new fields in the parent like ?:

child1 = fields.Many2one('child.child1', store=False)

child2 = fields.Many2one('child.child2', store=False)

Is there a better solution?




0
Avatar
Vazgeç
Adrien

'store' is used for computed fields which are by default not stored in database, so you can add store=True to store it.

In your example, the use of store=False is irrelevant.

Also, it seems you need to understand better the inheritance concept and relational field concept. See my answer below.

Avatar
Adrien
En İyi Yanıt

Hi,

1. About Model inheritance

First of all, are you sure you really need "_inherits" ?
It is much more common to use "inherit" which works like this :
_name = 'child1.child1'
_inherit = ['parent.parent']
And then you can use the field of the parent in the child object :
child1.parent_field

If you don't know the difference, see e.g. :

https://www.odoo.com/fr_FR/forum/how-to/developers-13/the-different-openerp-model-inheritance-mechanisms-what-s-the-difference-between-them-and-when-should-they-be-used-46


2. About parent / child relation :

This is not related with inheritance but to relational fields.

In that case you can have :

- a One2many field in the parent model to its children

example : child1_ids = fields.One2many(comodel_name='child1.child1', inverse_name='parent_id')

then you can do:

for child1 in parent.child1_ids:

    ... do smth ...

- a Many2one field in the child object to its parent (that must then be called 'parent_id' to correspond to the 'inverse_name' used before)

see for example the link between a partner and its contacts in native Odoo.

And explanation of relational fields :

https://www.odoo.com/fr_FR/forum/aide-1/question/relational-fields-114056

1
Avatar
Vazgeç
ai
Üretici

Thanks, Yes I think I need inherits. Because I have many classes which use the parent.parent. If I use One2many and Many2one, I need to declare many of them in parent.parent. I want to access some attributes of the child1, child2, childn from parent.parent.

Maybe, I want to display/choose children with fields.Many2one(parent.parent) in a view.

Is this possible?

Adrien

It is not clear what you mean and need.

Can you clarify what you need :

- parent/child relation between RECORDS ? ===> This is handled with relational fields

- or parent/child relation between MODELS ==> This is handled with inheritance

Maybe you could provide a minimal practical example of what you want to do?

ai
Üretici

class Selector(models.Model):

_name = 'selector.model'

selectOne = fields.Many2one('parent.parent')

fieldOfChildren1 = fields.Char(related='selectOne.attributeOfChildren1')

fieldOfChildren2 = fields.Integer(related='selectOne.attributeOfChildren2')

Is this somehow possible?

I think it is relation between MODELS.

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
violates not-null constraint
inheritance delegation inherits odoo12
Avatar
Avatar
1
Ara 19
6595
delete inherited child (inherits) odoo 12
inheritance many2one delegation odoo11 odoo12
Avatar
0
Eki 18
4499
Odoo 11: Adding child model to res.partner Çözüldü
inheritance odoo11
Avatar
Avatar
1
Eyl 19
4922
How to change field default value in model 'A' when changing field from model 'B' ?
inherit odoo11
Avatar
Avatar
Avatar
2
Eyl 19
7069
How to extend an existing class and include social newtork features in the sub class
inheritance inherit
Avatar
Avatar
3
Tem 18
4646
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