İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

How to store field readonly in database with onchange method

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
8 Cevaplar
18312 Görünümler
Avatar
oussama

Hi

How to store field readonly in database with onchange method

my code :

 def fret_change (self,cr, uid,ids ,tva_p,t_c,prix_d,fret_p,context):
        vals={}
        vals['p_achat_ht']= (t_c*prix_d)*(1+(fret_p/100))
         
        return {'value': vals}

def write(self,cr, uid, ids, vals, context=None):
        for rec in self.browse(cr, uid, ids, context=context):
            #Pass required value of fields in onchange
           
            res = self.fret_change(cr, uid, [rec.id], rec.tva_p, rec.t_c,rec.prix_d,rec.fret_p,context)
            if res.has_key('p_achat_ht'):
                vals.update({'p_achat_ht': res.get('p_achat_ht')})
        return super(product_product, self).write(cr, uid, ids, vals, context=context)

    def create(self,cr, uid, vals, context=None):
        #Pass required value of fields in onchange
        res = self.fret_change(cr, uid, [], vals.get('tva_p'),vals.get('t_c'), vals.get('prix_d'),vals.get('fret_p'),context)
        if res.has_key('p_achat_ht'):
            vals.update({'p_achat_ht': res.get('p_achat_ht')})
        return super(product_product, self).create(cr, uid, vals, context=context)

thanks

1
Avatar
Vazgeç
Sehrish

Try this: https://learnopenerp.blogspot.com/2021/10/onchange-method-readonly-field-not-store-database-odoo.html

Avatar
Annadurai
En İyi Yanıt

Hey! guys. We found a solution to store readonlyonchange in DB through below code.. CREATE edit, it will store in DB

samp_cal1=fields.Integer(string="a")

samp_cal2=fields.Integer(string="b")

samp_cal3=fields.Integer(string="c",readonly=True)

@api.onchange('samp_cal1','samp_cal2')

def adding_samp(self):

self.samp_cal3=self.samp_cal1+self.samp_cal2

@api.model

def create(self,vals):

    if self.samp_cal3:

        vals['samp_cal3']=self.samp_cal1+self.samp_cal2

    res = super(tokenreservation, self).create(vals)

    return res

@api.multi

def write(self,vals):

    if not self.samp_cal3:

        vals['samp_cal3'] = self.samp_cal1+self.samp_cal2

    res = super(tokenreservation, self).write(vals)

    return res

5
Avatar
Vazgeç
Avatar
vadivel
En İyi Yanıt

Hi friend, Usually when field is readonly and it gets input through on_change function after saving the record the value wont stored in database.So try below code:

addons/web/static/js/view_form.js:

In view_form.js:

in line: 840:

if (!f.get("readonly")) {

     values[f.name] = f.get_value(); }

else { readonly_values[f.name] = f.get_value(); }

     values[f.name] = f.get_value(); 

if (f.get("readonly")) 

   readonly_values[f.name] = f.get_value();

}

}

I think it will help you Thanks

1
Avatar
Vazgeç
Ben Bernard

Can you format your answer code more nicely. I think your solution could works.

Avatar
Bharat Devnani
En İyi Yanıt

Dear All,

Kindly look at this blog post for solution https://bharatrdevnani.wordpress.com/2016/02/04/readonly-attributes-onchange-odoo/ surely it will help.


Regards,

Bharat

1
Avatar
Vazgeç
Avatar
meriem HAKKANI
En İyi Yanıt

Hi

Try this : http://www.odooninja.com/readonly-field-onchange-method/

i try it its OK

0
Avatar
Vazgeç
Avatar
Deepa Venkatesh
En İyi Yanıt

As the term indicates Readonly, meaning values are not changed in those fields, hence odoo will not consider those values while saving it into database....

So best way to handle is making it as Functional / Computational field... that way it will be readonly and as well value will computated and can be either stored or not-stored...

But still you wish to use basic/normal fields with readonly property, then in ORM methods both create & write method, call the onchange event and update your values for those readonly fields manually...

 

0
Avatar
Vazgeç
Annadurai

hey Dep..! we can change onchange readonly field and save it to DB.. look my code

Avatar
sameer alhwety
En İyi Yanıt

If the field in new module you created you can making it functional field, but if the field already on system created by OpenERP/Odoo  don't change the field just create new field and save the value on it

0
Avatar
Vazgeç
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Üye Ol
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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