Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

Display name w/ default_code not showing when adding lines to Sales Order

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
2 Risposte
1731 Visualizzazioni
Avatar
Frank Sandqvist

Hi,

I am resorting to the forum as I'm at my wits end as to why this is happening. It seems to have started happening after upgrading to Odoo 18

My issue is that display_name is not working as I'd expect.

If I edit the product, it appears as I'd like ([default_code] name)

Screenshot: https://drive.google.com/file/d/1uBE3QdlUmqllqBtq8RN3TOk0QCNGEaLB/view?usp=sharing


When I browse the product in the sol_product_many2one widget, they are appearing

Screenshot: https://drive.google.com/file/d/1i-IV2Uq-iYCbtXP8unByj3f2nJv5pnL1/view?usp=sharing


But - when I add the product it just disappears.

Screenshot: https://drive.google.com/file/d/1ngwsDimqb6VQfnMJpdu9R-tbWHSA4LH8/view?usp=sharing


It also does not show on PDF quotes / order confs. 


Is this new default behaviour that I need to fix manually with Odoo 18, or is something not configured right? I tried to investigate the sol_product_many2one but it's a bit too dense for me. I also checked the "name" column in the sale_order_line table, and that indeed does not include the default_code.


Thank you so much in advance!

0
Avatar
Abbandona
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Risposta migliore

Hi,

In Odoo 18, the behavior of product names changed: the display_name (which shows [default_code] name) is now only used for UI display and is not automatically copied into the sale order line’s name field. This is why the product appears correctly in the widget but disappears after selection and doesn’t show in PDFs. To restore the old behavior, you can override the product_id onchange in sale.order.line so that the name field stores the display name.


Code:

from odoo import models, api


class SaleOrderLine(models.Model):

    _inherit = 'sale.order.line'


    @api.onchange('product_id')

    def _onchange_product_id_custom(self):

        res = super(SaleOrderLine, self)._onchange_product_id()

        if self.product_id:

            self.name = self.product_id.display_name or self.product_id.name

        return res


Hope it helps.

0
Avatar
Abbandona
Avatar
Banibro IT Solutions
Risposta migliore

What’s Happening in Odoo 18

  1. display_name no longer includes [default_code] name automatically everywhere.

    • In Odoo 17 and earlier, the default behavior was for display_name to return [default_code] name if default_code existed.

    • In Odoo 18, the logic for display_name is not used consistently across all widgets or record displays anymore. Some widgets like sol_product_many2one still use it, but fields like product_id.name or report lines may now rely on name or direct database values that exclude default_code.

  2. On the Sale Order Line (SOL), the name field is manually computed.

    • This field is populated during product_id_change() or _compute_product_id_change().

    • It does not include [default_code] unless you explicitly add it to the logic.

  3. PDF reports and quotes depend on the sale.order.line.name field.

    • If default_code isn’t part of that field, it won’t appear on your documents.

 How to Fix It

You need to override the behavior that generates the sale order line name to include the default_code. This will make it show up correctly in:

  • The form view

  • The PDF/print report

  • Any related downstream record

 Override product_id_change in a custom module or via Studio (dev mode)


from odoo import models


class SaleOrderLine(models.Model):

    _inherit = 'sale.order.line'


    def _compute_product_id_change(self):

        super()._compute_product_id_change()


        for line in self:

            if line.product_id:

                product = line.product_id

                default_code = product.default_code or ''

                name = product.name or ''

                display_name = "[%s] %s" % (default_code, name) if default_code else name

                line.name = display_name


 Fix PDF Quotes/Reports

Ensure your QWeb report template uses line.name and not just product_id.name. You don’t have to change this if you fix the name field as shown above — but just double-check.

 Why This Changed in Odoo 18?

Odoo 18 leans more toward modular, explicit control over display logic — likely to reduce performance overhead and simplify translation and customization. However, it means you have to manually define where and how you want default_code included.

Summary of What You Should Do

  •  Override _compute_product_id_change() to customize how name on sale.order.line is populated.

  •  Confirm your report template pulls from line.name, not product_id.name.

  •  Don’t rely solely on display_name anymore — it's not consistently used in PDF/reporting contexts.

0
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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