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

Where are the 'vals' coming from?

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
pythonparameters
1 Balas
7546 Tampilan
Avatar
Yakito

Hello,

OK I really must post a disclaimer before asking because this is a really basic question but as I am learning python and OpenERP I can't seem to figure it out and its taking me forever.

I am trying to understand some custom code I requested from a developer. Basically what I need is to add some values to a variable called vals, but I look and I look and I can't find where is vals initially created or where it is getting its contents from.

Here is the code of the class I am working with:

class guest_amenities_vals(osv.osv):
    _name = "sim.guest_amenities_vals"
    _description = "GuestAmenitiesVals"
    _columns = {

        'name': fields.char('Name',required=True),
        'cols': fields.many2one('sim.resumen_wizard','Order Reference', required=True, ondelete='cascade', select=True),
        'price': fields.float('Price'),
        'period': fields.float('Period')
    }
    _defaults = {
        'price' : 0,
    }

    def create(self, cr, uid, vals, context=None):
        print vals
        print "------------"
        if 'cols' in vals and 'name' in vals:
            existing_recs = self.search(cr, uid, ['&',('cols','=',vals['cols']),('name','=',vals['name'])], context=context)
        if not existing_recs:
            return super(guest_amenities_vals, self).create(cr, uid, vals, context=context)
        else:
            ids = existing_recs[0]
            if ids:
                super(guest_amenities_vals, self).write(cr, uid,[ids], vals, context=context)
                print vals
                return ids

guest_amenities_vals()

From what I could debug the code gets executed when the user clicks on a 'Print' button from a wizard.

Vals has something like this {'price': 3000, 'name': 'b', 'cols': 116L}

What I am trying to do is also add the Period to vals so I can insert it into de DB

So the question is how would you look for were vals is initialized so I can pass the value of period to this class and insert it into the DB like the rest of the fields?

Please again excuse me if this is super basic. I spent a lot of time digging into the code and can't find it so any clue on where to look or what to look for will be deeply appreciated.

0
Avatar
Buang
Prakash

Hi, vals is dictionary its contains Key and Value. Here Key is the field name of the table. Vals value coming from the form entered Field value. You can pass the value of period For example, vals['period'] = Your_value

Yakito
Penulis

Oh! thats why I couldn't find it! (sorry, super new with python). So basically if I enter more fields in the form the values will appear in vals, right?

Prakash

Yes In the create methods vals contains table column name and value. If more fields added in shows in the vals

Avatar
aharoen
Jawaban Terbai

You must inherit related view in your xml file that refer to "sim.guest_amenities_vals" model and add period field.

...
<field name="period"/>
...

Please read article(s) about inheriting openerp view for more explanation.

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
ValueError: SQL query parameters should be a tuple, list or dict
function python parameters
Avatar
0
Mar 15
12398
new python env
python
Avatar
0
Mar 25
2370
What means "Too many values to unpack" message? Diselesaikan
python
Avatar
Avatar
Avatar
Avatar
Avatar
4
Apr 24
175877
have no data in screen. read data in my own module from different model
python
Avatar
0
Des 23
2966
How to insert value to a one2many field in table with create method? Diselesaikan
python
Avatar
Avatar
Avatar
Avatar
Avatar
5
Jul 25
232244
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