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

Write method called in the create method

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
createv7write
1 Balas
8794 Tampilan
Avatar
N

I have created a custom module and i am redefining the create and write methods. When i create a new sale order, the method create is called, but also the write method.. How it is possible ? Thanks

def create(self, cr, uid, vals, context=None):
    # creation du devis par heritage(et des lignes de commandes du devis) // obligatoire de creer le devis pour acceder aux lignes du devis
    id = super(sale_order, self).create(cr, uid, vals, context)
    # creation d'une liste vide qui contiendra tous les numeros de sections saisis dans la vue
liste_numeros_section = []
    # recuperation des id de chaque ligne du devis (qui ne sont pas des options)
    order_line_ids = self.pool.get('sale.order.line').search(cr, uid, [('order_id', '=', id), ('is_option', '=', False)], context=context)
    #recuperation de l'objet section
    section_pool = self.pool.get('sale.order.section') 
    for i in self.pool.get('sale.order.line').browse(cr,uid,order_line_ids, context=context): # pour chaque ligne du devis
        # si nouveau numero de section, alors creation section + lien avec ligne de devis actuelle
        if not(i.number_section in liste_numeros_section):
            liste_numeros_section.append(i.number_section)
            dict_section = {
                'order_id': id,
                'order_line': [(4, i.id)], # lier ligne du devis actuelle a la section (creation d'une relation)
                'number': i.number_section,
             }
             section_pool.create(cr,uid,dict_section, context=context)
        else:
            # si le numero de section existe deja, alors creation lien ligne du devis actuelle /section
            id_section = self.pool.get('sale.order.section').search(cr,uid, [('number', '=', i.number_section), ('order_id', '=', id)], context=context) #recupere section qui correspond a la ligne du devis
            dict_section = {
                'order_line': [(4, i.id)], # lier ligne du devis actuelle a la section (creation d'une relation)
            }
            section_pool.write(cr,uid,id_section,dict_section, context=context)
        return id

    def write(self, cr, user, ids, vals, context=None):
        raise osv.except_osv(_('Erreur!'),_('Vous ne pouvez pas confirmer une commande qui contient une ou des options'))
        # mise a jour du devis par heritage
        super(sale_order, self).write(cr, user, ids, vals, context)
        order_id = ids[0] # recuperation de l'id du devis courant
        # recuperation de l'objet ligne de devis
        order_line_pool = self.pool.get('sale.order.line')
        # recuperation de l'objet section
        section_pool = self.pool.get('sale.order.section')
# recuperation des id de chaque ligne du devis (qui ne sont pas des options)
        order_line_ids = order_line_pool.search(cr, user, [('order_id', '=', order_id), ('is_option', '=', False)], context=context)
        # recuperation des id de chaque section du devis
        section_ids = section_pool.search(cr, user, [('order_id', '=', order_id)], context=context)
# creation d'une liste vide qui contiendra tous les numeros de sections saisis dans la vue
            liste_numeros_section = []
        # pour chaque ligne du devis
        for i in self.pool.get('sale.order.line').browse(cr,user,order_line_ids, context=context):
            if not (i.section_id in section_ids): # si nouvelle section
                dict_section = {
                    'order_id': order_id,
    # lier ligne du devis actuelle a la section (creation d'une relation)
                    'order_line': [(4, i.id)],
                    'number': i.number_section,
                }
                section_pool.create(cr,user,dict_section, context=context)
            else:
                dict_section = {
                # mise a jour de la relation entre la section et la ligne du devis
                    'order_line': [(6, 0, i.id)],
                    'number': i.number_section,
                }
                section_pool.write(cr,user,i.section_id,dict_section, context=context)
        return True
2
Avatar
Buang
Avatar
patrick
Jawaban Terbai

In order to create a new record, you have to write it to the database. I think that the call to super(sale.order).create(..) will do a call to write (or self.write(..)). At the moment I do not have the code of openERP with me to check this.

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
update fields on write() method Diselesaikan
create write
Avatar
Avatar
Avatar
2
Jan 16
36658
launch a wizard before saving a record
wizard create write
Avatar
Avatar
1
Agu 20
5566
Odoo 13 Create() Write() stores old values
create write 13.0
Avatar
Avatar
1
Apr 20
6063
How to create and write multiple records by overriding create and write method of odoo12 Diselesaikan
create write odoo12
Avatar
Avatar
1
Sep 19
9743
Creating a record or editing an existing record? How to know?
create write odoo12.0
Avatar
Avatar
Avatar
Avatar
3
Feb 19
10194
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