本文介绍了Openerp功能栏位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿,我是openerp的新手,我需要帮助来创建一个名为Total的函数字段,该字段计算同一对象的所有字段的总和...例如.
Hey I'm new to openerp and I need help to create a function field called Total that calculates the sum of all the fields of the same object...eg.
_name = 'hr.performanzze'
_columns = {
'p':fields.selection(((1,'Outstanding'), (2,'Well Above Expectations'), (3,'As Expected'), (4,'Below Expectations'), (5,'VeryPoor'), 0,'N/A')),'title.'),
'b':fields.selection(((1,'Outstanding'), (2,'Well Above Expectations'), (3,'As Expected'), (4,'Below Expectations'), (5,'Very Poor'), (0,'N/A')),'title'),
'total' : fields.function(get_total, method=True, string='Total Mark'),
}
def get_total(self, cr, uid, field_name, arg, context):
#want to calculate the sum of p and b
return the answer
推荐答案
def get_total(self, cr, uid, ids, field_name, arg, context):
res = []
perfos = self.browse(cr, uid, ids, context)
for perfo in perfos:
res[perfo.id] = perfo.p + perfo.b
return res
这篇关于Openerp功能栏位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!