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

Giving value to the selection field

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
valuesselectionmany2manyselect
5 Replies
9212 Tampilan
Avatar
Nazrin Guliyeva

Hey guys,

I am sending a post request to the res.partner model. And I want to give value to category_id which is selection field (many2many). How I can achieve it?

My code is below:

id = models.execute_kw(db, uid, password, 'res.partner', 'create', [{
'name': name, 'x_customer_register_date': my_date, 'x_customer_id': customerId, 'category_id': tags,
'zip': postcode, 'street': address,
}])



0
Avatar
Buang
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Jawaban Terbai

Hi,

Follow the below syntax for filling the values to many2many fields.


(0, 0, { values }) link to a new record that needs to be created with the given values dictionary

(1, ID, { values }) update the linked record with id = ID (write values on it)

(2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)

(3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)

(4, ID) link to existing record with id = ID (adds a relationship)

(5) unlink all (like using (3,ID) for all linked records)

(6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)

5
Avatar
Buang
Avatar
Haresh Kansara
Jawaban Terbai

Hi Nazrin,

There are basically two way to add record to many2many field.

1) Add existing created record to many2many field

- Add single record:

tags = [(4, EXISTING_RECORD.id)]

'category_id': tags,

- Add multiple records:

tags = [EXISTING_RECORD1.id, EXISTING_RECORD2.id, EXISTING_RECORD3.id, EXISTING_RECORD4.id, EXISTING_RECORD5.id]

'category_id': [(4, tag, None) for tag in tags]


2) Create new record and add to many2many field


tag_vals = {
'name': "Tag-1",
}

'category_id': [(0, 0, tag_vals)]


For about how to fill value to x2many field: https://odoo-development.readthedocs.io/en/latest/dev/py/x2many.html

I hope it will helpful for you

Thanks and regards
Haresh Kansara

1
Avatar
Buang
Avatar
shalin wilson
Jawaban Terbai

https://odoo-development.readthedocs.io/en/latest/dev/py/x2many.html

1
Avatar
Buang
shalin wilson

first read the doc and do like eg: 'x_id': [(6, 0, tax_ids)],

Haresh Kansara

6,0 will replace remove existing tags add new added tags. So i suggest to use 4,0 to add

shalin wilson

yeah thanks and i thought the person would go through the link to understand each,else they might ask how to remove on next question and so on

shalin wilson

Many2many fields always have an intermediary table where it's stored the foreign keys of the two tables, the actual were the field is m2m defined and the pointed table of the m2m field. Using that table the records of the other table can be retrieved. The following is a definition of a many2many field with the intermediary table in bold

invoice_line_tax_id = fields.Many2many('account.tax', 'account_invoice_line_tax', 'invoice_line_id', 'tax_id', string='Taxes', domain=[('parent_id', '=', False)])

In the case of the payment_ids of the model account.invoice it's a computed field so the records of the other table are retrieved using a the function _compute_payments of the account.invoice. The computed m2m fields don't have an intermediary table

Avatar
Nazrin Guliyeva
Penulis Jawaban Terbai

It is string in my variable, like B2B or B2C

and I want to choose accordingly, so in my case the solution above is not working

0
Avatar
Buang
shalin wilson

many2many field right?

it stores ids in both side so u have to write the ids

shalin wilson

find id of B2B and B2C and store it

Nazrin Guliyeva
Penulis

for small stuffs like B2B or B2C i did now like this. But there is one problem now. Now I want to do orders and connect it with customers, there is field which is one2many and I need to choose customer's id. And the number of customers are extremely big. In this case, what should I do?

Nazrin Guliyeva
Penulis

many2one sorry

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
Open record selection form for One2Many-Field on button click Diselesaikan
selection many2many ir.actions.act
Avatar
Avatar
1
Nov 24
3069
LINK A SELECTION FIELD SELECTION LIST WITH VALUES OF MANY2MANY FIELD
selection many2many onchange
Avatar
0
Jul 20
3956
Create new many2many type field based on selection type field value ?
selection many2many convert
Avatar
0
Jun 19
3913
SELECT QUERY ON SELECTION FIELD
selection sql select
Avatar
0
Des 16
5377
Dynamic values in Select fields
fields selection dynamic select
Avatar
Avatar
Avatar
2
Nov 23
5742
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