Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

How to populate a dropdown list with a custom field?

Odoberať

Get notified when there's activity on this post

This question has been flagged
viewsdropdowndropdownlistdropdownmenuodoov12
3 Replies
10675 Zobrazenia
Avatar
Sameer Ahmad

Hello,

Generally when a many2one field is declared and a model is referred to, this dropdown list populates the entries from the field name but i want to populate the drop down list with a custom field say companyName. How can i achieve this? Can anyone refer me to some example..

Thanks

0
Avatar
Zrušiť
Avatar
Gagea Alexandru
Best Answer

Hello,


Example of dropdown list from another model.


.py file : 


class ResPartner(models.Model):

    _inherit = 'res.partner'

software = fields.Many2one('partner.software', string='Software')

#this is the dropdown list


class PartnerSoft(models.Model):

    _name = 'partner.software'

    _description = 'Software'


    software = fields.Char('Soft')

    _rec_name = 'software'

#this is where I save my custom values

xml file for the dropdown list : 


        <record id="res_partner_form_view_extension" model="ir.ui.view">

            <field name="name">res.partner.form.view.extension</field>

            <field name="inherit_id" ref="base.view_partner_form"/>

            <field name="model">res.partner</field>

            <field name="priority" eval="2"/>

            <field name="arch" type="xml">

                <xpath expr="//field[@name='lang']" position="after">

                    <field name="software"/>

                </xpath>

            </field>

        </record>



xml file for the second model where you store the dropdown list values: 


<odoo>

    <data>


        <record id="res_partner_soft_form_view" model="ir.ui.view">

            <field name="name">res.partner.soft.form.view</field>

            <field name="model">partner.software</field>

                <field name="arch" type="xml">

                    <form>

                        <sheet>

                            <div>

                                <label for="soft" string="Software" class="oe_edit_only"/>

                                <h1><field name="software"/></h1>

                            </div>

                        </sheet>

                    </form>

                </field>

        </record>


        <record id="res_partner_soft_tree_view" model="ir.ui.view">

            <field name="name">res.partner.soft.tree.view</field>

            <field name="model">partner.software</field>

            <field name="arch" type="xml">

                <tree string="software">

                    <field name="software"/>

                </tree>

            </field>

        </record>


        <record id="res_partner_soft_search_view" model="ir.ui.view">

            <field name="name">res.partner.soft.search.view</field>

            <field name="model">partner.software</field>

                <field name="arch" type="xml">

                    <search string="Software">

                        <field name="software"/>

                    </search>

                </field>

        </record>


        <record model="ir.actions.act_window" id="partner_soft_action">

            <field name="name">Software</field>

            <field name="res_model">partner.soft</field>

            <field name="view_mode">tree,form</field>

            <field name="view_id" ref="res_partner_soft_tree_view"/>

            <field name="view_type">form</field>

            <field name="search_view_id" ref="res_partner_soft_search_view"/>

       </record>



        <menuitem id="partner_soft_menu_item"

          name="Software"

          action="partner_soft_action"

          parent="contacts.menu_contacts"/>


    </data>

</odoo>

0
Avatar
Zrušiť
Avatar
Mitul Shingala
Best Answer

Hello

you can achieve this using the

1. override the name_get() or

2. using the _rec_name = "<field-name>".  for eg. _rec_name = 'company_name'


0
Avatar
Zrušiť
Sameer Ahmad
Autor

Below is how i tried and it didn't work... Did i miss something?

class AccountAnalyticAccount(models.Model):

_inherit = 'account.analytic.account'

_rec_name = 'inHeader'

inHeader = fields.Char(string='Company Name', required=True)

class headerSelection(models.Model):

_inherit = 'account.invoice'

headerSelect = fields.Many2one('account.analytic.account', string="Company Name", required=True)

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

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Populate menuitem with custom field
views menuitem dropdown dropdownlist dropdownmenu
Avatar
0
mar 23
2147
How to make a field appear in drop down list? Solved
views fields many2one dropdownlist odoov12
Avatar
Avatar
4
mar 19
8549
How to show icons/images in drop down
views icons dropdown
Avatar
Avatar
Avatar
2
nov 16
7555
Populate product from puchase order line in drop down
wizard dropdownlist dropdownmenu odoo12
Avatar
0
máj 20
3628
How to add a field in an inherited group? Solved
views fields xpath odoov12
Avatar
Avatar
Avatar
Avatar
5
aug 19
10438
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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