View ProjeQtOr On SourceForge.net
ProjeQtOr - Project Management Tool
Support us on Capterra
OIN - Open Invention Network
ProjeQtOr free project management software - Update and save a custom readonly field before object detail loads - ProjeQtOr
 
 

Update and save a custom readonly field before object detail loads

More
19 Jun 2015 16:05 #1 by papjul
Hi,

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?

Thank you,

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 17:36 #2 by babynus
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.

Babynus
Administrator of ProjeQtOr web site

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 22:20 #3 by papjul
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!

Please Log in or Create an account to join the conversation.

More
20 Jun 2015 20:46 #4 by babynus
Not so complex.

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.

Babynus
Administrator of ProjeQtOr web site
The following user(s) said Thank You: papjul

Please Log in or Create an account to join the conversation.

More
03 Jul 2015 08:54 #5 by papjul
Thanks, it worked (I had to add it to delete() in BillLine too).

Please Log in or Create an account to join the conversation.

Moderators: babynusprotion
Time to create page: 0.031 seconds

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.