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

api.onchange modification One2many field with NewItem does not works

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
one2many many2one custom field
3909 Görünümler
Avatar
Richard Kellner

In version v9.x I have defined models that have One2many and Many2one relation:

Sample code, that doesn't works for me (created in new module):

class ClassA(models.Model):    
    _name = 'module.class_a'    
    
    CYCLE = 'cycle'   
    AMOUNT = 'amount'   
    Other = (        
        (CYCLE, 'Cycle'),        
        (AMOUNT, 'Amount')    
    )    
    name = fields.Char(string='Name', required=True)   
    other_influence = fields.Selection(Other, string='Other influence', required=True)   
    related = fields.One2many('module.class_b', 'components')   
    
    @api.onchange('other_influence')    
    def _other_influence_change(self):        
        self.related = None       
        if self.other_influence == self.CYCLE:            
            b = {               
                'name': 'XXX', # Lets say we do generate something here, hardocded just to show the problem
            }           
            self.related += self.related.new(b)
    
class ClassB(models.Model):   
    _name = 'module.class_b'   
    
    name = fields.Char(string='Name', required=True)   
    components = fields.Many2one('module.class_a', ondelete='no action')

When user create new entry for ClassA in view I would expect when clicking on Other influence dropdown and select Cycle in new XXX will appear in related, however what happen is that a new blank line appear, and when trying to save it ends up with error.

openerp.sql_db: bad query:  SELECT "module_class_b"."components" as "components","module_class_b"."id" as "id" FROM "module_class_b"
                        WHERE "module_class_b".id IN ('one2many_v_id_53')  ORDER BY "module_class_b"."id"

I know the difference betweem new and create, but if I change new to create in line

self.related += self.related.create(b) 

and click at Other influence field view works fine and new row is added, e.g. Name field contains XXX. Save works as well, but this is obviously bad setup as each click on Other influence would create and entry in DB (but works, both updated view and also store, but create shouldn't be used here instead on new).

I would like to click at Other influence field in view function _other_influence_change is triggered with

self.related += self.related.new(b)

and new row is added in view, and it shows data from variable b, eg. Name field contains XXX. And save to the DB successfully once user pres the save button.

I have tried to look for existing bugs and also advises how to do it properly but nothing doesn't seems to work, colleague of mine told me that this has worked fine in v8.x. Thanks for the advises.

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
Specifing FK and PK in One2many relation in v15 via Studio
one2many many2one custom field
Avatar
0
Kas 22
132
[Odoo13][Form view - many2one / one2many] Display problem on my one2many field, in my project module form view
one2many many2one custom field
Avatar
Avatar
2
Ağu 20
3559
How can i change the displayed value of a custom many2one selection field?
one2many many2one custom field
Avatar
0
Mar 15
4283
show One2Many field list base another model field
one2many one2many many2one custom field
Avatar
Avatar
Avatar
2
May 25
3098
How to automatically fill all records from one2many tree view of model b into one2many tree view of model a? (Odoo 13) Çözüldü
relationship many2one_list one2many_list one2many many2one custom field Odoo13
Avatar
1
Eki 23
5686
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