Odoo Help

0

How can i do this operation y odoo?

By
Giovanny Vizcaya
on 10/25/15, 12:16 PM 673 views



when i add a new payment(1), this is added to the accumulated(2) and showing a new accumulated(3) ...how can i do that? 

0
Giovanny Vizcaya
On 11/2/15, 8:42 PM

i tried to get the last value of "Prestaciones Acumuladas" but i don't understand how it works, i'm using


@api.one

def _get_sum_payment(self):

payments = self.env[hr.prestaciones'].search([('employee_id','=', self.employee_id),('acumulado')])

self.sum_payments = sum(item.amount for item in payments)

sum_payments = fields.Float(string="Prestaciones Acumuladas", compute='_get_sum_payment', store="True")

0
Axel Mendoza
On 10/26/15, 3:53 AM

To do that you need to have the field "Prestaciones Acumuladas" as a calculated field with store = True and also readonly to do not modify it latter at least that you made a change in the field "Abono Mensual" of previous saved values. The formula to calculate it's simply the sum of the field "Abono Mensual" + the field "Prestaciones Acumuladas" of the previous record. You just need to figure out how to get the previous record, could be based on the field create_date like a search over the model with a create_date minor than the current record create_date with a limit 1 of results and ordered by create_date DESC


you mean prestaciones_acumuladas = fields.Float(compute="_get_acumulado")? but i don't understand at all that part of get the previous record...

Giovanny Vizcaya
on 11/1/15, 7:41 PM

Something like this? perhaps? @api.one def _get_sum_payment(self): payment = self.env['account.voucher'].search([('partner_id','=', self.id),('type','=','payment')]) self.sum_payments = sum(item.amount for item in payment) sum_payments = fields.Float(string="# Sum", compute='_get_sum_payment')

Giovanny Vizcaya
on 11/1/15, 7:47 PM

solved?

Axel Mendoza
on 12/23/15, 4:09 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 10/25/15, 12:16 PM
Seen: 673 times
Last updated: 11/2/15, 9:08 PM