I have created a table in Odoo, where I set the date and time of beginning and end of some activities.
What I want to do is that when the end date and time is less than the current date, update a field in the record.
You can use #api.onchange() or compute function to update value of field depending up on another field add #api.depends(field_name) , you write your condition inside this function so whenever value of a field changes this function will be triggered.
you can refer this link for oncahnge and compute function
Related
I have a DDB table, 4 attributes, key (PK - a string), date (sort/range key), status, frequency.
I have multiple clients that will write to this table based on the 'key' and date value
I want to increment frequency every time a client makes a write.
Can I just use DynamoDBVersionAttribute on an int field and use this as a proxy for frequency?
I understand this is not meant for this use case, but I want to avoid having to first read and then write the item. Any thoughts?
Since you're already doing an update expression, just add an ADD action to increment the frequency by 1. The ADD action doesn't need to know the original value to increment it.
See the example from the docs here:
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html#Expressions.UpdateExpressions.SET.IncrementAndDecrement
I'm creating my portfolio with Symfony 3 and I want to show my skills with my experience.
I have a "Skill" entity with a "startAt" param (type=datetime) and a "exp" param (string).
The "exp" param = the difference between "startAt" and the current date.
I add some lifecycle callback so the "exp" param update every time I touch my "Skill" entity but here is my question:
How can I update my entity every day without touching it?
For exemple right now I have "exp = 6 months" but next month this param need to be "7 months".
Since "startAt" is likely mapped to a field name in the database called "start_at", this date is all the data you need to set and store. The method in the entity called getExp(), which maps to the variable "exp" would then take $this->startAt() value and calculate the difference between that start at time and the current time. You can use the PHP DateTime object to calculate the difference in units of days, months or years, depending on your preference.
Also, "exp" doesn't need to be a field you need to store or map to the database because it can easily be calculated on the fly based on the "startAt" date value anyway.
create a command that update your entity and make a cron tab with it
I created a database to keep track of customer service related follow-ups in a call centre environment.
My table has, among the others, a Date created field, a Due date field and a Status field (Open, Due or Overdue).
I would like the value indicated in the Status field to update automatically as time elapses.
Can this be achieved and how?
This is absolutely possible. Why not? I would suggest you do the following:
(1) add another status to the status field called 'closed'
(2) determine from a logorithmic perspective what 'Due' means (e.g. if the current date falls within 5 days of your due date
(3) Write a query which updates your status either 'due' or 'overdue' depending on what the current date is
UPDATE tblDue SET tblDue.Status = "Due"
WHERE (((tblDue.DueDate)=Now()));
UPDATE tblDue SET tblDue.Status = "Overdue"
WHERE (((tblDue.DueDate)>Now()));
I'm looking to either show an error message (fail) the report, if the end time filter is selected as being earlier than the start time filter, or disallow a user from selecting an end time that is before the currently selected start time.
Any ideas? I do not want to lose the pop up calendar functionality for the end time filter. I also don't want to set any kind of default value for the end time based on the start time.
I think Error message is your option.
I looked into this earlier, I couldn't find much on it. Can't really restrict what user can pick unless you want to put valid available dates into a dropdown. If you want the datepicker(popup calendar) and you don't want to set a default for end date based on startdate, then just let the user pick, check if #EndDate < #StartDate either in you query or in an expression of the item you choose to display your message to the user.
Hope it helps
I have one getCMSField_forpopup form for an event. I made another popup inside that to give multiple dates to that event(using has_many relation). When I give date 2 different dates/times to event "A" and then after saving event "A", I open main getCMSField_forpopup to enter details of another event "B" then I see dates/times (complextablefield) already there which were actually meant to appear in event A's detail not in event "B". I want to see those only with A not with every new event. How can I make that possible ?
Your problem is that you enter Dates for 1 Event, but then you can see this Dates on every single Event?
to me this sounds like either your Event has no ID at this time and therefore a query on Dates "WHERE EventID = x" does not work, or your Dates get saved without the ID of the Event
You could simply check your database if your Dates have the ID of an Event set.
If the ID if the Event is 0, then the issue is that you are not saving the event ID, this either means that:
you have created the Dates before saving the Event, in this case the solution is just saving the Event before you add Dates, you could also hide the Dates field when it has not been saved, see below the $this->isNew() stuff
or silverstripe fails to save the EventID, in this case you could fix it by adding a hidden field to your getCMSFields_forPopup of the Date and save the Event ID there, but its gonna be a little tricky getting this ID into the popup
if this is not the issue, then the problem is that when you create a new Event it has no ID, and therefore can not filter by ID, you can simply do this inside your getCMSFields_forPopup of the Event:
if (!$this->isNew()) {
// add your ComplexTableField for Dates here so it only
// gets added if this record has already been saved
}
But actually I would recommend using nested DataObjectManager (a DataObjectManager inside a DataObjectManager)(see tutorial on youtube: http://youtu.be/eeXOTlXFmQQ), DataObjectManager does all that work for you, so this problem should not occur.
It only displays the DataObjectManager for Dates if you have already saved the Event once, otherwise it tells the user that he needs to save it first.
And it also sets the Event ID on the Dates for you
Or, even better, you could upgrade to SilverStripe 3, where you can use GridField.
GridField works way better then DataObjectManager and looks a lot nicer.