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

Overriding method in a model

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
override
1 Cevapla
36077 Görünümler
Avatar
Thanh Loyal

Hello,

I found a guy had solved the same problem here:

\http://stackoverflow.com/questions/32859723/odoo-how-to-override-original-function

So I imitated to override a method of 'stock.inventory' class:


class StockInventoryInherit(models.Model):
_inherit = 'stock.inventory'

def _default_stock_location(self, cr, uid, context=None):
logger.info("_____________-------------------_____________")
logger.info("_____________-------------------_____________")
logger.info("_____________-------------------_____________")
return 19

But nothing changes.

What am I doing wrong?

Please help.

Thank you.

---


0
Avatar
Vazgeç
Thanh Loyal
Üretici

It seems to be that private methods (which start with underscore _) can not be override. I tested with a public method and it worked. But I want to override that private one. Any idea? thank you.

Avatar
Jignesh Mehta
En İyi Yanıt

Hello Loyal,


For overriding method, You should called super() for it.


For Ex:-

class StockInventoryInherit(models.Model):

_inherit = 'stock.inventory'


    def _stock_inventory_default_stock_location(self, cr, uid, context=None):

        res = super(StockInventoryInherit, self)._stock_inventory_default_stock_location(cr, uid, context=context)

        return res


Hope it works for you.

Thanks,


1
Avatar
Vazgeç
Thanh Loyal
Üretici

Hi Jignesh Mehta, thank you for your answer. I am sorry, I did not make my self clear. My problem is my method was NOT called. Only the original method in 'stock' module was called.

Jignesh Mehta

Hello, For override any base method, You should called super(). Just call print "res :::" in my method.

Thanh Loyal
Üretici

yeah I would call super() if my method was called. But currently Odoo does not run into my function. MY FUNCTION WAS NOT CALLED. My problem is only that.

Jignesh Mehta

can you post your code ?

Thanh Loyal
Üretici

It seems to be that private methods (which start with underscore _) can not be override. I tested with a public method and it worked. But I want to override that private one. Any idea? thank you.

Thanh Loyal
Üretici

My (main) code is like above, the method I want to override is stock.py --> class stock_inventory --> method _default_stock_location

Jignesh Mehta

Hello, Try with my updated answer.

Thanh Loyal
Üretici

Hi Jignesh Mehta, thank you for your help. That still does not work. I have found the same question: https://www.odoo.com/forum/help-1/question/how-to-override-private-method-account-invoice-line-25187. . . If I override method 'action_done', it works just fine. But _default_stock_location does not. It seems to be maggical (something I still dont understand yet) keke.

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
Create function problem Çözüldü
override
Avatar
Avatar
2
Haz 23
2903
How to override method 'create' on the non-inherited model
override
Avatar
Avatar
1
Kas 17
3917
How to override the get_lines method of the report_account_common class? Çözüldü
override
Avatar
1
Haz 16
5540
I overrote a method and it was not called
override
Avatar
Avatar
Avatar
2
Ağu 15
6101
How i can override the activity js file in odoo 14?
javascript override
Avatar
Avatar
1
Ağu 23
3738
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