我只想知道,如何將某些函數轉換爲新的API,或者是否需要完全轉換它們,具體取決於我們使用的API調用。Odoo v10 API vs Odoo v8 API
例如,
@api.model
the method is exposed as not using ids, its recordset will generally be empty. Its "old API" signature is cr, uid, *arguments, context:
@api.model
def some_method(self, a_value):
pass
# can be called as
old_style_model.some_method(cr, uid, a_value, context=context)
在Odoo V8,假設我有這樣的功能:
def update_info(self, cr, uid, ids, context=None):
""" OpenERP osv memory wizard : update_info_partner
"""
context = context or {}
seniat_url_obj = self.env('seniat.url')
self.cr.execute('''SELECT id FROM res_partner WHERE vat ilike 'VE%';''')
record = self.cr.fetchall()
pids = [item[0] for item in record]
seniat_url_obj.connect_seniat(cr, uid, pids, context=context,
all_rif=True)
return{}
如果我添加@api.model
裝飾這個功能,我想我還需要更新它的屬性,即:self, cr, uid, ids, context=None
,對吧?
在這種情況下,添加@api.model
裝飾器,然後將函數屬性更改爲只有self
就足夠了?
我只是試圖得到如何解決這個問題,從現在開始,因爲我將一些模塊從v8鏡像到v10。