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?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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?
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")
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...
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')
solved?
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Aug 23
|
12549 | ||
change password
Solved
|
|
1
Aug 23
|
11054 | |
|
1
Jul 23
|
7228 | ||
|
4
Apr 23
|
8677 | ||
|
2
Feb 23
|
17598 |