Odoo Help

Welcome!

This community 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.

0

How can i do this operation y odoo?

By
Giovanny Vizcaya
on 10/25/15, 12:16 PM 317 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

--Axel Mendoza--
10228
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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