Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

How to change the values for a selection field?

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
selection
9 Replies
54672 Tampilan
Avatar
Luigi Sison

How can I create, update or delete values for a selection field?

For example, a selection field has allowable values: value1, value2

How can I add value3?

1
Avatar
Buang
Luigi Sison
Penulis

How can I do this in the SaaS instance?

Ivan

Luigi, unfortunately, AFAIK, you cannot do any of those answers in SaaS instance. You need to do some development.

Ivan

You can, alternatively, create a new selection field to capture the 3rd (and 4th, etc.) selection. But it will be informational only.

Avatar
Ivan
Jawaban Terbai

There are 3 ways to provide selection list values that is accepted by OpenERP:

  1. Specifying directly in the field.selection definition: 'field_1': fields.selection([('value1', 'String 1'), ('value2', 'String 2')], 'Field Label')
  2. Specifying using a name list variable outside of the field.selection definition: 'field_1': fields.selection(LIST_VARIABLE, 'Field Label').  Where LIST_VARIABLE is defined beforehand: LIST_VARIABLE = [('value1', 'String 1'), ('value2', 'String 2')]
  3. Specifying using a method: 'field_1': fields.selection(_method_name, 'Field Label').  Where _method_name is defined beforehand:

def _method_name(self, cr, uid, context=None):

    return [('value1', 'String 1'), ('value2', 'String 2')]

Now, you need to check first which one is your current selection field is.  If it is using method No. 1, then you need to redefine it to use either method No 2 or method No 3.  If it is using method No. 2 or 3, you just need to change either the variable (you can use LIST_VARIABLE.append(('value3', 'String 3'))) to return the new value.

5
Avatar
Buang
Avatar
Atul Makwana
Jawaban Terbai

Selection field allows static value in list of tuples

    registration_state = fields.Selection([('select_1', 'One'), ('select_2', 'Two'), ('select_3', 'Three')], 'Select')

in that you can not add values.

so the solutions is to add a many2one field, which allows you to add value in it.  for that you need to define a new model of your selection.

class selection_selection(models.Model):
    _name = 'selection.selection'
    
    name = fields.Char('Name', required=True)
    value = fields.Char('Value', required=True)
    
now in your class you need to add many2one field which is referencing to your selection model like,

class your_model(models.Model):

    _name = 'your.model'
    
    my_selection = fields.Many2one(selection.selection, Selections)
    
now in xml file while defining the fields you need to add a widget to your selection field like,

    <field name="my_selection" widget="selection" />


to configure the selections you can make menu under configuration as per your need.

hope this helps.

7
Avatar
Buang
Ivan

@Atul you can make selection field to have a somewhat dynamic (can be changed by other modules) list of values as I've stated in my answer. Also (and thus), the choice of using either many2one and selection fields does not only lies on the capability to add values. Further details on the differences between many2one and selection fields are elaborated in my answer here: https://www.odoo.com/forum/help-1/question/best-practices-as-to-when-to-use-fields-selection-vs-fields-many2one-69262

Atul Makwana

Obviously we can make it dynamic selection field. Thanks for the comment @Ivan.

Avatar
john5000
Jawaban Terbai

Hi Luigi,

There are two kinds of "selection" fields, so there are two ways that the values are managed.

The one that is defined as "fields.selection(...)" [defined in the .py file, the model] has values defined there in a comma seperated list.  In this case you add the new value to the list in the .py file.

Or a field can be defined as a one to many2one(...), in which case the line that defines it in the .py file will indicate what table has the values. Usually use can add new values from the interface on this type of field.

 

 

1
Avatar
Buang
Avatar
Pragnesh Mistry (pmi)
Jawaban Terbai

you can use list to add item dynamically in fields.Selection

cnt=0
list1=[]
for i in range(1900,2017):
         list1.append((str(cnt),str(i)))
         cnt=cnt+1

class Employee(models.Model):

    _name = 'employee.details'
    year=fields.Selection(list1, string='Years', required=True, copy=True)

0
Avatar
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
how to add values dynamically in selection fields? Diselesaikan
selection
Avatar
Avatar
Avatar
Avatar
Avatar
4
Des 23
23272
Dynamically change choices in selection fields Diselesaikan
selection
Avatar
Avatar
Avatar
Avatar
Avatar
5
Jul 24
16671
Working with fields.selection values Diselesaikan
selection
Avatar
Avatar
1
Jun 22
28381
How to get values from a radio button in a Selection
selection
Avatar
0
Jul 20
3768
Changing field selection data on change event
selection
Avatar
0
Mar 20
4467
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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