Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

How to Concatenate First and Last Names into a Full Name Field in Odoo

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
fieldsconcatenatev17
1 Balas
4091 Tampilan
Avatar
Christophe

Hi all, 

I looked around but couldn't really find the full answer. I created two fields: x_studio_firstname and x_studio_lastname. Now, I need to combine these two into the x_studio_fullname field. 

I believe I have the code to do this but don't know where to put it in Odoo to fully test it. 

I read somewhere that I could change the complete_name field so that this field is generated with the custom fields. But again, I have no clue where to edit this in Odoo. Can someone point me in the right direction or provide documentation?

def name_get(self):
    res = []
    for record in self:
        name = record.x_studio_Firstname + ' ' + record.x_studio_lastname
        res.append((record.id, name))
    return res

x_studio_fullname = fields.Char(string="Full Name", compute='_compute_full_name', store=True)

@api.depends('x_studio_Firstname', 'x_studio_lastname')
def _compute_full_name(self):
    for record in self:
        record.x_studio_fullname = record.x_studio_Firstname + ' ' + record.x_studio_lastname

0
Avatar
Buang
Ray Carnes (ray)

Would it not be easier to customize the emails and/or reports to show full name? I can't imagine your back end Users need to see the full name?

Christophe
Penulis

That's just it. We don't need the full name in emails or contact with customers, only the first name. If we use the standard Odoo name field, it's the full name. So we could only use that for the first name and add a last name studio field. But that doesn't seem very handy to have a contact overview to show the full name. I added the extra field in the contact layout (via studio) but that doesn't really work. We need separate fields for the first and last name and show the full name via those fields. We thought it was basic, but it seems in Odoo that this isn't standard.

Avatar
Synodica Solutions Pvt. Ltd.
Jawaban Terbai

Hello,

At Synodica, we specialize in customizing Odoo to fit your business needs. Concatenating the first and last names into a full name field is a common requirement. Here’s a step-by-step guide to achieve this in Odoo:

Step-by-Step Guide to Concatenate First and Last Names

  1. Create a Compute Field: You can create a computed field in the res.partner model to hold the full name.
  2. Modify the res.partner Model: Create a custom module or modify an existing one to add this computed field. Here’s an example of how you can do this:
from odoo import models, fields, api

class ResPartner(models.Model):
    _inherit = 'res.partner'

    full_name = fields.Char(string='Full Name', compute='_compute_full_name', store=True)

    @api.depends('name', 'last_name')
    def _compute_full_name(self):
        for partner in self:
            partner.full_name = f"{partner.name or ''} {partner.last_name or ''}".strip()

3. Update the Views: Update the views to display the new full_name field. You can add this field to the form and tree views as follows:



  1. Install/Update the Module: Install or update your custom module to apply these changes.

Explanation:

  • Computed Field: The full_name field is a computed field that depends on name (first name) and last_name. The @api.depends decorator ensures that the full_name is recomputed whenever name or last_name changes.
  • String Concatenation: The f"{partner.name or ''} {partner.last_name or ''}".strip() part concatenates the first and last names, handling any None values by substituting them with empty strings.
  • View Inheritance: The view inheritance XML adds the full_name field to the form and tree views right after the name field.

By following these steps, you’ll be able to display the full name of your contacts in Odoo.

Hope this helps!

2
Avatar
Buang
Christophe
Penulis

Strange that if it's a common requirement it's not standard in Odoo. The step-by-step guide was very helpful. Thanks. I still didn't get it to work, but I now know where to look and learn this the trial and error way.

Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
How to concatenate fields in a view? Diselesaikan
fields concatenate
Avatar
Avatar
Avatar
Avatar
Avatar
8
Apr 25
29747
Is it possible to concat two tags
fields tags concatenate
Avatar
Avatar
1
Mar 22
2969
Ya es posible hacer Upgrade de v17 a v17.1 ?
v17
Avatar
Avatar
1
Okt 25
1263
How to add a new Many2one field in res.config.settings? Diselesaikan
v17
Avatar
Avatar
Avatar
Avatar
4
Okt 25
3620
Add field to ALL models in Odoo
v17
Avatar
Avatar
Avatar
2
Sep 25
2293
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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