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

on record creation run function to create a record in another module odoo 13

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
Odoo13.0create()
16 Cevaplar
18462 Görünümler
Avatar
Moaz Mabrok

I was trying to create a new company when a record is created in my module but using the create method 

but I can't get it to work

     @api.model
def create(self, vals):
for n_record in self:
company_info ={
'company_type': 'company',
'name': n_record.new_company_name,
'vat': n_record.company_trn
}
record = n_record.env['base.view_partner_form'].create(company_info)

return record

I got this error and I can't understand the Error 

Odoo Server Error
Traceback (most recent call last):
........
........
 return result.id if isinstance(args[0], Mapping) else result.ids
AttributeError: 'NoneType' object has no attribute 'id'

can please help 


edit

@api.model
def create(self, vals):
company_info ={
'company_type': 'company',
'name': self.new_company_name,
'vat': self.company_vat
}
record = self.env['res.partner'].create(company_info)

return record

Something went wrong !

Contacts require a name

1
Avatar
Vazgeç
Sehrish

Override odoo methods: https://goo.gl/4BkizH

Avatar
Prakash
En İyi Yanıt
Hi,
Remove return record
and add return super "yourclassname"
@api.model
def create(self, vals):
company_info ={
'company_type': 'company',
'name': self.new_company_name,
'vat': self.company_vat
}
record = self.env['res.partner'].create(company_info)
return super(yourclassname, self).create(vals)


1
Avatar
Vazgeç
Moaz Mabrok
Üretici

can you explain using my code, I can't understand your example

Moaz Mabrok
Üretici

what is the `ClassName` for `res.partner` or the contacts

Prakash

Are you overriding default create method? In that case create method add below code: change "classname" into your class name.

return super(classname, self).create(values)

Moaz Mabrok
Üretici

I am overriding my module `A` create method so after creating the recored in `A` it create a recored in odoo contacts module `B`

Prakash

Updated code, please check remove return record and add return super yourclassname ...

Moaz Mabrok
Üretici

how to make it run a function on create instead of having the code in the create function it self

Avatar
Niyas Raphy (Walnut Software Solutions)
En İyi Yanıt

Hi,

Change this line record = n_record.env['base.view_partner_form'].create(company_info) to

record = self.env['res.company'].create(company_info) and see .


For creating records from code, see : Create Record From Code in Odoo


For Over riding the create method,

@api.model
def create(self, vals):
result = super(ClassName, self).create(vals)
# do what you want
return result

See : - How To Override Create Function in Odoo


Thanks

1
Avatar
Vazgeç
Moaz Mabrok
Üretici

That is the tutorial that I was following

I am still getting the error

File "/usr/lib/python3/dist-packages/odoo/api.py", line 385, in call_kw

result = _call_kw_model_create(method, model, args, kwargs)

File "/usr/lib/python3/dist-packages/odoo/api.py", line 366, in _call_kw_model_create

return result.id if isinstance(args[0], Mapping) else result.ids

AttributeError: 'NoneType' object has no attribute 'id'

Moaz Mabrok
Üretici

I user this instead

@api.model

def create(self, vals):

company_info ={

# 'company_type': 'company',

'name': self.new_company_name,

'vat': self.company_trn

}

record = self.env['res.company'].create(company_info)

return record

and geting

×

The operation cannot be completed:

- Create/update: a mandatory field is not set.

- Delete: another model requires the record being deleted. If possible, archive it instead.

Model: Companies (res.company), Field: Company Name (name)

Niyas Raphy (Walnut Software Solutions)

Make sure that the value for the all the mandatory fields are passed in to the create method, here in your code as per the error self.new_company_name might be returning empty or False, just print it and see, also you can try with vals['new_company_name']

Thanks

Moaz Mabrok
Üretici

I tried vals['new_company_name'] I am not going the error but is stuck save

Moaz Mabrok
Üretici

the company has been created but the form is not saving

Niyas Raphy (Walnut Software Solutions)

See the updated answer,

Moaz Mabrok
Üretici

how to make it run a function on create instead of having the code in the create function it self

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
what is difference between these vals.get("field name", False) and vals['field name'] == False Çözüldü
Odoo13.0 create()
Avatar
Avatar
Avatar
2
Tem 21
6299
Odoo 13. Don't close a wizard when Click a button Çözüldü
Odoo13.0
Avatar
Avatar
Avatar
Avatar
4
May 24
14084
Permission error while user printing excel sheet report in odoo 13 Çözüldü
Odoo13.0
Avatar
Avatar
1
Nis 24
4335
One2many field edited from Transient Model cannot be made empty.
Odoo13.0
Avatar
0
Kas 23
3021
Blank White Page After log in to Odoo13 Çözüldü
Odoo13.0
Avatar
1
Eyl 23
3161
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