date des evenements recurrent reglé
This commit is contained in:
parent
1eef4a6e4f
commit
5e3133f06b
@ -17,8 +17,19 @@
|
||||
|
||||
""" GOLEM activities related models """
|
||||
|
||||
import collections
|
||||
from datetime import datetime, timedelta
|
||||
from dateutil import parser
|
||||
#from dateutil import rrule
|
||||
from dateutil.rrule import WEEKLY, rrule
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from datetime import timedelta
|
||||
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
||||
#from dateutil import rrule
|
||||
#from dateutil.rrule import rrule
|
||||
#from dateutil.rrule import rrule
|
||||
|
||||
class GolemActivityType(models.Model):
|
||||
""" GOLEM Activity Type """
|
||||
@ -143,13 +154,13 @@ class GolemActivity(models.Model):
|
||||
if not activity.date_stop:
|
||||
activity.date_stop = activity.season_id.date_end
|
||||
|
||||
weekday = fields.Selection([('mon', _('Monday')),
|
||||
('tue', _('Tuesday')),
|
||||
('wed', _('Wednesday')),
|
||||
('thu', _('Thursday')),
|
||||
('fri', _('Friday')),
|
||||
('sat', _('Saturday')),
|
||||
('sun', _('Sunday'))], copy=False)
|
||||
weekday = fields.Selection([(0, _('Monday')),
|
||||
(1, _('Tuesday')),
|
||||
(2, _('Wednesday')),
|
||||
(3, _('Thursday')),
|
||||
(4, _('Friday')),
|
||||
(5, _('Saturday')),
|
||||
(6, _('Sunday'))], copy=False)
|
||||
hour_start = fields.Float('Start time', copy=False)
|
||||
hour_stop = fields.Float('Stop time', copy=False)
|
||||
|
||||
@ -191,7 +202,15 @@ class GolemActivity(models.Model):
|
||||
result = []
|
||||
for calendar_id, real_id in select:
|
||||
res = real_data[real_id].copy()
|
||||
|
||||
date_start = str(calendar_id).split('_')
|
||||
if len(date_start) == 2:
|
||||
dt = datetime.strptime(date_start[1],DEFAULT_SERVER_DATETIME_FORMAT).date()# "%y-%m-%d %H:%M:%S")
|
||||
res['date_start'] = str(dt)
|
||||
res['id'] = calendar_id
|
||||
|
||||
|
||||
#res['date_start'] = date_start[1]
|
||||
result.append(res)
|
||||
return result
|
||||
|
||||
@ -223,16 +242,23 @@ class GolemActivity(models.Model):
|
||||
|
||||
@api.multi
|
||||
def real_id2calendar_id(self, record_id):
|
||||
""" convert Real Id to Calendar ID """
|
||||
activity = self.env['golem.activity'].browse(record_id)
|
||||
dates = []
|
||||
delta = timedelta(days=7)
|
||||
date = fields.Date.from_string(activity.date_start)
|
||||
while date <= fields.Date.from_string(activity.date_stop):
|
||||
print date
|
||||
print activity.date_stop
|
||||
dates.append('%s_%s' % (record_id, date))
|
||||
date += delta
|
||||
return dates
|
||||
date_start = fields.Date.from_string(activity.date_start)
|
||||
date_stop = fields.Date.from_string(activity.date_stop)
|
||||
weekday = 0#date_start.weekday()
|
||||
if activity.weekday:
|
||||
weekday = activity.weekday
|
||||
print '_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-'
|
||||
print weekday
|
||||
list_date = list(rrule(freq=WEEKLY, dtstart=date_start, until=date_stop, byweekday=weekday))
|
||||
calendar_ids = []
|
||||
for date in list_date:
|
||||
calendar_ids.append('%s_%s' % (record_id, date))
|
||||
print '_______________________________________________'
|
||||
print calendar_ids
|
||||
return calendar_ids
|
||||
|
||||
|
||||
@api.multi
|
||||
def get_recurrent_ids(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user