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

name_search is not working for Many2oneReference field

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
V18Many2oneReference
2 Cevaplar
853 Görünümler
Avatar
Ihor

I'm using Odoo 18. I have the following models:

  • document.foo

class FooDocument(models.Model):

  _name = 'document.foo'

  _description = 'Foo'


  date = fields.Datetime(

    string='Date',

  )

  number = fields.Char(

    string='Number',

  )

  • document.bar

class BarDocument(models.Model):

  _name = 'document.bar'

  _description = 'Bar'


  date = fields.Datetime(

    string='Date',

  )

  number = fields.Char(

    string='Number',

  )

  • document.invoice
class InvoiceDocument(models.Model):
  _name = 'document.invoice'
  _description = 'Invoice'

  date = fields.Datetime(
    string='Date',
  )
  number = fields.Char(
    string='Number',
  )
  doc_base_name = fields.Selection(
    string='Base Document Type',
    selection=[
      ('document.foo', 'Foo'),
      ('document.bar', 'Bar'),
    ],
    default='document.foo',
  )
  doc_base_id = fields.Many2oneReference(
    string='Base Document',
    model_field='doc_base_name',
  )

Also, I have the following view for document.invoice​​

<record id="document_invoice_view_form" model="ir.ui.view">

<field name="name">document.invoice.form</field>

<field name="model">document.invoice</field>

<field name="arch" type="xml">

<form>

<sheet>

<group>

<field name="date" />

<field name="number" />

<field name="doc_base_name" />

<field name="doc_base_id" />

</group>

</sheet>

</form>

</field>

</record>

Then, I am doing the following actions in the Odoo web interface:

1.Creating new records of document.foo​​

2.Creating a new record of document.invoice

*Choosing Foo value in the doc_base_name (Base Document Type) field

*Trying to choose a value in the doc_base_id (Base Document) field, but there are no values. name_search​ method doesn't return values

How to solve this problem with doc_base_id (Many2oneReference) field?

1
Avatar
Vazgeç
Ihor
Üretici

Thank you for your answers! It turned out the reason was the old version of my 18.0 branch from Github. The problem disappeared after pulling current version.

Avatar
Christoph Farnleitner
En İyi Yanıt

Your example source works perfectly fine in terms of having the Many2oneReference field be a (M2o-)selection of Foo or Bar:


The name_search in fact would in your case return always all values - because there just isn't any definition of what an entered name should be searched against (since there's no name field).

If you would, for example, set a _rec_name on the Foo and Bar models (or define an name, or a computed display_name), i.e.

class DocumentFoo(models.Model):
    _name = 'document.foo'
    _description = 'Foo'
    _rec_name = 'number'

    date = fields.Datetime(string='Date', )
    number = fields.Char(string='Number', )

 

also your name_search would actually return a 'filtered' result.

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

Hi,

You need to give document.foo and document.bar models a way to represent themselves.


If you want to use the existing number field as the record name:


class FooDocument(models.Model):

    _name = 'document.foo'

    _description = 'Foo'

    _rec_name = 'number' # <--- Add this


    date = fields.Datetime(string='Date')

    number = fields.Char(string='Number')



class BarDocument(models.Model):

    _name = 'document.bar'

    _description = 'Bar'

    _rec_name = 'number' # <--- Add this


    date = fields.Datetime(string='Date')

    number = fields.Char(string='Number')



This way, when you open the dropdown for doc_base_id, Odoo will display the number values of Foo/Bar records.


Hope it helps.

1
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
Hide 'Apps' module from the HOME screen for users not set as 'Administrators'. Çözüldü
V18
Avatar
Avatar
1
Haz 25
2178
Truenas Official docker odoo self hosted image no persistancy
V18
Avatar
1
May 25
2488
Import Products - Internal Notes Çözüldü
products V18
Avatar
Avatar
Avatar
2
Eyl 25
633
Error (Real-time connection lost) Odoo 18 Community Çözüldü
V18 Odoo 18
Avatar
Avatar
Avatar
Avatar
Avatar
12
Eyl 25
32836
Inventory Adjustments - Importing File Çözüldü
InventoryAdjustment V18
Avatar
Avatar
Avatar
3
Eyl 25
2158
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