Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Edit dropdown in sales module

Naroči se

Get notified when there's activity on this post

This question has been flagged
salesproductdropdownodoo18
3 Odgovori
131 Prikazi
Avatar
Agent

Is it possible to change the field display_name in the sales dropdown in sales where the product to add to the order line is selected? The standard Odoo shows `display_name`, which is `default_code` + the product name. I want to know if it's possible and how to change for another different compute field instead to show in the dropdown in odoo 18
I'm trying to concatenate more fields so that they display in the dropdown without affecting other modules that use the product's display_name

0
Avatar
Opusti
Codesphere Tech

Hello,
Yes you can inherit the name_search for that and update it as per your needs

Avatar
Kunjan Patel
Best Answer
Hello Agent,
I hope you are doing well

models/product.py
from odoo import models, api
class ProductProduct(models.Model):
     _inherit = 'product.product'

      @api.depends_context('show_sale_display')
      def _compute_display_name(self):
          if self.env.context.get('show_sale_display'):
              for rec in self:
                 rec.display_name = f"[{rec.default_code or ''}] {rec.name} | ${rec.list_price:.2f}"
          else:
              super()._compute_display_name()

  views/sale_order_view.xml
  <?xml version="1.0" encoding="UTF-8"?>
  <odoo>
      <record id="view_order_form_custom_display" model="ir.ui.view">
          <field name="name">sale.order.form.custom.display</field>
          <field name="model">sale.order</field>
          <field name="inherit_id" ref="sale.view_order_form"/>
          <field name="arch" type="xml">
              <xpath expr="//field[@name='order_line']/list/field[@name='product_id']" position="attributes">
                  <attribute name="context">{'show_sale_display': True}</attribute>
              </xpath>
          </field>
      </record>
  </odoo>

Result:  Sale shows [ABC123] Product Name | $99.99 other modules show default.

I hope this information helps you

Thanks & Regards,
Kunjan Patel
0
Avatar
Opusti
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer
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

1
Avatar
Opusti
Avatar
Agent
Avtor Best Answer

thank you all!!

0
Avatar
Opusti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Suggestions for Odoo Product Module Enhancement: Dynamic Combination Sets and Combination Product Interface Optimization
sales product odoo18
Avatar
0
dec. 24
309
Conditionally show or hide product attributes (Odoo Online/Studio)
sales product
Avatar
Avatar
1
okt. 25
710
Hide the cost
sales product
Avatar
Avatar
Avatar
2
maj 25
4556
Products in multi company
sales product
Avatar
0
nov. 24
1537
how to filter out all products which got no sales with the last 3 months or a specific period?
sales product
Avatar
Avatar
1
avg. 24
2363
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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