odoo 8 auto count days field - odoo

I have this Interest Age (days) field which I want to be able to shown count of days between a specified date from other field and to day, so that everytime I open the page it will update the days
date_hpp_start = fields.Date('HPP Date start')
#api.multi
#api.depends('date_hpp_start')
def _compute_difference(self):
for rec in self:
if rec.date_hpp_start:
converted_date = datetime.datetime.strptime(rec.date_hpp_start, '%Y-%m-%d').date()
rec.days_difference = (datetime.date.today() - converted_date).days
days_difference = fields.Integer(string='Interest Age (days)', store=True, compute=_compute_difference)
This is not correct because with this code,the days only be changed everytime I choose the HPP Date start field.
Thank you.

I found that the problem is on the store=True, and after I removed it, it shown the days according to the counter.

Related

How to calculation 'Next Birthday' in a Podio field

I want to be able to calculate the 'Next Birthday' date from a 'Date of Birth' field in Podio.
I cannot seem to get the calculation that makes this work.
Please try the below calculation
var dob = #DOB;
var nextDOB = moment(new Date(new Date(dob).setFullYear(new
Date().getFullYear() + 1))).format('DD/MM/YYYY');;
nextDOB+"";
Here, we are using the JS to get the next year date corresponding to the DOB field and parse it using moment js
It should be noted that this field will only calculate when the #DOB field is changed, so this will only work for the first 'next' birthday that comes up. I'd recommend using the API to set an actual date field instead of trying to use calculation fields for this.

Podio Age Calculation

My organisation has a Podio calculation field (see code below) to calculate the age of a person.
In order to get this field to update daily (because we need up to date data), the associated field #Date Today is updated with a Globiflow flow with today's date.
At the moment, there are ~1800 records and growing. So if this is run every day we are going way over the limits set by Globiflow (http://www.globiflow.com/help/globiflow-plans-and-limits.php).
Any ideas on more elegant ways to achieve this without using up our workflows? Essentially I need to calculate the age of each person, each day.
JS in Podio 'Age' field:
var date = #Date Of Birth;
var dateCalc = moment(date);
var currentDate = moment(#Date Today);
var calc = currentDate.diff(dateCalc, 'y','m');
date != null ? calc : null
Thanks
Shaun
One idea is to have an app with single item to keep the today's date. Update this single item everyday using GlobiFlow with today's date.
This item should be referred in all the 1800 Person items. Now use the today date from this single item in age calculation in person app. You can have a GlobiFlow to refer this single item automatically when ever a new Person is created.

Date is not refreshing based on the Combo value in SSRS

I have a SSRS report with following fields:
1. Season.
2. Start Date
3. End Date
Whenever season changes, the default date for start-date and end-date needs to be changed. I created a dataset which populate start-date and end-date values based on the season input and assigned the values to Startdate and enddate parameters. In Report, when season selected for first time default-date has changed correctly. But when I change the Season to another value, default-date are not refreshing. What is the problem here?
I have attached the screenshots below. Could someone help me on this?
First Screen-shot shows the default dates for Season 1 (Tax season)
Second Screen-shot shows the default dates for Season 2 (Pre-season) (After Changing Season-1 to Season-2 default date values are not changing )
I found out this issue occurs because the call to data-set is not happened in the second refresh.
Thanks for the help
Your dataset for the dates has to include
SELECT start-date, end-date FROM Table
WHERE Season = #Season
then Default the values for the date parameters to select from the dataset and it will change them when ever you change the season.

How can I generate an ID that will reset every year?

I need help in VB.net I'm a newbie in programming.
I have a problem in generating an ID with the format
`yyyy` = now.year
`mm` = now.month
`0000` = auto number
I want to increment the auto number everytime I add records
so it goes like this
2014090001
and also it will reset back to 0000 when year changes.
thank you for all your replies, I took all your advice and I got a solution CONSIDER THIS THREAD AS CLOSE!!
my final solution is creating another table in database with the fields ID, counter, and YEAR
I created a condition that will test the current year, so if the year = now.year the counter will just increment by 1 and if year <> to now.year then the counter will back to 0. it will add up another records in that table so the use of ID is to delete the previous records.

Adding a Date Range

I have an Adobe time sheet where I need to populate all of the date fields based on a beginning date.
For instance if I enter 08-01-11 I need the end date to automatically add 28 days.
Then below, I need all the date fields in the column to list 08-01-11, 08-02-11, etc. The first and last entry should equal the start date and end date.
I have researched for the last few hours but I am unable to find a solution.
Any help would be greatly appreciated.
Thanks.
Tom M.
I did a quick experiment. (I used 7 dates instead of 28 to reduce repetitive work.)
First I created a simple document in Word with a table and some static text labeling the different fields and leaving room for the text fields.
Next, I print to PDF and open the PDF in Acrobat. Here I add 9 text fields. 2 for the start and end dates and 7 for the consecutive dates. I call them startDate, endDate, date1, ..., date7. I set the format of all fields to Date. I make all fields except startDate read-only.
Next, I go the Calculate tab of the endDate field and enter the following JavaScript code (Custom calculatation script):
var f = this.getField("startDate");
var d = new Date(f.value);
d.setDate(d.getDate()+6);
event.value = util.printd("mm/dd/yyyy", d);
I do something similar for the date1, ..., date7 fields.
You can download the result here:
http://download.tallcomponents.com/timesheet.pdf
Frank Rem, http://www.tallcomponents.com