私はこれに苦労しており、それについてはあまり明確ではありません。別のクラスのフィールドから関数を呼び出す - Odoo v8
のは、私はクラスの機能を持っているとしましょう:
今class my_class(osv.Model):
_name = 'my_class'
_description = 'my description'
def func (self, cr, uid, ids, name, arg, context=None):
res = dict((id, 0) for id in ids)
sur_res_obj = self.pool.get('contratos.user_input')
for id in ids:
res[id] = sur_res_obj.search(cr, uid, # SUPERUSER_ID,
[('contratos_id', '=', id), ('state', '=', 'done')],
context=context, count=True)
return res
columns = {
'function': fields.function(_get_func,
string="Number of completed Contratos", type="integer"),
my_class()
私は別のクラスのオブジェクトからこの非常に同じ関数を呼び出したい:
class another_class(osv.Model):
_inherit = 'my_class'
_name = 'my_class'
columns = {
'another_field' : fields.related('function', 'state', type='char', string = "Related field which calls a function from another object"),
}
しかし、これは動作していません、私はこれについて非常に混乱しています、私はどのようにOdoov8の別のオブジェクトから関数を呼び出すことができますか?
私はself.pool.get
について聞いたことがありますが、私はそれを呼び出す方法について本当に分かりません。
アイデア?
ありがとうございます!
ありがとう、私はOpenERP 7 apiに固執しています。私はこれを試しています。私はもっと苦労したら別の質問を開きます、ありがとう! – NeoVe