How to use the self.env.
Good day, i'm working with odoo8 developing a module that check the payments of employees social benefits. I need to get the last value inserted in a field "accumulated, i'm trying with this code:
payments = self.env['hr.prestaciones'].search([(employee_id','=', self.employee_id),('accumulated')])
self.sum_payments = sum(item.amount for item in payments)
sum_payments = fields.Float(string="Prestaciones Acumuladas", compute='_get_sum_payment')
but that code is not working... how can solve it?