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

Manually create/delete lines in a form in a one to many field (Survey module)

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
surveyone2manyidinsertonchange
1 Balas
6813 Tampilan
Avatar
Mauricio Leon

I'm trying to create a line in a one to many field every time a checkbox button is clicked.

I added this button to the survey form view (from the Survey module) called nominative

The model is as folows

class survey_survey(models.Model):
    _inherit = 'survey.survey'
    nominative = fields.Boolean(string="Nominative survey", default=False)

And this is the view

<record id="survey.survey_form2" model="ir.ui.view" >
    <field name="name">survey_form2</field>
    <field name="model">survey.survey</field>
    <field name="inherit_id" ref="survey.survey_form"/>
        <field name="arch" type="xml">
            <field name="quizz_mode" position="after">
            <field name="nominative" />
        </field>
    </field>
</record>

What I want to happen is that every time the "Nominative" checkbox is selected, a page with some questions gets loaded in the form, and every time the checkbox is unselected, that page gets popped out of the list of pages in the form.

Right now my nearest approach to do this is by creating a new object and append it to the page_id collection

@api.onchange('nominative')

def _toogle_extra_page(self):

    cr = self.env.cr
    uid = self.env.uid
    page_obj = self.pool.get('survey.page')
    page = page_obj.create(cr,uid,{
        "survey_id": self.id,
        "name": "Extra Page",
        "title": "Extra Page"
    }, context=None)

    self.page_ids.append(page)

But when I hit the checkbox, the "self.id" value is set to "NULL" in the SQL command

INSERT INTO "survey_page" ("id", "survey_id", "sequence", "title", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval('survey_page_id_seq'), NULL, 10, 'Pagina de Contacto', 1, 1, (now() at time zone 'UTC'), (now() at time zone 'UTC')) RETURNING id

 And also it is not showing in the form view as "Extra Page"

How can I manually insert/remove pages when that specific event occurs?

0
Avatar
Buang
Avatar
Mauricio Leon
Penulis Jawaban Terbai

I have managed to add a new element to the list of pages with the following code

@api.onchange('nominative')
def _toogle_info_page(self):
    cr = self.env.cr
    uid = self.env.uid
    pages = []
    pages.append({
        "name":"Contact Page",
        "title":"Contact Page",
        "sequence": 1,
        "description": "Contact info Page"
    })

    self.update({"page_ids": pages})

With this I was able to update the list of pages I had in my survey, but it removed all previous pages inserted. So, in order to solve this, I used the following code

@api.onchange('nominative')
def _toogle_info_page(self):
    page = self.env['survey.page'].new({
        "name":"Contact Page",
"title":"Contact Page",
"sequence": 1,
"description": "Contact info for tracking"
    })

    self.page_ids += page

With this, I don´t need to know the current survey ID to insert a new page in the list of pages.

I still can´t get the questions inside the pages though (no method described above worked), but I´ll open a new thread on the blog for this doubt.

Hope it helps.


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 update two levels o2m fileds relation
one2many onchange
Avatar
0
Sep 20
3769
Several levels of One2many
one2many onchange
Avatar
0
Apr 16
3887
One2many onchange in ODOO Diselesaikan
one2many onchange
Avatar
Avatar
3
Mar 16
14966
How to Import one2many field record from one model to one2many field in another model
one2many onchange
Avatar
Avatar
1
Mar 15
13330
Insert values to one2many on specific record
one2many insert odoo
Avatar
Avatar
Avatar
2
Sep 23
225
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