Functional Field not working properly in Kanban View

146 views Asked by At

My code:

def get_score(self, cr, uid, ids, context={}, arg=None,obj=None):
    result = {}
    for f in self.browse(cr, uid,ids): 
        net_score = float(f.earn_score.f.availed_score)
        result[f.id] = net_score
    return result

'net_score': fields.function(get_score, method=True, string='Net Score',type='float'),

This methods works fine on form view shows correct net score for every player, but when i want to display the same field in Kanban view, it sums up net_score for all players displayed on Kanban view, shows the same accumulated score for all.

How can I display net_hours for every player in Kanban?

1

There are 1 answers

0
RAJ KUMAR MISHRA On

When I went through the code i found one mistake there : net_score =float(f.earn_score.f.availed_score)

I m not sure but hope it should be : net_score = float(f.earn_score + f.availed_score)

And the to show the net score at kanban as well as the other views you can try the below code:

def get_score(self, cr, uid, ids, context={}, arg=None,obj=None):
    result = {}
    for f in ids:
        curr_obj = self.browse(cr,uid,f) 
        net_score = float(curr_obj.earn_score + curr_obj.availed_score)
        result[f] = net_score
    return result