def check_import(self, cr, uid, vals, context=None): if context is None: context = {} ids = [] for val in vals: obj_tm = self.pool.get('res.users').browse( cr, uid, uid, context=context).company_id.project_time_mode_id if not val.get('planned_hours', False): # 'Computes duration' in days plan = 0.0 if val.get('date') and val.get('date_deadline'): start = datetime.strptime(val['date'], '%Y-%m-%d %H:%M:%S') end = datetime.strptime(val['date_deadline'], '%Y-%m-%d %H:%M:%S') diff = end - start plan = (diff.seconds / float(86400) + diff.days) * obj_tm.factor val['planned_hours'] = plan else: # Converts timedelta into hours hours = (val['planned_hours'].seconds / float(3600)) + \ (val['planned_hours'].days * 24) val['planned_hours'] = hours exists, r_id = calendar.uid2openobjectid(cr, val['id'], self._name, val.get('recurrent_id')) val.pop('id') if exists: self.write(cr, uid, [exists], val) ids.append(exists) else: task_id = self.create(cr, uid, val) ids.append(task_id) return ids
def check_import(self, cr, uid, vals, context=None): if context is None: context = {} ids = [] for val in vals: obj_tm = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.project_time_mode_id if not val.get('planned_hours', False): # 'Computes duration' in days plan = 0.0 if val.get('date') and val.get('date_deadline'): start = datetime.strptime(val['date'], '%Y-%m-%d %H:%M:%S') end = datetime.strptime(val['date_deadline'], '%Y-%m-%d %H:%M:%S') diff = end - start plan = (diff.seconds/float(86400) + diff.days) * obj_tm.factor val['planned_hours'] = plan else: # Converts timedelta into hours hours = (val['planned_hours'].seconds / float(3600)) + \ (val['planned_hours'].days * 24) val['planned_hours'] = hours exists, r_id = calendar.uid2openobjectid(cr, val['id'], self._name, val.get('recurrent_id')) val.pop('id') if exists: self.write(cr, uid, [exists], val) ids.append(exists) else: #set user_id with id, needed later val.update({'user_id' : uid}) task_id = self.create(cr, uid, val) ids.append(task_id) return ids
def check_import(self, cr, uid, vals, context=None): if context is None: context = {} ids = [] for val in vals: obj_tm = self.pool.get("res.users").browse(cr, uid, uid, context=context).company_id.project_time_mode_id if not val.get("planned_hours", False): # 'Computes duration' in days plan = 0.0 if val.get("date") and val.get("date_deadline"): start = datetime.strptime(val["date"], "%Y-%m-%d %H:%M:%S") end = datetime.strptime(val["date_deadline"], "%Y-%m-%d %H:%M:%S") diff = end - start plan = (diff.seconds / float(86400) + diff.days) * obj_tm.factor val["planned_hours"] = plan else: # Converts timedelta into hours hours = (val["planned_hours"].seconds / float(3600)) + (val["planned_hours"].days * 24) val["planned_hours"] = hours exists, r_id = calendar.uid2openobjectid(cr, val["id"], self._name, val.get("recurrent_id")) val.pop("id") if exists: self.write(cr, uid, [exists], val) ids.append(exists) else: task_id = self.create(cr, uid, val) ids.append(task_id) return ids
def check_import(self, cr, uid, vals, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param vals: Get Values @param context: A standard dictionary for contextual values """ if context is None: context = {} ids = [] model_obj = self.pool.get(context.get('model')) recur_pool = {} try: for val in vals: # Compute value of duration if val.get('date_deadline', False) and 'duration' not in val: start = datetime.strptime(val['date'], '%Y-%m-%d %H:%M:%S') end = datetime.strptime(val['date_deadline'], '%Y-%m-%d %H:%M:%S') diff = end - start val['duration'] = (diff.seconds / float(86400) + diff.days) * 24 exists, r_id = calendar.uid2openobjectid(cr, val['id'], context.get('model'), \ val.get('recurrent_id')) if val.has_key('create_date'): val.pop('create_date') u_id = val.get('id', None) val.pop('id') if exists and r_id: val.update({'recurrent_uid': exists}) model_obj.write(cr, uid, [r_id], val) ids.append(r_id) elif exists: model_obj.write(cr, uid, [exists], val) ids.append(exists) else: if u_id in recur_pool and val.get('recurrent_id'): val.update({'recurrent_uid': recur_pool[u_id]}) revent_id = model_obj.create(cr, uid, val) ids.append(revent_id) else: __rege = re.compile( r'OpenObject-([\w|\.]+)_([0-9]+)@(\w+)$') wematch = __rege.match(u_id.encode('utf8')) if wematch: model, recur_id, dbname = wematch.groups() val.update({'recurrent_uid': recur_id}) event_id = model_obj.create(cr, uid, val) recur_pool[u_id] = event_id ids.append(event_id) except Exception: raise return ids
def check_import(self, cr, uid, vals, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param vals: Get Values @param context: A standard dictionary for contextual values """ if context is None: context = {} ids = [] model_obj = self.pool.get(context.get('model')) recur_pool = {} try: for val in vals: # Compute value of duration if val.get('date_deadline', False) and 'duration' not in val: start = datetime.strptime(val['date'], '%Y-%m-%d %H:%M:%S') end = datetime.strptime(val['date_deadline'], '%Y-%m-%d %H:%M:%S') diff = end - start val['duration'] = (diff.seconds/float(86400) + diff.days) * 24 exists, r_id = calendar.uid2openobjectid(cr, val['id'], context.get('model'), \ val.get('recurrent_id')) if val.has_key('create_date'): val.pop('create_date') u_id = val.get('id', None) val.pop('id') if exists and r_id: val.update({'recurrent_uid': exists}) model_obj.write(cr, uid, [r_id], val) ids.append(r_id) elif exists: model_obj.write(cr, uid, [exists], val) ids.append(exists) else: if u_id in recur_pool and val.get('recurrent_id'): val.update({'recurrent_uid': recur_pool[u_id]}) revent_id = model_obj.create(cr, uid, val) ids.append(revent_id) else: __rege = re.compile(r'OpenObject-([\w|\.]+)_([0-9]+)@(\w+)$') wematch = __rege.match(u_id.encode('utf8')) if wematch: model, recur_id, dbname = wematch.groups() val.update({'recurrent_uid': recur_id}) event_id = model_obj.create(cr, uid, val) recur_pool[u_id] = event_id ids.append(event_id) except Exception: raise return ids