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

How to get the value(Char) of the first line in one2many field?

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
13 Cevaplar
9700 Görünümler
Avatar
Boby

I want to get the value(Char) of the first line in one2many field into my main form.

Any advice?


0
Avatar
Vazgeç
Avatar
Prakash
En İyi Yanıt

You can access one2many fields values using one2many filed name and dot notation. 

Example, In sale order main

rec =[ line.comment for line self.order_line]

The above rec variable get all lines comment data list.

To get first line.

rec =[ line.comment for line self.order_line]

line1 = rec[0]

To get particular line based on condition

rec =[ line.comment for line self.order_line if comment != False]

The above rec return list of sale order line id, based on above condition.

Edit based on your object,

@api.depends('certificate_of_competency_ids')
def _get_licence(self):
    first_line = self.env['hr.certificate.competency'].search([('id', 'in',     self.certificate_of_competency_ids.ids)], order='sequence, id', limit=1)
    if first_line and first_line.certificate_name_competency:
    self.licence = first_line.certificate_name_competency.name

class certificate_competency(models.Model):
    _name = 'hr.certificate.competency'
    _description = 'Certificate Competency'
    _order = 'coc_emp_id, sequence, id'
2
Avatar
Vazgeç
Boby
Üretici

how to make the condition when the data o2m field are empty? i dont know but i cant use this (if comment != False)

Boby
Üretici

Hi, Praksesh

I've tried the code.. But there is an error:

first_line = self.certificate_of_competency_ids.filtered(lambda line: min(line.sequence))

TypeError: 'int' object is not iterable

Boby
Üretici

Cool.. i can use that,

Thankyou very much Prakash.

Avatar
Ray Carnes (ray)
En İyi Yanıt

You can do this directly within Odoo (without writing custom code) by making a related field.


Check out how we do this for the Next Activity Summary field on a Lead/Opportunity:






activity_ids is a one2many field.

2
Avatar
Vazgeç
Boby
Üretici

can it show only one name of the first line in one2many field?

i mean, i make a field sequence widget="handle" so i can move it.. And if i move every data to the top of the line.. it show that data in my main form.

but i dont know if i make a related field i think all the data in o2m field will be showed and it will error?

Avatar
Odoo Mates
En İyi Yanıt

Hi,

You can get the value of the first line like this,

self.field_name[0] this will return you the id of the first line and if you need to access a particular field from it, self.field_name[0].name .


Thanks

1
Avatar
Vazgeç
Boby
Üretici

i tried the code.. but its error when there is no line in the o2m data.. how to make the condition when the data is empty?

Odoo Mates

self.field_name[0].name if self.field_name else ''

Boby
Üretici

Thankyou Odoo Mates, it solve the empty data problem. But i have another problem, i add <field name="sequence" widget="handle"/> in my o2m field so i can drag and drop the lines. but not every data in the first line that showed up on my main form.

sometimes when i move another data to the first lines, data in the second lines showed up on my main form

Prakash

Using order line sequence field you find first order line. Order lines min(line.sequence) find and get value.

Boby
Üretici

Hi Prakash.

I'm sorry but i don't understand what do you mean. Can you help me with it

Here is my code:

class employee(models.Model):

_inherit = 'hr.employee'

licence = fields.Char(string="Licence", compute="_get_licence")

certificate_of_competency_ids = fields.One2many('hr.certificate.competency', 'coc_emp_id', String="Certificate of Competency")

(Now i'm using below function)

@api.depends('certificate_of_competency_ids')

def _get_licence(self):

self.licence = self.certificate_of_competency_ids[0].certificate_name_competency.name if self.certificate_of_competency_ids else ''

class certificate_competency(models.Model):

_name = 'hr.certificate.competency'

_description = 'Certificate Competency'

coc_emp_id = fields.Many2one('hr.employee', string="Employee Name")

sequence = fields.Integer(string='Sequence', default=10)

certificate_name_competency = fields.Many2one('hr.certificate.competency.name', string="Certificate Name")

Prakash

updated the code, check it let me know if any issue.

Prakash

Updated answer, please check

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