
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?
Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!
RegistrierenVerknüpfte Beiträge | Antworten | Ansichten | Aktivität | |
---|---|---|---|---|
|
0
März 25
|
1419 | ||
|
0
Jan. 25
|
3498 | ||
|
1
Aug. 23
|
14865 | ||
change password
Gelöst
|
|
1
Aug. 23
|
13511 | |
|
1
Juli 23
|
10489 |