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
    • 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
    • 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

function.field store help

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
storeerrrorfields.functionarguments
3 Replies
7031 Tampilan
Avatar
Erhuvwu Akpobaro

Hey guys ,


I have field.function that shows the right value i want however when i try to display this value in the point of sake(through my own customization) nothing shows , i believe this is because my field.function is not stored :


class cm_product_template(osv.osv):

     _name = 'product.template'

     _inherit = "product.template"


    def _get_invoice_company(self, cr, uid, ids, field, parameter, context=None):

    #def _get_invoice_company(self, cr, uid, ids , context=None):

           context = context or {}

           invoice = {}

           #period_obj3 = self.pool.get('product.template')

           for auto1 in self.browse(cr, uid, ids, context=context):

               prod_temp_id = auto1.id

               print prod_temp_id

               # cr.execute("SELECT id FROM pp_feature WHERE plan = %d" %(featurename) )

               cr.execute("""SELECT f.name FROM product_template pt INNER JOIN product_product pp on pp.product_tmpl_id = pt.id INNER JOIN account_analytic_invoice_line aal on aal.product_id = pp.id INNER JOIN account_analytic_account aaa on aaa.id = aal.analytic_account_id INNER JOIN res_company f on f.id = aaa.invcompany_id WHERE pp.product_tmpl_id = %s""", % (prod_temp_id,) )

               # res = cr.fetchall()

               res = cr.fetchone()

               print res

               invoice.update({prod_temp_id : res and res[0] or False })

    return invoice


    _columns = {

        'cm_property_ids': fields.one2many('cm.property', 'product_template_id', 'Products') ,

        'invoice_company':fields.function(_get_invoice_company , type='integer' , store=True, method=True ,string='Invoice Company')

        }


# example od function you can use in defaults
    def _get_default_invoice_company(self, cr, uid, context=None):

        context = context or {}

        # do your treatment here

        company_id = False

        return company_id


     _defaults = {

        'invoice_company': _get_default_invoice_company ,

        }

When i add store=True i get this error :  

File "/opt/odoo/odoo/openerp/models.py", line 2399, in _set_default_value_on_column

default = default(self, cr, SUPERUSER_ID, context)

TypeError: _get_invoice_company() takes at least 6 arguments (4 given)


I am confused why i cant store the function value field in the database  any ideas to get passed this ?


1
Avatar
Buang
Erhuvwu Akpobaro
Penulis

Hi , the field invoice company is a a new inherited field on the produced template page , I want this field to automatically show a value on on already creates products and new products . thanks for the help on removing the default field however I get this error now : Value Error : expected singleton prod_temp_Id = auto.id Is the function trying to store multiple values ?

Cyril Gaspard (GEM)

I modify your code, but you will have again an error because your request finish with : INNER JOIN accoun$ ????

Erhuvwu Akpobaro
Penulis

My aplogies the right sql query is : cr.execute("SELECT f.name FROM product_template pt INNER JOIN product_product pp on pp.product_tmpl_id = pt.id INNER JOIN account_analytic_invoice_line aal on aal.product_id = pp.id inner join account_analytic_account aaa on aaa.id = aal.analytic_account_id inner join res_company f on f.id = aaa.invcompany_id WHERE pp.product_tmpl_id = %d" %(prod_temp_id) )

Cyril Gaspard (GEM)

I update your function, should work, for use of a function in _defaults, I gave you an example of function to call, see function _get_default_invoice_company which is the only prototype of function you can use in this case (in body function, you can't use ids), bye

Avatar
Cyril Gaspard (GEM)
Jawaban Terbai

remove :

_defaults = {

'invoice_company':_get_invoice_company ,

}

what do you want to do exactly with your field invoice_company, your code is very strange ...

1
Avatar
Buang
Avatar
Erhuvwu Akpobaro
Penulis Jawaban Terbai

Hi , the field invoice company is a a new inherited field on the produced template page , I want this field to automatically show a value on on already creates products and new products . thanks for the help on removing the default field however I get this error now : Value Error : expected singleton prod_temp_Id = auto.id 

Is the function trying to store multiple values ?

1
Avatar
Buang
Cyril Gaspard (GEM)

I upvote for you, you have now enough karma to upvote, edit previous post ..., bye

Erhuvwu Akpobaro
Penulis

Do you how to edit the point of sale module/interface ?

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
To change the function field to editable?
python store fields.function odooV8
Avatar
Avatar
Avatar
3
Mar 18
11288
Why in functions called by fields.function(called_function,...) the field uid is always 1?
store v7 fields.function uid
Avatar
Avatar
1
Mar 15
6097
jsonb_path_query_array error Diselesaikan
errror
Avatar
Avatar
1
Jun 24
5223
Expected singleton Error
errror
Avatar
Avatar
Avatar
5
Des 19
8133
[object with reference: name - name] v10
errror
Avatar
Avatar
2
Apr 17
8356
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