Hello everyone,
Got this code done but it wont work. What should I do to get number of days and weeks ?
Two fields: days and weeks defined as a _computed fields
.....
_columns = {
'st_date': fields.date('Start date'),
'en_date': fields.date('End date'),
'product': fields.one2many('product.data','check_id', string="Product"),
'days': fields.char(_compute='days_between', string='NoD'),
'weeks': fields.char(_compute='weeks_between', string='NoW'),
}
def days_between(st_date,en_date):
st_date = datetime.strptime('st_date', "%Y-%m-%d")
en_date = datetime.strptime('en_date', "%Y-%m-%d")
return abs((en_date - st_date).days)
print 'test==days'
print days_between('2013-05-06', '2013-06-06')
def weeks_between(st_date,en_date):
weeks = rrule.rrule(rrule.WEEKLY, dtstart=st_date, until=en_date)
return weeks.count()
print 'test==weeks'
print 'weeks between', weeks
.....