def get_turn(self, cr, uid, ids, date, context=None): res = {} if isinstance(date, str): date = tu.dt(date) for cont in self.browse(cr, uid, ids): if (tu.d(cont.date_start) <= date and (cont.date_end == False or date <= tu.d(cont.date_end))): ts = filter( lambda i: i.dayofweek == str(date.weekday()) or i.dayofweek == '', cont.turn_id.timesheet_id) if len(ts) == 1: ddate = tu.datetime.combine(date.date(), tu.time(0)) res[cont.id] = ( ddate + tu.timedelta(hours=ts[0].hour_from), ddate + tu.timedelta(hours=24 * (ts[0].hour_from > ts[0].hour_to) + ts[0].hour_to)) elif len(ts) > 1: raise RuntimeError( "More than one turn enabled at same time. See Timesheet line." ) else: res[cont.id] = False else: res[cont.id] = False return res
def get_turn(self, cr, uid, ids, date, context=None): res = {} if isinstance(date, str): date = tu.dt(date) for cont in self.browse(cr, uid, ids): if (tu.d(cont.date_start) <= date and (cont.date_end == False or date <= tu.d(cont.date_end))): ts = filter(lambda i: i.dayofweek == str(date.weekday()) or i.dayofweek == '', cont.turn_id.timesheet_id) if len(ts) == 1: ddate = tu.datetime.combine(date.date(), tu.time(0)) res[cont.id] = (ddate + tu.timedelta(hours=ts[0].hour_from), ddate + tu.timedelta(hours= 24 * (ts[0].hour_from > ts[0].hour_to) + ts[0].hour_to)) elif len(ts) > 1: raise RuntimeError("More than one turn enabled at same time. See Timesheet line.") else: res[cont.id] = False else: res[cont.id] = False return res
def _get_turn_date(self, cr, uid, ids, field_name, arg, context=None): res = self._get_turn_start(cr, uid, ids, field_name, arg, context=context) if not res: return False for k in res: if res[k]: res[k] = tu.dt2s( tu.datetime.combine(tu.dt(res[k]).date(), tu.time(0))) return res
def _get_date(self, cr, uid, ids, field_name, arg, context=None): res = map(lambda a: (a.id, tu.dt2s(tu.datetime.combine(tu.dt(a.name).date(),tu.time(0)))), self.browse(cr, uid, ids)) return dict(res)