İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
9951 Görünümler

how to override the create method for a model in new api.


i have two models

1.'person_travel'

2.'person_calender'


second model is for the calender view. the 'person_travel'  creates records of  travel details with date.

what i need is , when a user creates a travel record  with a particular date i need that record to be displayed in the calender view with same date....how to do it??????


my plan is to override the create method in 'person_travel' model...how to achieve it??

Avatar
Vazgeç
En İyi Yanıt

Hi Abdul,

When you are overriding ORM Methods (write, create ...), if you don't want to call the super function(sometimes it will raise exception if you call super after your modification), you can use like this:-

To eliminate need of calling super method, you can use like this:-

instead of this -> super(stock_move, self).write(cr, uid, ids, vals, context=context)

you can give-> osv.osv.write(self, cr, uid, ids, vals, context=context)

This will call directly write function of ORM...

Hope this helps....



Avatar
Vazgeç
En İyi Yanıt

Hello,

For override create method you need to override this method in 'person_travel' model.


class person_travel(osv.osv):

  _descriptin = "Person Travel"

_name = "person.travel"

  _columns = {}


_defaults = {}

def create(self,cr,uid,vals,context=None)

    Put your code here.

   return super(person_travel, self).create(cr, uid, vals, context=context)


Hope this will help you.


Avatar
Vazgeç
En İyi Yanıt

Learn Overriding Create Method in Odoo 8 with Example - Odoo Technical


http://odootechnical.com/learn-overriding-create-method-in-odoo-8/

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Mar 25
1335
0
Oca 25
3427
1
Ağu 23
14741
change password Çözüldü
1
Ağu 23
13365
1
Tem 23
10377