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

Problem with function write when i posted multi invoice

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
writeeventaccount.movev17
1 Balas
1931 Tampilan
Avatar
Roger Masias Font

Dear community,


I'm trying to add register when i change the state of the invoice, the draft to posted.


I think that i have to catch the write event and the vals but i can't understand, how can i filter the vals for every register.


Example code :


    @api.model    def write(self, vals):        for invoice in self:            if (vals.get('state') == 'posted'):                pos_id = invoice.line_ids.sale_line_ids.order_id.astore_tpv_id                invoice_date = invoice.invoice_date                amount_total = invoice.amount_total                account_move_id = invoice.id


Kind regards 

0
Avatar
Buang
Avatar
Zinfin Solutions Private Limited
Jawaban Terbai

Hello Roger Masias Font,

​​If you want to trigger a specific action when changing the state of an invoice from draft to posted, you can indeed use the write method.

​However, there are a few issues in your provided code. First, the if condition should check if the current state is 'draft' and the new state is 'posted'. Second, you should use the super function to call the parent class's write method. Here's a corrected version of your code:

def write(self, vals):
    result = super(YourInvoiceModel, self).write(vals)
    
    for invoice in self:
        if 'state' in vals and vals['state'] == 'posted' and invoice.state == 'draft':
            # Your logic here
            pos_id = invoice.line_ids.sale_line_ids.order_id.astore_tpv_id
            invoice_date = invoice.invoice_date
            amount_total = invoice.amount_total
            account_move_id = invoice.id
            # Perform your custom actions with the gathered data

    return result

​Make sure to replace YourInvoiceModel with the actual name of your invoice model. This code checks if the 'state' key is present in the vals dictionary and its value is 'posted', and if the current state of the invoice is 'draft'. If these conditions are met, you can access the required fields and perform your custom logic.

​Remember to adapt the model and field names according to your actual data model


0
Avatar
Buang
Roger Masias Font
Penulis

Dear Zinfin,

I can't undestant, how are you filter self with specific invoice, i think that self contain a lot of invoice but i think vals contain some values of specific invoice or all of invoice?

Kind regards, thanks for your help.

Zinfin Solutions Private Limited

Hello Roger,
the loop is iterating over invoices represented by self. The condition within the loop checks if the key 'state' is present in the vals dictionary and if its value is 'posted'. Additionally, it checks if the state of the current invoice in the loop is 'draft'. If these conditions are met, the code inside the loop is executed.

The invoice variable in the loop represents the current invoice being processed. So, the code inside the loop is dealing with a specific invoice that satisfies the conditions specified in the if statement. The vals dictionary seems to contain information related to the state of invoices, and it's being checked for the 'posted' state.

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
Add a new column in the partner legder
account.move v17 Ledger
Avatar
Avatar
1
Agu 24
1856
odoo17: Is this bug known? Mail Composer in Account Move renders same report doesn't matter which mail template is selected (reproducable in runbot)
mail templates account.move reports v17
Avatar
0
Apr 24
2278
payment_state never get value "paid" in code
development invoice write onchange v17
Avatar
Avatar
1
Mar 24
1878
Ya es posible hacer Upgrade de v17 a v17.1 ?
v17
Avatar
Avatar
1
Okt 25
1370
How to add a new Many2one field in res.config.settings? Diselesaikan
v17
Avatar
Avatar
Avatar
Avatar
4
Okt 25
3811
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