I created a custom Budget module (which I'm willing to share with the community once it works), with a readonly field "real amount" which is the sum of all invoices of a given project (to know the amount spent and compare with planned amount). Unfortunately, I don't understand how I can update and save this value.
What I would like to do:
1) Select a budget element in the list
2) Update and save its real amount by calculating all related invoices
3) Show the budget element in object detail with the updated value
4) Even if we don't make any modifications and don't save, the value is saved in database
Or better solution but I'm not sure it is possible: update all "real amount" columns when list of budget (in list area) is shown.
I tried to update value in the Budget constructor, but I can't use $this->save(), Budget isn't loading anymore. If I remove the $this->save() and I save manually the element, it says "No change to update" although the real amount field has changed.
I'm sure that's not a big deal but I keep looking and can't find how to do that. As you better know the application than me, do you know how I could achieve that?
I think the way you try to do it is not the good one.
It's better to take the problem the other way round.
Change the save() method of the Bill object (corresponding to invoices), so that each time you save an invoce the corresponding budget is updated.
It is how is it done to sum up values from work, to assignments, to activities and to projects.
Have a look at PlanningElement object to see examples.
Yes, I think of that way but I thought there would be too many cases to take into account (creation, update, delete, maybe other special cases I don't think of).
I will see when I get back to it in 2 weeks, thank you for your answer!
In Budget, add new public method : updateSynthesis (look in PlanningElement for example).
In Bill, on save() and deleted() (after parent::save() and parent::delete()), call updateSynthesis() for corresponding Budget.
That's all.
En poursuivant votre navigation, vous acceptez le dépôt de cookies tiers destinés au bon fonctionnement et à la sécurisation du site (gestion de session, reCaptcha) et à une analyse statistique anonymisée des accès sur notre site (Google Analytics). Si vous vous inscrivez, les informations que vous fournirez ne seront jamais divulguées à un tiers sous quelque forme que ce soit. En savoir plus
Cookies settings
×
Functional Cookies
Ce site utilise des cookies pour assurer son bon fonctionnement et ne peuvent pas être désactivés de nos systèmes. Nous ne les utilisons pas à des fins publicitaires. Si ces cookies sont bloqués, certaines parties du site ne pourront pas fonctionner.
Session
Please login to see yours activities!
Other cookies
Ce site web utilise un certain nombre de cookies pour gérer, par exemple, les sessions utilisateurs.