İç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

update fields on write() method

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
createwrite
2 Cevaplar
36653 Görünümler
Avatar
philip

Hi all,

Take a look at my error please... in my model I have create() method to concatenate my first_name and last_name and fill into my name field and it works. I have also write() method to update if I have any changes to first_name, last_name and fill into my name field, but I got an errors below. someone can help me figure out to work my write() method, Thanks for the effort and answers

errors------

Server Traceback (most recent call last): File "/home/jp/ws/openerp/web/addons/web/session.py", line 89, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/home/jp/ws/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/home/jp/ws/openerp/server/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 190, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 132, in wrapper return f(self, dbname, *args, **kwargs) File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 199, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 187, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) TypeError: write() got multiple values for keyword argument 'context'

python -----


    def create(self, cr, uid, vals, context=None):
        name = str(vals['first_name'] or '') + ' ' +str(vals['last_name'] or '')
        vals['name'] = name.title()
        return super(hr_employee, self).create(cr, uid, vals, context=context)

    def write(self, cr, uid, vals, context=None):
        name = str(vals['first_name'] or '') + ' ' +str(vals['last_name'] or '')
        vals['name'] = name
        return super(hr_employee, self).write(cr, uid, vals, context=context)

    def onchange_first_name(self, cr, uid, ids, first_name, context=None):

        if first_name:
            return {'value': {'first_name': first_name.title()}}
        return {'value':{}}

    def onchange_last_name(self, cr, uid, ids, last_name, context=None):
        if last_name:
            return {'value': {'last_name': last_name.title()}}
        return {'value':{}}

    def onchange_name(self, cr, uid, ids, last_name, context=None):
        if last_name:
            return {'value': {'last_name': last_name.title()}}
        return {'value':{}}
            
    _columns = {
        'name': fields.char('First Name', size=32),
        'date_start': fields.date('Start Date', required=True),
        'date_end': fields.date('End Date'),
        'attendance_ids' : fields.one2many('philcode.test', 'calendar_id', 'Working Time'),
        'first_name': fields.char('First Name', size=32, required=True),
        'last_name': fields.char('Last Name', size=32, required=True),
    }

xml -----

                        <label for="first_name"/>
                        <div>
                            <h1><field name="first_name" style="width: 50%%" on_change="onchange_first_name(first_name)"/></h1><br/>
                        </div>
                        <label for="last_name"/>
                        <div>
                            <h1><field name="last_name" style="width: 50%%" on_change="onchange_last_name(last_name)"/></h1>
                        </div>
                        <label for="name" String="Full Name"/>
                        <div>
                            <h1><field name="name" on_change="onchange_name(name)" style="width: 50%%"/></h1>

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

parameter specified for Write method are wrong

def write(self, cr, uid, ids, vals, context=None):

Ids was not specified...

2
Avatar
Vazgeç
philip
Üretici

Thanks for the response, so what's right for the write method
and how to specify the ids?

OdooBot

U need not pass anything for Ids ... it is exclusively passed by openerp .....
It is d necessary syntax for it ... as it is orm method...

Sent from Yahoo! Mail on Android



From: philip <johnpaul@ictsecuritygroup.org>;
To: deep <deepa4lok@yahoo.com>;
Subject: Re: False
Sent: Mon, Sep 8, 2014 12:29:54 PM

Thanks for the response, so what's right for the write method
and how to specify the ids?

--
philip
Sent by OpenERP S.A. using Odoo about Forum Post False
Avatar
Mariusz Mizgier
En İyi Yanıt

You don't provide additional parameter for the write method, which is ids of the written record. If OpenERP has to write, it needs to know to which record it should write to.

1
Avatar
Vazgeç
philip
Üretici

I tried to put ids in my function but I got error mesaage:
name = str(vals['first_name'] or '') + ' ' +str(vals['last_name'] or '') KeyError: 'last_name'
python code def write(self, cr, uid, vals, context=None): name = str(vals['first_name'] or '') + ' ' +str(vals['last_name'] or '') vals['name'] = name return super(hr_employee, self).write(cr, uid, vals, context=context)

philip
Üretici

here is my python code

def write(self, cr, uid, ids, vals, context=None): name = str(vals['first_name'] or '') + ' ' +str(vals['last_name'] or '') vals['name'] = name return super(hr_employee, self).write(cr, uid, ids, vals, context=context)

can you point me to the right direction, I don't have any idea on write() method.

Thanks for the response

Mariusz Mizgier

It means, that you don't have key of 'last_name' in your vals dictionary - you should first do the check for whether first_name or last_name are the values that are changing on the current record and based on that then create name you want to put, ie. if 'first_name' in vals and 'last_name' in vals: name = str(vals['first_name'] + str(vals['last_name']) if 'first_name' in vals and 'last_name' not in vals: do something.... (like check if record has got already its last name and you have to do your text operation on new first name, but old last name)

philip
Üretici

can you fix the code

def write(self, cr, uid, vals, context=None):
name = str(vals['first_name'] or '') + ' ' +str(vals['last_name'] or '')
vals['name'] = name
return super(hr_employee, self).write(cr, uid, vals, context=context)

Thank really appreciate all your help

Mariusz Mizgier

Try this: def write(self, cr, uid, ids, vals, context=None): employee_data = self.pool.get('hr.employee').browse(cr, uid, ids) if vals['first_name'] and vals['last_name']: name = str(vals['first_name']) + ' ' +str(vals['last_name']) vals['name'] = name return super(hr_employee, self).write(cr, uid, vals, context=context) if vals['first_name']: name = str(vals['first_name']) + ' ' +str(employee_data.last_name or '') vals['name'] = name return super(hr_employee, self).write(cr, uid, vals, context=context) if vals['second_name']: employee_data = self.pool.get('hr.employee').browse(cr, uid, ids) name = str(employee_data.first_name or '') + ' ' +str(vals['second_name']) vals['name'] = name return super(hr_employee, self).write(cr, uid, vals, context=context)

philip
Üretici

Thanks will try this later, is this indentation is right?
def write(self, cr, uid, ids, vals, context=None):
----employee_data = self.pool.get('hr.employee').browse(cr, uid, ids)
----if vals['first_name'] and vals['last_name']:
----name = str(vals['first_name']) + ' ' +str(vals['last_name']) vals['name'] = name
----return super(hr_employee, self).write(cr, uid, vals, context=context) if vals['first_name']:
----name = str(vals['first_name']) + ' ' +str(employee_data.last_name or '') vals['name'] = name
----return super(hr_employee, self).write(cr, uid, vals, context=context) if vals['second_name']:
----employee_data = self.pool.get('hr.employee').browse(cr, uid, ids)
----name = str(employee_data.first_name or '') + ' ' +str(vals['second_name'])
----vals['name'] = name return super(hr_employee, self).write(cr, uid, vals, context=context)

Mariusz Mizgier

No, it is not right - comments are not working well with the indents: ----def write(self, cr, uid, ids, vals, context=None): --------employee_data = self.pool.get('hr.employee').browse(cr, uid, ids) --------if vals['first_name'] and vals['last_name']: ------------name = str(vals['first_name']) + ' ' +str(vals['last_name']) vals['name'] = name ------------return super(hr_employee, self).write(cr, uid, vals, context=context) --------if vals['first_name']: ------------name = str(vals['first_name']) + ' ' +str(employee_data.last_name or '') ------------vals['name'] = name ------------return super(hr_employee, self).write(cr, uid, vals, context=context) --------if vals['second_name']: ------------name = str(employee_data.first_name or '') + ' ' +str(vals['second_name']) ------------vals['name'] = name ------------return super(hr_employee, self).write(cr, uid, vals, context=context) --------else: ------------return super(hr_employee, self).write(cr, uid, vals, context=context)

philip
Üretici

Thanks will try later. thanks for your response

philip
Üretici

PYTHON-----
----def write(self, cr, uid, ids, vals, context=None):
--------employee_data = self.pool.get('hr.employee').browse(cr, uid, ids)
--------if vals['first_name'] and vals['last_name']:
------------name = str(vals['first_name']) + ' ' +str(vals['last_name'])
------------vals['name'] = name
------------return super(hr_employee, self).write(cr, uid, vals, context=context)
--------if vals['first_name']:
------------name = str(vals['first_name']) + ' ' +str(employee_data.last_name or '')
------------vals['name'] = name
------------return super(hr_employee, self).write(cr, uid, vals, context=context)
--------if vals['second_name']:
------------name = str(employee_data.first_name or '') + ' ' +str(vals['second_name'])
------------vals['name'] = name
------------return super(hr_employee, self).write(cr, uid, vals, context=context)
--------else:
------------return super(hr_employee, self).write(cr, uid, vals, context=context)


ERRORS------ Server Traceback (most recent call last):
--File "/home/jp/ws/openerp/web/addons/web/session.py", line 89, in send
----return openerp.netsvc.dispatch_rpc(service_name, method, args)
--File "/home/jp/ws/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc
----result = ExportService.getService(service_name).dispatch(method, params)
--File "/home/jp/ws/openerp/server/openerp/service/web_services.py", line 626, in dispatch
----res = fn(db, uid, *params)
--File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 190, in execute_kw
----return self.execute(db, uid, obj, method, *args, **kw or {})
--File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 132, in wrapper
----return f(self, dbname, *args, **kwargs)
--File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 199, in execute
----res = self.execute_cr(cr, uid, obj, method, *args, **kw)
--File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 187, in execute_cr
----return getattr(object, method)(cr, uid, *args, **kw)
--File "/home/jp/ws/openerp/my_addons/for_development/philcode_test.py", line 15, in write
----name = str(vals['first_name']) + ' ' +str(vals['last_name'])
KeyError: 'last_name'

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
İlgili Gönderiler Cevaplar Görünümler Aktivite
launch a wizard before saving a record
wizard create write
Avatar
Avatar
1
Ağu 20
5564
Odoo 13 Create() Write() stores old values
create write 13.0
Avatar
Avatar
1
Nis 20
6061
How to create and write multiple records by overriding create and write method of odoo12 Çözüldü
create write odoo12
Avatar
Avatar
1
Eyl 19
9742
Creating a record or editing an existing record? How to know?
create write odoo12.0
Avatar
Avatar
Avatar
Avatar
3
Şub 19
10193
how to override create or write method Çözüldü
one2many create write
Avatar
Avatar
Avatar
3
Tem 17
12671
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