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
    • Discuss
    • 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

[v10] Pass active_id through button to fill fields

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
actionmany2onebuttonautocompleteactive_id
9 Replies
10433 Tampilan
Avatar
Bastien Bascou

Hello !

I get troubles to fill fields of my model opened in edit form view.

Here are some screens of the usecase :

http://imgur.com/G1ptWXN

http://imgur.com/lWrrDRj

http://imgur.com/1FvI25l

In the URL, I can see the active_id (or active_ids) of my products on the second screenshot. But my trouble is in filling the field Article with them (WITHOUT saving it : I want the user to choose to save or not)

Here is the code of my "new" button action right now :


def new_match(self):
    return{
        'name':("Save a new matching"),
        'view_mode': 'form',
        'view_type': 'form',
        'view_id': False,
        'res_model': 'label.label',
        'res_id': self.id,
        'type': 'ir.actions.act_window',
        'target': 'current',
        'domain': '[]',
        'flags': {'initial_mode': 'edit',} ,
        '_default':{'products':[(6,0,[self._context.get('active_ids')])]},
  }

I tried a lot of stuff that didn't work, without giving me any error or stuff. I'm a bit lost here

If someone could give me solution or part of it that'd be great ! :)

Thanks !

0
Avatar
Buang
Bastien Bascou
Penulis

The code of my list view :

<record model="ir.ui.view" id="label.tree_new_match">

<field name="name">Create Matching</field>

<field name="model">label.label</field>

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

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

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

<tree colors="red:status=='OFFLINE';black:len(products)!=0;green:len(products)==0" default_order='len_products, real_id' create='false' delete='false'>

<button string="New" type="object" name="new_match"/>

<field name="description" string="Name"/>

<field name="real_id"/>

<field name="type"/>

<field name="products"/>

<field name="status"/>

<field name="len_products" invisible="context.get('len_products')!=1000"/>

</tree>

</field>

</record>

Avatar
Bastien Bascou
Penulis Jawaban Terbai

The only way i found to do this was to set the fields direclty in the action function, but that doesn't do what i wanted to do at first :'(

0
Avatar
Buang
Avatar
Keyur Gajjar (kga)
Jawaban Terbai

Hello Bastein,

You need to pass the context here instead of '_default':

    e.g. 'context': {},

And in context you need to pass fields which you want to set defaults with 'default_' prefix.

in your case its like 

    'context': {'default_partners': [(6,0, active_ids)]}, 

0
Avatar
Buang
Bastien Bascou
Penulis

Hi ! Thank you for the answer

I got the error : NameError: global name 'active_id' is not defined

when I put it between '' no mistakes but doesn't work.

Keyur Gajjar (kga)

sorry, my bad. Try using self.env.context.get('active_ids') instead of active_ids.

Bastien Bascou
Penulis

Still doesn't work, i tried with self._context.get('active_ids') as well,replacing active_ids by active_id etc ...

Do I need to pass values trough context of my tree view ?

Keyur Gajjar (kga)

Yeah you need to pass that active_id in the context when clicking on the action in 'More' dropdown. which will be propagated to the "New" button action's context.

Bastien Bascou
Penulis

Is it automatically propagated ? because as i said in my original post, in the url the active_id on my second screenshot is the products i want to match with my label, but in the third screenshot the active_id is the label itself. so i'm scared that i can't use the active_id of the product anymore at this point.

Bastien Bascou
Penulis

Ok got some news :

def new_match(self):

context=self._context.copy()

if context.get('active_ids'):

context.update(default_products=[(6,0,context.get('active_ids'))])

else:

context.update(default_products=[(6,0,context.get('active_id'))])

return {

'name':_("Save a new matching"),

'view_mode': 'form',

'view_type': 'form',

'view_id': False,

'res_model': 'label.label',

'res_id': self.id,

'type': 'ir.actions.act_window',

'target': 'current',

'domain': '[]',

'context': context,

'flags': {'initial_mode': 'edit',},

}

with this action button, I manage to get the active_ids of my products in the 3rd screenshot. But still nothing filled where it should be. :)

Thank you again !

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
Active id Bug in odoo v15
action active_id
Avatar
0
Mei 22
3169
action button is disabled in the list view Diselesaikan
action button
Avatar
1
Mar 21
5615
How set STATE=DONE? (Action & Button)
action button
Avatar
Avatar
Avatar
3
Mar 15
11223
How to change string of the button without altering its action
action button string
Avatar
Avatar
Avatar
2
Feb 23
4373
Custom back button no longer working. Diselesaikan
action button customization
Avatar
2
Okt 20
6804
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