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
    • Discuss
    • Artificial Intelligence
    • 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
    • Manajemen Properti
    • 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
    • Tanya ahli
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan
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

cursor object has no attribute 'write'?

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
pythonv7cursor
2 Replies
9269 Tampilan
Avatar
mike

The traceback complains about sql_db.py line 358 in __getattr__ and before that it is line 162 in wrapper which is inside the decorator function 'check'. I agree with it, class Cursor has no attribute 'write'. However, my function (app_approve) is trying to write and it is in the traceback prior to the above. I just don't understand how it thinks I am trying to call 'write' on the cursor when I'm explicitly calling self.write. Or am I not myself here? This is getting too metaphysical anybody have any ideas?

def _create_application_history(self, cr, uid, ids, vals, context=None):
    """ Creates new application history objects """
    current_application = self.browse(cr, uid, ids, context=context)[0]
    # we are only working with a single record here 
    vals['application_id'] = current_application.id
    vals['current_status'] = current_application.state
    vals['completion'] = current_application.completion
    vals['note'] = current_application.note
    # get id from the ORM browse record since ORM can't recognize its own objects
    vals['dbe_specialist'] = current_application.dbe_specialist.id
    vals['onsite_visit_date'] = current_application.onsite_visit_date
    vals['onsite_visit_notes'] = current_application.onsite_visit_notes
    vals['visit_approved'] = current_application.visit_approved
    vals['docs_completed'] = current_application.docs_completed
    # get application history object and call its create
    _logger.debug("Application history create called with ids %s and vals %s", str(ids), str(vals))
    history_id = self.pool.get('dbe.application.history').create(cr, uid, vals, context=context)
    return history_id

def _transaction_history(func):
    """ Decorator function for historical logging of transactions """
    @functools.wraps(func) # ensuring we still have a name after wrapping
    def wrapped(self, cr, uid, ids, vals, context=None):
        func_name = func.__name__
        # if the wrapped function name matches a transaction type create a corresponding history record
        if func_name in _transaction_types.keys():
            vals['transaction_type'] = _transaction_types[func_name]                
            history_id = self._create_application_history(cr, uid, ids, vals, context)

        if history_id:
            _logger.debug("Application history created for transaction type %s with record #%d", _transaction_types[func_name], history_id)
        # call wrapped function without explicit self
        return func(cr, uid, ids, vals, context)
    return wrapped

@_transaction_history
def app_approve(self, cr, uid, ids, context={}):
    """ Setting the application record state to 'approve' from form action """
    return self.write(cr, uid, ids, {'state': 'approve'}, context=context)
0
Avatar
Buang
Avatar
mike
Penulis Jawaban Terbai

Fixed! This...

def app_approve(self, cr, uid, ids, context={}):

Should have been this...

def app_approve(self, cr, uid, ids, vals, context):

It was an impedance mismatch because either vals was missing or I had multiple values for context (or both). I needed to pass self through the wrapper and not return the wrapper as self because at the end of it all I was attempting self.write anyway.

Also, I had an unrelated mistake in original code for _transaction_history instead of passing vals to the create method pass vals.copy() to prevent resetting values in vals with values for self.

1
Avatar
Buang
Avatar
Francesco OpenCode
Jawaban Terbai

Self has write but cr not, if you call this function

return func(cr, uid, ids, vals, context)

you obtain an error becase the firts parameter (cr) must be self

return self.func(cr, uid, ids, vals, context)
0
Avatar
Buang
mike
Penulis

but then it complains: line 345 in wrapped return func(self, cr, uid, vals, context) TypeError: app_approve() takes at most 5 arguments (6 given). So self is passed anyway and the reason I didn't call with it before. This is normal from wrapped functions? Seems like it shouldn't be...

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
Please define these Python Fetch types
python v7
Avatar
2
Mar 24
30354
openerp 7 alpha "No handler found" error?
python v7
Avatar
0
Mar 15
7739
How to create a custom module in openerp 7 community edition?
python v7
Avatar
Avatar
1
Mar 15
12322
How add a float to a Datetime field.
python v7
Avatar
Avatar
Avatar
Avatar
3
Mar 15
10897
How to pass input filter value (domain) to python code?
python v7
Avatar
Avatar
1
Mar 15
12009
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
  • Karir
  • 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 Svenska ภาษาไทย 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