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

How to access the vals dict.

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
createvals
4 Replies
7786 Tampilan
Avatar
Tarek Mohamed Ibrahim

I created a new record in a one2many field in a view, e.g. the order.line in a sales order screen. I need after each new line added in the detail, the one2many field, to sum the total amount of the order via an onchange method in the qty or price fields. I don't need to go to the 'update' button and click it each time I need to update the total amount. How to do that?

----

My idea is to access the vals array that is sent to the 'create' method when saving a record, I need to access it before saving.

0
Avatar
Buang
Avatar
Axel Mendoza
Jawaban Terbai

The one2many fields store the values in a format described on the write method of the model. For this task you need to pass the one2many field for the on_change method and check the state of their records in order to properly sum your total, something like this:

 def onchange_line_ids(self, cr, uid, ids, order_lines, context=None):  
    total = 0
    line_pool = self.pool.get('sale.order.line')
   for line in order_lines: 
if line[0] == 0:
             total += line[2].get('qty', 0)
        elif line[0] == 4:
            total += line_pool.browse(cr, uid, line[1], context=context).qty
        elif line[0] == 1:
             if line[2].get('qty', False):
                 total += line[2].get('qty', 0)
            else:
                 total += line_pool.browse(cr, uid, line[1], context=context).qty  
   return {'value': {'total': total}}

2
Avatar
Buang
Tarek Mohamed Ibrahim
Penulis

in the onchange method of the price I passed the 'order_id.order_line' and it didn't recognize it. I then passed only the 'order_id' on hope to access 'order_line' in the method, but it gave me what is called 'Newid' and was not able to accomplish my task

Axel Mendoza

You cannot do that, you need to put the onchange on the main form level to be able to pass order_line field, you could put the onchange to the order_line field itself because it's the main source of changes that you need to monitor, and pass only order_line instead of order.order_line, in the view you cannot move very easily over relation fields

Tarek Mohamed Ibrahim
Penulis

thx Axel for answer, it has worked. I accepted the answer and gave you an upvote

Avatar
Pawan
Jawaban Terbai

Hi Tarek, 

If i am wright, you want to sum of total price/qty in your one2many field. you can simply add an attribute "sum" at the qty/price field under tree tag, like:

<tree> [your one2many field tree view]

<field name="[your field]" sum="Total" />

........

</tree>

it will show sum of your fields data at the end of tree view.....

Hope it helps!!    

0
Avatar
Buang
Tarek Mohamed Ibrahim
Penulis

I've already did that and I can see the sum of the amounts every time I do a change in qty or price in any line. My case is different, that is, I have a field that defines the upper limit of a Sales Order amount, this field is per customer, and I read this field in the sale_order class via a function and display it on the order header. When saving the order, the create/write method checks if the sum of the line amounts exceeded this limit, then it raises an exception and stops the save action. The user then have to go to lines and reduce qtys until the amounts sum go below the upper limit allowed. I need this be done automatically via an onchange method. I checked the last reply from Axel and still didn't try it. I think it would work

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
Can't get some values from vals
create vals
Avatar
0
Sep 17
4715
What does vals mean ,and how to use it in the case of overriding the create() & write() methods ? Diselesaikan
create write vals
Avatar
Avatar
1
Agu 16
11646
Create new bug
create
Avatar
0
Apr 24
2900
vals for relationship fields (one2many) Diselesaikan
one2many create v7 vals
Avatar
Avatar
1
Des 22
6858
how i can update value of field in create method in Odoo v13 CE
create
Avatar
0
Des 19
5383
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