Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

grid like multi column dropdown selection

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
5 Besvarelser
4877 Visninger
Avatar
Simon Lee

I am using odoo 9. I would like to find a way to show 2 columns on a dropdown selection. For instance, when clicking on the lot_name field in the stock.pack.operation.lot tree view, I would like to show the lot_name and the available_qty of a product in the dropdown list, similar to the grid-like-multi-columm-combo box in the following link (https://www.obout.com/combobox/aspnet_columns_grid.aspx). Is it possible to have such grid-like-multi-columm-combo box in odoo? If yes, where can I find some examples and tutorial. Thanks.

Simon Lee

0
Avatar
Kassér
Avatar
Simon Lee
Forfatter Bedste svar

Hengky Zhang, thank you for your answer. I finally have time to try this out but I ran into this problem.

Here's my code:

.py file:
class my_stock_production_lot(models.Model):
    _name = 'stock.production.lot'   
    _inherit = 'stock.production.lot'    
    product_available_qty=fields.Float(string='Quantity Available', related='product_id.qty_available')           

    @api.multi   
    def name_get(self):
        res = []       
        for lot in self:
            if lot.name:                  
                display_value = lot.name               
                if lot.product_available_qty > 0:
                    display_value += ' ['                   
                    display_value += '%.0f Units' % lot.product_available_qty                   
                    display_value += ']'               
                res.append((lot.id, display_value))        
        return res

.xml file:
<record id="view_pack_operation_lot_form_inherit" model="ir.ui.view">           
<field name="inherit_id" ref="stock.view_pack_operation_lot_form"/>           
<field name="model">stock.pack.operation</field>           
<field name="arch" type="xml">               
<xpath expr="//field[@name='pack_lot_ids']/tree/field[@name='lot_id']" position="replace">                   
<field name="lot_id" invisible="context.get('only_create', False)" 
        domain="[('product_id','=', parent.product_id)]"                                      
        context="{'product_id': parent.product_id, 'show_qty': True}"/>               
</xpath>           
</field>                   
</record>

My question:
1) Was I right on how to include 'show_qty' in the context of the .xml file?

2) I cannot reference  context in the name_get method. name_get cannot accepts a context parameter. When I checked the self._context variable in the debugger, I did not see {'show_qty': False}. I cannot  do "if self._context.get('show_qty'):..." either since it is a frozen dict. So how can I determine in name_get whether I should display the default name or my customize name[qty]???

Can you please explain possibly with example? Thanks.

0
Avatar
Kassér
Avatar
Hengky
Bedste svar

Yes you can, but not same 100%

you override method name search in that many2one object

so you can override the return value

for default odoo just return the name of the relation table, and what you need to need to substring that name with the quantity example odoo will return --> LOT001(10QTY) instead of LOT001

for selection field you should use method to get the content of that selectional field and use your logical code for the return

0
Avatar
Kassér
Simon Lee
Forfatter

Thank you for the idea. I have a question. If I override name_search and add qty to the name, all other functions that call name_search will see the name as LOT001(10 PCS), right? I don't want such global effect. Just want to show the name+qty in some specific view. How can I do that? Thanks.

Hengky

sorry the method should be name_get not name search ^_^

lucky you understand what i mean

yes that method is global, let me check it first is it possible for specific field

Hengky

yes it is possible for specific field friend,

you need to add the context in the field

<field name="product_id" context="{attribute_only':True}"/>

then in the name_get method put the IF statement if the context is True then bla bla bla

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

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

Tilmeld dig
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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