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

using name_get how to shows two different display values?

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
4 Cevaplar
55100 Görünümler
Avatar
Prakash

I have two fields related with res.partner.addreess

_name = "contact_details"
_columns = {
        'contact_id': fields.many2one('res.partner.address', 'Contact Name'),
        'contact_address_id': fields.many2one('res.partner.address', 'Contact Address'),
 }

In the contact_details Form:-

Currently display

Contact Name --> Contact Name with address

Contact Address --> Contact Name with address

Actual Requirement

Contact Name --> Contact Name only

Contact Address --> Contact Name with address

Using name_get Is it possible using name_get to show contact Name and Contact Address in Field 1 and field 2 ???

Thanks

0
Avatar
Vazgeç
Niyas Raphy (Walnut Software Solutions)

See: https://www.youtube.com/watch?v=kzgjurEkemI

Sehrish

Hope this will helps: https://www.youtube.com/watch?v=qtoEE6IUZBw

Avatar
Yenthe Van Ginneken (Mainframe Monkey)
En İyi Yanıt

Hi all,

While the answer from Fabien is technically correct I've noticed something interesting. If you set the context on a field the name_get() function is only changed when you're in edit mode and atleast touched the field ones. If you're not in editable mode or didn't touch the field atleast once the context is not passed along to the name_get() function and thus it shows the default rec_name value. If you pass the context on the menuitem itself it will alter the name_get values as the context is set before the name_get() goes off. 

An example (tested in V12 & V13):

    <record id="your_action" model="ir.actions.act_window">
        <field name="name">Your action</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">res.partner</field>
        <field name="context">{'custom_search': True}</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="search_view_id" ref="your_view_search"/>
        <field name="help" type="html">
            <p class="oe_view_nocontent_create">
                Click to add a new record.
            </p>
        </field>
    </record>

def name_get(self): result = [] for record in self:
if self.env.context.get('custom_search', False):
# Only goes off when the custom_search is in the context values. result.append((record.id, "{} {}".format(record.name, record.address)))
else:
result.append((record.id, record.name))
return result

Regards,

Yenthe

6
Avatar
Vazgeç
Sugeesh Ps

I have used name_get() function and i could change the default value, But i need this change in only one many2one all the other many2one with the same relation should show the rec_name value. How can i make this possible ?

Nicolas de Moreau

Hi Yenthe, thanks for your answer. Maybe you could consider adding "return result" in the name_get. I know it's obvious but I copy-pasted it and it took me some time finding the error... ;-)

BT-amascherpa

Hi Yenthe, the Fabien solution works fines if you add: options={'always_reload': True} on the field, as stated on his answer. This way it works fine on edit and save mode

Avatar
Fabien Pinckaers (fp)
En İyi Yanıt

Yes, you must put a context on one of the two fields (in the view or in the field) and develop a name_get on thre res.partner object that returns different values according to the context.

OpenERP has already such an implementation for partners. This should work in your view, for v7:

<field name="contact_id"/>
<field name="contact_address_id" context="{'show_address': 1}" options='{"always_reload": True}'/>
10
Avatar
Vazgeç
omprakash

Hi Fabien Pinckaers , I have doubt regards passing context value in XML file . Can you please explain with example .

Mahmoud

now in odoo 14 it is partner_category_display

and it is not working when you set it to short

Avatar
Abegail Sanchez
En İyi Yanıt

Hi Fabien,

this helped me, thanks

this was he meant

def name_get(self,cr,uid,ids,context=None):
        if context is None:
            context ={}
        res=[]
        record_name=self.browse(cr,uid,ids,context)
        for object in record_name:

                if object.name
                   if context.get('show_address',False):
                          //name for contact_address_id field

                         res.append((object.id,object.name+object.address))
                  else:
                       //name for contact_id field                     

                      res.append((object.id,object.name))
        return res

0
Avatar
Vazgeç
Avatar
Brodynt IT
En İyi Yanıt

Hi everyone.
We're facing this issue as well, exactly the same as described by Yenthe, but although I see some comments saying it works, we've not managed to make it work, even playing with the 'always_reload' option. (Odoo 12!)

name_get function does not trigger unless you're in edit mode (talking about m2m and o2m in my case)

Example: wizard.compose.mail has a res.partner many2many field shown as tags to display the recipients of the email. If we search partners by emails in the m2m, it works in edit mode, but after we've selected any record it keeps showing as "Companyname, name". 

Context is properly set in an inherited name_get func, that works in other places, but not here. Always_reload option is also to set to True.

Got any idea?  BT-amascherpa replied saying it worked, but on which version? This used to work for me as well in v8 even without always_reload, but we've not managed to make it work in v12.

Thanks.



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