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