Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

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

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
fieldsconcatenatev17
1 Odpowiedz
4083 Widoki
Awatar
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
Awatar
Odrzuć
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
Autor

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.

Awatar
Synodica Solutions Pvt. Ltd.
Najlepsza odpowiedź

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
Awatar
Odrzuć
Christophe
Autor

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.

Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
How to concatenate fields in a view? Rozwiązane
fields concatenate
Awatar
Awatar
Awatar
Awatar
Awatar
8
kwi 25
29744
Is it possible to concat two tags
fields tags concatenate
Awatar
Awatar
1
mar 22
2961
Ya es posible hacer Upgrade de v17 a v17.1 ?
v17
Awatar
Awatar
1
paź 25
1262
How to add a new Many2one field in res.config.settings? Rozwiązane
v17
Awatar
Awatar
Awatar
Awatar
4
paź 25
3610
Add field to ALL models in Odoo
v17
Awatar
Awatar
Awatar
2
wrz 25
2277
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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