bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def _set_data(self, cr, uid, meeting_id, name, value, arg, context): if not value: return attendee_obj = self.pool.get('calendar.attendee') model_obj = self.pool.get('ir.model') alarm_obj = self.pool.get('calendar.alarm') eventdata = self.read(cr, uid, meeting_id, [name], context=context) if name == "attendees": attendee_ids = attendee_obj.import_cal(cr, uid, eventdata['attendees']) vals = { 'ref':'%s,%d'%('crm.meeting', meeting_id) } attendee_obj.write(cr, uid, attendee_ids, vals) if name == "alarms": model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] alarm_ids = alarm_obj.import_cal(cr, uid, eventdata['alarms']) vals = { 'res_id' : meeting.id, 'model_id' : model_id, } alarm_obj.write(cr, uid, alarm_ids, vals) alarm = alarm_obj.browse(cr, uid, alarm_ids)[0] self.write(cr, uid, [meeting_id], {'alarm_id':alarm.alarm_id}) return True
def _set_data(self, cr, uid, meeting_id, name, value, arg, context): if not value: return attendee_obj = self.pool.get('calendar.attendee') model_obj = self.pool.get('ir.model') alarm_obj = self.pool.get('calendar.alarm') eventdata = self.read(cr, uid, meeting_id, [name], context=context) if name == "attendees": attendee_ids = attendee_obj.import_cal(cr, uid, eventdata['attendees']) vals = { 'ref':'%s,%d'%('crm.meeting', meeting_id) } attendee_obj.write(cr, uid, attendee_ids, vals) if name == "alarms": model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] alarm_ids = alarm_obj.import_cal(cr, uid, eventdata['alarms']) vals = { 'res_id' : meeting.id, 'model_id' : model_id, } alarm_obj.write(cr, uid, alarm_ids, vals) alarm = alarm_obj.browse(cr, uid, alarm_ids)[0] self.write(cr, uid, [meeting_id], {'alarm_id':alarm.alarm_id}) return True
470,300
def _set_data(self, cr, uid, meeting_id, name, value, arg, context): if not value: return attendee_obj = self.pool.get('calendar.attendee') model_obj = self.pool.get('ir.model') alarm_obj = self.pool.get('calendar.alarm') eventdata = self.read(cr, uid, meeting_id, [name], context=context) if name == "attendees": attendee_ids = attendee_obj.import_cal(cr, uid, eventdata['attendees']) vals = { 'ref':'%s,%d'%('crm.meeting', meeting_id) } attendee_obj.write(cr, uid, attendee_ids, vals) if name == "alarms": model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] alarm_ids = alarm_obj.import_cal(cr, uid, eventdata['alarms']) vals = { 'res_id' : meeting.id, 'model_id' : model_id, } alarm_obj.write(cr, uid, alarm_ids, vals) alarm = alarm_obj.browse(cr, uid, alarm_ids)[0] self.write(cr, uid, [meeting_id], {'alarm_id':alarm.alarm_id}) return True
def _set_data(self, cr, uid, meeting_id, name, value, arg, context): if not value: return attendee_obj = self.pool.get('calendar.attendee') model_obj = self.pool.get('ir.model') alarm_obj = self.pool.get('calendar.alarm') eventdata = self.read(cr, uid, meeting_id, [name], context=context) if name == "attendees": attendee_ids = attendee_obj.import_cal(cr, uid, eventdata['attendees']) vals = { 'ref':'%s,%d'%('crm.meeting', meeting_id) } attendee_obj.write(cr, uid, attendee_ids, vals) if name == "alarms": model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] alarm_ids = alarm_obj.import_cal(cr, uid, eventdata['alarms']) vals = { 'res_id' : meeting.id, 'model_id' : model_id, } alarm_obj.write(cr, uid, alarm_ids, vals) alarm = alarm_obj.browse(cr, uid, alarm_ids)[0] self.write(cr, uid, [meeting_id], {'alarm_id':alarm.alarm_id}) return True
470,301
def _set_data(self, cr, uid, meeting_id, name, value, arg, context): if not value: return attendee_obj = self.pool.get('calendar.attendee') model_obj = self.pool.get('ir.model') alarm_obj = self.pool.get('calendar.alarm') eventdata = self.read(cr, uid, meeting_id, [name], context=context) if name == "attendees": attendee_ids = attendee_obj.import_cal(cr, uid, eventdata['attendees']) vals = { 'ref':'%s,%d'%('crm.meeting', meeting_id) } attendee_obj.write(cr, uid, attendee_ids, vals) if name == "alarms": model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] alarm_ids = alarm_obj.import_cal(cr, uid, eventdata['alarms']) vals = { 'res_id' : meeting.id, 'model_id' : model_id, } alarm_obj.write(cr, uid, alarm_ids, vals) alarm = alarm_obj.browse(cr, uid, alarm_ids)[0] self.write(cr, uid, [meeting_id], {'alarm_id':alarm.alarm_id}) return True
def _set_data(self, cr, uid, meeting_id, name, value, arg, context): if not value: return attendee_obj = self.pool.get('calendar.attendee') model_obj = self.pool.get('ir.model') alarm_obj = self.pool.get('calendar.alarm') eventdata = self.read(cr, uid, meeting_id, [name], context=context) if name == "attendees": attendee_ids = attendee_obj.import_cal(cr, uid, eventdata['attendees']) vals = { 'ref':'%s,%d'%('crm.meeting', meeting_id) } attendee_obj.write(cr, uid, attendee_ids, vals) if name == "alarms": model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] alarm_ids = alarm_obj.import_cal(cr, uid, eventdata['alarms']) vals = { 'res_id' : meeting.id, 'model_id' : model_id, } alarm_obj.write(cr, uid, alarm_ids, vals) alarm = alarm_obj.browse(cr, uid, alarm_ids)[0] self.write(cr, uid, [meeting_id], {'alarm_id':alarm.alarm_id}) return True
470,302
def _set_data(self, cr, uid, meeting_id, name, value, arg, context): if not value: return attendee_obj = self.pool.get('calendar.attendee') model_obj = self.pool.get('ir.model') alarm_obj = self.pool.get('calendar.alarm') eventdata = self.read(cr, uid, meeting_id, [name], context=context) if name == "attendees": attendee_ids = attendee_obj.import_cal(cr, uid, eventdata['attendees']) vals = { 'ref':'%s,%d'%('crm.meeting', meeting_id) } attendee_obj.write(cr, uid, attendee_ids, vals) if name == "alarms": model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] alarm_ids = alarm_obj.import_cal(cr, uid, eventdata['alarms']) vals = { 'res_id' : meeting.id, 'model_id' : model_id, } alarm_obj.write(cr, uid, alarm_ids, vals) alarm = alarm_obj.browse(cr, uid, alarm_ids)[0] self.write(cr, uid, [meeting_id], {'alarm_id':alarm.alarm_id}) return True
def _set_data(self, cr, uid, meeting_id, name, value, arg, context): if not value: return attendee_obj = self.pool.get('calendar.attendee') model_obj = self.pool.get('ir.model') alarm_obj = self.pool.get('calendar.alarm') eventdata = self.read(cr, uid, meeting_id, [name], context=context) if name == "attendees": attendee_ids = attendee_obj.import_cal(cr, uid, eventdata['attendees']) vals = { 'ref':'%s,%d'%('crm.meeting', meeting_id) } attendee_obj.write(cr, uid, attendee_ids, vals) if name == "alarms": model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] alarm_ids = alarm_obj.import_cal(cr, uid, eventdata['alarms']) vals = { 'res_id' : meeting.id, 'model_id' : model_id, } alarm_obj.write(cr, uid, alarm_ids, vals) alarm = alarm_obj.browse(cr, uid, alarm_ids)[0] self.write(cr, uid, [meeting_id], {'alarm_id':alarm.alarm_id}) return True
470,303
def _set_data(self, cr, uid, meeting_id, name, value, arg, context): if not value: return attendee_obj = self.pool.get('calendar.attendee') model_obj = self.pool.get('ir.model') alarm_obj = self.pool.get('calendar.alarm') eventdata = self.read(cr, uid, meeting_id, [name], context=context) if name == "attendees": attendee_ids = attendee_obj.import_cal(cr, uid, eventdata['attendees']) vals = { 'ref':'%s,%d'%('crm.meeting', meeting_id) } attendee_obj.write(cr, uid, attendee_ids, vals) if name == "alarms": model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] alarm_ids = alarm_obj.import_cal(cr, uid, eventdata['alarms']) vals = { 'res_id' : meeting.id, 'model_id' : model_id, } alarm_obj.write(cr, uid, alarm_ids, vals) alarm = alarm_obj.browse(cr, uid, alarm_ids)[0] self.write(cr, uid, [meeting_id], {'alarm_id':alarm.alarm_id}) return True
def _set_data(self, cr, uid, meeting_id, name, value, arg, context): if not value: return attendee_obj = self.pool.get('calendar.attendee') model_obj = self.pool.get('ir.model') alarm_obj = self.pool.get('calendar.alarm') eventdata = self.read(cr, uid, meeting_id, [name], context=context) if name == "attendees": attendee_ids = attendee_obj.import_cal(cr, uid, eventdata['attendees']) vals = { 'ref':'%s,%d'%('crm.meeting', meeting_id) } attendee_obj.write(cr, uid, attendee_ids, vals) if name == "alarms": model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] alarm_ids = alarm_obj.import_cal(cr, uid, eventdata['alarms']) vals = { 'res_id' : meeting.id, 'model_id' : model_id, } alarm_obj.write(cr, uid, alarm_ids, vals) alarm = alarm_obj.browse(cr, uid, alarm_ids)[0] self.write(cr, uid, [meeting_id], {'alarm_id':alarm.alarm_id}) return True
470,304
def _set_data(self, cr, uid, meeting_id, name, value, arg, context): if not value: return attendee_obj = self.pool.get('calendar.attendee') model_obj = self.pool.get('ir.model') alarm_obj = self.pool.get('calendar.alarm') eventdata = self.read(cr, uid, meeting_id, [name], context=context) if name == "attendees": attendee_ids = attendee_obj.import_cal(cr, uid, eventdata['attendees']) vals = { 'ref':'%s,%d'%('crm.meeting', meeting_id) } attendee_obj.write(cr, uid, attendee_ids, vals) if name == "alarms": model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] alarm_ids = alarm_obj.import_cal(cr, uid, eventdata['alarms']) vals = { 'res_id' : meeting.id, 'model_id' : model_id, } alarm_obj.write(cr, uid, alarm_ids, vals) alarm = alarm_obj.browse(cr, uid, alarm_ids)[0] self.write(cr, uid, [meeting_id], {'alarm_id':alarm.alarm_id}) return True
def _set_data(self, cr, uid, meeting_id, name, value, arg, context): if not value: return attendee_obj = self.pool.get('calendar.attendee') model_obj = self.pool.get('ir.model') alarm_obj = self.pool.get('calendar.alarm') eventdata = self.read(cr, uid, meeting_id, [name], context=context) if name == "attendees": attendee_ids = attendee_obj.import_cal(cr, uid, eventdata['attendees']) vals = { 'ref':'%s,%d'%('crm.meeting', meeting_id) } attendee_obj.write(cr, uid, attendee_ids, vals) if name == "alarms": model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] alarm_ids = alarm_obj.import_cal(cr, uid, eventdata['alarms']) vals = { 'res_id' : meeting.id, 'model_id' : model_id, } alarm_obj.write(cr, uid, alarm_ids, vals) alarm = alarm_obj.browse(cr, uid, alarm_ids)[0] self.write(cr, uid, [meeting_id], {'alarm_id':alarm.alarm_id}) return True
470,305
def do_alarm_create(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') attendee_obj = self.pool.get('calendar.attendee') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0]
def do_alarm_create(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') attendee_obj = self.pool.get('calendar.attendee') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0]
470,306
def do_alarm_create(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') attendee_obj = self.pool.get('calendar.attendee') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0]
def do_alarm_create(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') attendee_obj = self.pool.get('calendar.attendee') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0]
470,307
def do_alarm_create(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') attendee_obj = self.pool.get('calendar.attendee') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0]
def do_alarm_create(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') attendee_obj = self.pool.get('calendar.attendee') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0]
470,308
def do_alarm_create(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') attendee_obj = self.pool.get('calendar.attendee') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0]
def do_alarm_create(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') attendee_obj = self.pool.get('calendar.attendee') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0]
470,309
def do_alarm_unlink(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] for meeting in self.browse(cr, uid, ids): alarm_ids = alarm_obj.search(cr, uid, [('model_id','=',model_id), ('res_id','=',meeting.id)]) if alarm_ids and len(alarm_ids): alarm_obj.unlink(cr, uid, alarm_ids) cr.commit() return True
def do_alarm_unlink(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] for meeting in self.browse(cr, uid, ids): alarm_ids = alarm_obj.search(cr, uid, [('model_id','=',model_id), ('res_id','=',meeting.id)]) if alarm_ids and len(alarm_ids): alarm_obj.unlink(cr, uid, alarm_ids) cr.commit() return True
470,310
def import_cal(self, cr, uid, data, context={}): file_content = base64.decodestring(data) event_obj = self.pool.get('basic.calendar.event') event_obj.__attribute__.update(self.__attribute__) vals = event_obj.import_ical(cr, uid, file_content) ids = [] for val in vals: is_exists = common.uid2openobjectid(cr, val['id'], self._name) if val.has_key('create_date'): val.pop('create_date') val['caldav_url'] = context.get('url') or '' val.pop('id') if is_exists: self.write(cr, uid, [is_exists], val) ids.append(is_exists) else: case_id = self.create(cr, uid, val) ids.append(case_id) return ids
def import_cal(self, cr, uid, data, context={}): file_content = base64.decodestring(data) event_obj = self.pool.get('basic.calendar.event') event_obj.__attribute__.update(self.__attribute__) vals = event_obj.import_ical(cr, uid, file_content) ids = [] for val in vals: is_exists = common.uid2openobjectid(cr, val['id'], self._name) if val.has_key('create_date'): val.pop('create_date') val['caldav_url'] = context.get('url') or '' val.pop('id') if is_exists: self.write(cr, uid, [is_exists], val) ids.append(is_exists) else: case_id = self.create(cr, uid, val) ids.append(case_id) return ids
470,311
def import_cal(self, cr, uid, data, context={}): file_content = base64.decodestring(data) event_obj = self.pool.get('basic.calendar.event') event_obj.__attribute__.update(self.__attribute__) vals = event_obj.import_ical(cr, uid, file_content) ids = [] for val in vals: is_exists = common.uid2openobjectid(cr, val['id'], self._name) if val.has_key('create_date'): val.pop('create_date') val['caldav_url'] = context.get('url') or '' val.pop('id') if is_exists: self.write(cr, uid, [is_exists], val) ids.append(is_exists) else: case_id = self.create(cr, uid, val) ids.append(case_id) return ids
def import_cal(self, cr, uid, data, context={}): file_content = base64.decodestring(data) event_obj = self.pool.get('basic.calendar.event') event_obj.__attribute__.update(self.__attribute__) vals = event_obj.import_ical(cr, uid, file_content) ids = [] for val in vals: is_exists = common.uid2openobjectid(cr, val['id'], self._name) if val.has_key('create_date'): val.pop('create_date') val['caldav_url'] = context.get('url') or '' val.pop('id') if is_exists: self.write(cr, uid, [is_exists], val) ids.append(is_exists) else: case_id = self.create(cr, uid, val) ids.append(case_id) return ids
470,312
def import_cal(self, cr, uid, data, context={}): file_content = base64.decodestring(data) event_obj = self.pool.get('basic.calendar.event') event_obj.__attribute__.update(self.__attribute__) vals = event_obj.import_ical(cr, uid, file_content) ids = [] for val in vals: is_exists = common.uid2openobjectid(cr, val['id'], self._name) if val.has_key('create_date'): val.pop('create_date') val['caldav_url'] = context.get('url') or '' val.pop('id') if is_exists: self.write(cr, uid, [is_exists], val) ids.append(is_exists) else: case_id = self.create(cr, uid, val) ids.append(case_id) return ids
def import_cal(self, cr, uid, data, context={}): file_content = base64.decodestring(data) event_obj = self.pool.get('basic.calendar.event') event_obj.__attribute__.update(self.__attribute__) vals = event_obj.import_ical(cr, uid, file_content) ids = [] for val in vals: is_exists = common.uid2openobjectid(cr, val['id'], self._name) if val.has_key('create_date'): val.pop('create_date') val['caldav_url'] = context.get('url') or '' val.pop('id') if is_exists: self.write(cr, uid, [is_exists], val) ids.append(is_exists) else: case_id = self.create(cr, uid, val) ids.append(case_id) return ids
470,313
def get_recurrent_ids(self, cr, uid, ids, base_start_date, base_until_date, limit=100): if not limit: limit = 100 if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") result = [] count = 0 for data in cr.dictfetchall(): start_date = base_start_date and datetime.datetime.strptime(base_start_date, "%Y-%m-%d") or False until_date = base_until_date and datetime.datetime.strptime(base_until_date, "%Y-%m-%d") or False if count > limit: break event_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") if start_date and start_date <= event_date: start_date = event_date if not data['rrule']: if start_date and event_date < start_date: continue if until_date and event_date > until_date: continue idval = common.real_id2caldav_id(data['id'], data['date']) result.append(idval) count += 1 else: exdate = data['exdate'] and data['exdate'].split(',') or [] event_obj = self.pool.get('basic.calendar.event') rrule_str = data['rrule'] new_rrule_str = [] rrule_until_date = False is_until = False for rule in rrule_str.split(';'): name, value = rule.split('=') if name == "UNTIL": is_until = True value = parser.parse(value) rrule_until_date = parser.parse(value.strftime("%Y-%m-%d")) if until_date and until_date >= rrule_until_date: until_date = rrule_until_date if until_date: value = until_date.strftime("%Y%m%d%H%M%S") new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S") name = "UNTIL" new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) new_rrule_str = ';'.join(new_rrule_str) start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date) for rdate in rdates: r_date = datetime.datetime.strptime(rdate, "%Y-%m-%d %H:%M:%S") if start_date and r_date < start_date: continue if until_date and r_date > until_date: continue idval = common.real_id2caldav_id(data['id'], rdate) result.append(idval) count += 1 ids = result return ids
def get_recurrent_ids(self, cr, uid, ids, base_start_date, base_until_date, limit=100): if not limit: limit = 100 if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") result = [] count = 0 for data in cr.dictfetchall(): start_date = base_start_date and datetime.datetime.strptime(base_start_date, "%Y-%m-%d") or False until_date = base_until_date and datetime.datetime.strptime(base_until_date, "%Y-%m-%d") or False if count > limit: break event_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") if start_date and start_date <= event_date: start_date = event_date if not data['rrule']: if start_date and event_date < start_date: continue if until_date and event_date > until_date: continue idval = common.real_id2caldav_id(data['id'], data['date']) result.append(idval) count += 1 else: exdate = data['exdate'] and data['exdate'].split(',') or [] event_obj = self.pool.get('basic.calendar.event') rrule_str = data['rrule'] new_rrule_str = [] rrule_until_date = False is_until = False for rule in rrule_str.split(';'): name, value = rule.split('=') if name == "UNTIL": is_until = True value = parser.parse(value) rrule_until_date = parser.parse(value.strftime("%Y-%m-%d")) if until_date and until_date >= rrule_until_date: until_date = rrule_until_date if until_date: value = until_date.strftime("%Y%m%d%H%M%S") new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S") name = "UNTIL" new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) new_rrule_str = ';'.join(new_rrule_str) start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date) for rdate in rdates: r_date = datetime.datetime.strptime(rdate, "%Y-%m-%d %H:%M:%S") if start_date and r_date < start_date: continue if until_date and r_date > until_date: continue idval = common.real_id2caldav_id(data['id'], rdate) result.append(idval) count += 1 ids = result return ids
470,314
def get_recurrent_ids(self, cr, uid, ids, base_start_date, base_until_date, limit=100): if not limit: limit = 100 if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") result = [] count = 0 for data in cr.dictfetchall(): start_date = base_start_date and datetime.datetime.strptime(base_start_date, "%Y-%m-%d") or False until_date = base_until_date and datetime.datetime.strptime(base_until_date, "%Y-%m-%d") or False if count > limit: break event_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") if start_date and start_date <= event_date: start_date = event_date if not data['rrule']: if start_date and event_date < start_date: continue if until_date and event_date > until_date: continue idval = common.real_id2caldav_id(data['id'], data['date']) result.append(idval) count += 1 else: exdate = data['exdate'] and data['exdate'].split(',') or [] event_obj = self.pool.get('basic.calendar.event') rrule_str = data['rrule'] new_rrule_str = [] rrule_until_date = False is_until = False for rule in rrule_str.split(';'): name, value = rule.split('=') if name == "UNTIL": is_until = True value = parser.parse(value) rrule_until_date = parser.parse(value.strftime("%Y-%m-%d")) if until_date and until_date >= rrule_until_date: until_date = rrule_until_date if until_date: value = until_date.strftime("%Y%m%d%H%M%S") new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S") name = "UNTIL" new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) new_rrule_str = ';'.join(new_rrule_str) start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date) for rdate in rdates: r_date = datetime.datetime.strptime(rdate, "%Y-%m-%d %H:%M:%S") if start_date and r_date < start_date: continue if until_date and r_date > until_date: continue idval = common.real_id2caldav_id(data['id'], rdate) result.append(idval) count += 1 ids = result return ids
def get_recurrent_ids(self, cr, uid, ids, base_start_date, base_until_date, limit=100): if not limit: limit = 100 if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") result = [] count = 0 for data in cr.dictfetchall(): start_date = base_start_date and datetime.datetime.strptime(base_start_date, "%Y-%m-%d") or False until_date = base_until_date and datetime.datetime.strptime(base_until_date, "%Y-%m-%d") or False if count > limit: break event_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") if start_date and start_date <= event_date: start_date = event_date if not data['rrule']: if start_date and event_date < start_date: continue if until_date and event_date > until_date: continue idval = common.real_id2caldav_id(data['id'], data['date']) result.append(idval) count += 1 else: exdate = data['exdate'] and data['exdate'].split(',') or [] event_obj = self.pool.get('basic.calendar.event') rrule_str = data['rrule'] new_rrule_str = [] rrule_until_date = False is_until = False for rule in rrule_str.split(';'): name, value = rule.split('=') if name == "UNTIL": is_until = True value = parser.parse(value) rrule_until_date = parser.parse(value.strftime("%Y-%m-%d")) if until_date and until_date >= rrule_until_date: until_date = rrule_until_date if until_date: value = until_date.strftime("%Y%m%d%H%M%S") new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S") name = "UNTIL" new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) new_rrule_str = ';'.join(new_rrule_str) start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date) for rdate in rdates: r_date = datetime.datetime.strptime(rdate, "%Y-%m-%d %H:%M:%S") if start_date and r_date < start_date: continue if until_date and r_date > until_date: continue idval = common.real_id2caldav_id(data['id'], rdate) result.append(idval) count += 1 ids = result return ids
470,315
def get_recurrent_ids(self, cr, uid, ids, base_start_date, base_until_date, limit=100): if not limit: limit = 100 if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") result = [] count = 0 for data in cr.dictfetchall(): start_date = base_start_date and datetime.datetime.strptime(base_start_date, "%Y-%m-%d") or False until_date = base_until_date and datetime.datetime.strptime(base_until_date, "%Y-%m-%d") or False if count > limit: break event_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") if start_date and start_date <= event_date: start_date = event_date if not data['rrule']: if start_date and event_date < start_date: continue if until_date and event_date > until_date: continue idval = common.real_id2caldav_id(data['id'], data['date']) result.append(idval) count += 1 else: exdate = data['exdate'] and data['exdate'].split(',') or [] event_obj = self.pool.get('basic.calendar.event') rrule_str = data['rrule'] new_rrule_str = [] rrule_until_date = False is_until = False for rule in rrule_str.split(';'): name, value = rule.split('=') if name == "UNTIL": is_until = True value = parser.parse(value) rrule_until_date = parser.parse(value.strftime("%Y-%m-%d")) if until_date and until_date >= rrule_until_date: until_date = rrule_until_date if until_date: value = until_date.strftime("%Y%m%d%H%M%S") new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S") name = "UNTIL" new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) new_rrule_str = ';'.join(new_rrule_str) start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date) for rdate in rdates: r_date = datetime.datetime.strptime(rdate, "%Y-%m-%d %H:%M:%S") if start_date and r_date < start_date: continue if until_date and r_date > until_date: continue idval = common.real_id2caldav_id(data['id'], rdate) result.append(idval) count += 1 ids = result return ids
def get_recurrent_ids(self, cr, uid, ids, base_start_date, base_until_date, limit=100): if not limit: limit = 100 if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") result = [] count = 0 for data in cr.dictfetchall(): start_date = base_start_date and datetime.datetime.strptime(base_start_date, "%Y-%m-%d") or False until_date = base_until_date and datetime.datetime.strptime(base_until_date, "%Y-%m-%d") or False if count > limit: break event_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") if start_date and start_date <= event_date: start_date = event_date if not data['rrule']: if start_date and event_date < start_date: continue if until_date and event_date > until_date: continue idval = common.real_id2caldav_id(data['id'], data['date']) result.append(idval) count += 1 else: exdate = data['exdate'] and data['exdate'].split(',') or [] event_obj = self.pool.get('basic.calendar.event') rrule_str = data['rrule'] new_rrule_str = [] rrule_until_date = False is_until = False for rule in rrule_str.split(';'): name, value = rule.split('=') if name == "UNTIL": is_until = True value = parser.parse(value) rrule_until_date = parser.parse(value.strftime("%Y-%m-%d")) if until_date and until_date >= rrule_until_date: until_date = rrule_until_date if until_date: value = until_date.strftime("%Y%m%d%H%M%S") new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S") name = "UNTIL" new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) new_rrule_str = ';'.join(new_rrule_str) start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date) for rdate in rdates: r_date = datetime.datetime.strptime(rdate, "%Y-%m-%d %H:%M:%S") if start_date and r_date < start_date: continue if until_date and r_date > until_date: continue idval = common.real_id2caldav_id(data['id'], rdate) result.append(idval) count += 1 ids = result return ids
470,316
def get_recurrent_ids(self, cr, uid, ids, base_start_date, base_until_date, limit=100): if not limit: limit = 100 if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") result = [] count = 0 for data in cr.dictfetchall(): start_date = base_start_date and datetime.datetime.strptime(base_start_date, "%Y-%m-%d") or False until_date = base_until_date and datetime.datetime.strptime(base_until_date, "%Y-%m-%d") or False if count > limit: break event_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") if start_date and start_date <= event_date: start_date = event_date if not data['rrule']: if start_date and event_date < start_date: continue if until_date and event_date > until_date: continue idval = common.real_id2caldav_id(data['id'], data['date']) result.append(idval) count += 1 else: exdate = data['exdate'] and data['exdate'].split(',') or [] event_obj = self.pool.get('basic.calendar.event') rrule_str = data['rrule'] new_rrule_str = [] rrule_until_date = False is_until = False for rule in rrule_str.split(';'): name, value = rule.split('=') if name == "UNTIL": is_until = True value = parser.parse(value) rrule_until_date = parser.parse(value.strftime("%Y-%m-%d")) if until_date and until_date >= rrule_until_date: until_date = rrule_until_date if until_date: value = until_date.strftime("%Y%m%d%H%M%S") new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S") name = "UNTIL" new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) new_rrule_str = ';'.join(new_rrule_str) start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date) for rdate in rdates: r_date = datetime.datetime.strptime(rdate, "%Y-%m-%d %H:%M:%S") if start_date and r_date < start_date: continue if until_date and r_date > until_date: continue idval = common.real_id2caldav_id(data['id'], rdate) result.append(idval) count += 1 ids = result return ids
def get_recurrent_ids(self, cr, uid, ids, base_start_date, base_until_date, limit=100): if not limit: limit = 100 if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") result = [] count = 0 for data in cr.dictfetchall(): start_date = base_start_date and datetime.datetime.strptime(base_start_date, "%Y-%m-%d") or False until_date = base_until_date and datetime.datetime.strptime(base_until_date, "%Y-%m-%d") or False if count > limit: break event_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") if start_date and start_date <= event_date: start_date = event_date if not data['rrule']: if start_date and event_date < start_date: continue if until_date and event_date > until_date: continue idval = common.real_id2caldav_id(data['id'], data['date']) result.append(idval) count += 1 else: exdate = data['exdate'] and data['exdate'].split(',') or [] event_obj = self.pool.get('basic.calendar.event') rrule_str = data['rrule'] new_rrule_str = [] rrule_until_date = False is_until = False for rule in rrule_str.split(';'): name, value = rule.split('=') if name == "UNTIL": is_until = True value = parser.parse(value) rrule_until_date = parser.parse(value.strftime("%Y-%m-%d")) if until_date and until_date >= rrule_until_date: until_date = rrule_until_date if until_date: value = until_date.strftime("%Y%m%d%H%M%S") new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S") name = "UNTIL" new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) new_rrule_str = ';'.join(new_rrule_str) start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date) for rdate in rdates: r_date = datetime.datetime.strptime(rdate, "%Y-%m-%d %H:%M:%S") if start_date and r_date < start_date: continue if until_date and r_date > until_date: continue idval = common.real_id2caldav_id(data['id'], rdate) result.append(idval) count += 1 ids = result return ids
470,317
def search(self, cr, uid, args, offset=0, limit=100, order=None, context=None, count=False): args_without_date = [] start_date = False until_date = False for arg in args: if arg[0] not in ('date', unicode('date')): args_without_date.append(arg) else: if arg[1] in ('>', '>='): start_date = arg[2] elif arg[1] in ('<', '<='): until_date = arg[2] res = super(crm_meeting, self).search(cr, uid, args_without_date, offset, limit, order, context, count) return self.get_recurrent_ids(cr, uid, res, start_date, until_date, limit)
def search(self, cr, uid, args, offset=0, limit=100, order=None, context=None, count=False): args_without_date = [] start_date = False until_date = False for arg in args: if arg[0] not in ('date', unicode('date')): args_without_date.append(arg) else: if arg[1] in ('>', '>='): start_date = arg[2] elif arg[1] in ('<', '<='): until_date = arg[2] res = super(crm_meeting, self).search(cr, uid, args_without_date, offset, limit, order, context, count) return self.get_recurrent_ids(cr, uid, res, start_date, until_date, limit)
470,318
def search(self, cr, uid, args, offset=0, limit=100, order=None, context=None, count=False): args_without_date = [] start_date = False until_date = False for arg in args: if arg[0] not in ('date', unicode('date')): args_without_date.append(arg) else: if arg[1] in ('>', '>='): start_date = arg[2] elif arg[1] in ('<', '<='): until_date = arg[2] res = super(crm_meeting, self).search(cr, uid, args_without_date, offset, limit, order, context, count) return self.get_recurrent_ids(cr, uid, res, start_date, until_date, limit)
def search(self, cr, uid, args, offset=0, limit=100, order=None, context=None, count=False): args_without_date = [] start_date = False until_date = False for arg in args: if arg[0] not in ('date', unicode('date')): args_without_date.append(arg) else: if arg[1] in ('>', '>='): start_date = arg[2] elif arg[1] in ('<', '<='): until_date = arg[2] res = super(crm_meeting, self).search(cr, uid, args_without_date, offset, limit, order, context, count) return self.get_recurrent_ids(cr, uid, res, start_date, until_date, limit)
470,319
def _get_user_avail(self, cr, uid, ids, context=None): current_datetime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') res = super(res_users, self)._get_user_avail(cr, uid, ids, context) cr.execute("SELECT crm_case.user_id, 'busy' as status \ FROM crm_meeting meeting, crm_case \ WHERE meeting.inherit_case_id = crm_case.id \ and crm_case.date <= %s and crm_case.date_deadline >= %s and crm_case.user_id = ANY(%s) and meeting.show_as = %s", (current_datetime, current_datetime , ids, 'busy')) result = cr.dictfetchall() for user_data in result: user_id = user_data['user_id'] status = user_data['status'] res.update({user_id:status}) return res
def _get_user_avail(self, cr, uid, ids, context=None): current_datetime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') res = super(res_users, self)._get_user_avail(cr, uid, ids, context) cr.execute("SELECT crm_case.user_id, 'busy' as status \ FROM crm_meeting meeting, crm_case \ WHERE meeting.inherit_case_id = crm_case.id \ and crm_case.date <= %s and crm_case.date_deadline >= %s and crm_case.user_id = ANY(%s) and meeting.show_as = %s", (current_datetime, current_datetime , ids, 'busy')) result = cr.dictfetchall() for user_data in result: user_id = user_data['user_id'] status = user_data['status'] res.update({user_id:status}) return res
470,320
def _get_user_avail(self, cr, uid, ids, context=None): current_datetime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') res = super(res_users, self)._get_user_avail(cr, uid, ids, context) cr.execute("SELECT crm_case.user_id, 'busy' as status \ FROM crm_meeting meeting, crm_case \ WHERE meeting.inherit_case_id = crm_case.id \ and crm_case.date <= %s and crm_case.date_deadline >= %s and crm_case.user_id = ANY(%s) and meeting.show_as = %s", (current_datetime, current_datetime , ids, 'busy')) result = cr.dictfetchall() for user_data in result: user_id = user_data['user_id'] status = user_data['status'] res.update({user_id:status}) return res
def _get_user_avail(self, cr, uid, ids, context=None): current_datetime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') res = super(res_users, self)._get_user_avail(cr, uid, ids, context) cr.execute("SELECT crm_case.user_id, 'busy' as status \ FROM crm_meeting meeting, crm_case \ WHERE meeting.inherit_case_id = crm_case.id \ and crm_case.date <= %s and crm_case.date_deadline >= %s and crm_case.user_id = ANY(%s) and meeting.show_as = %s", (current_datetime, current_datetime , ids, 'busy')) result = cr.dictfetchall() for user_data in result: user_id = user_data['user_id'] status = user_data['status'] res.update({user_id:status}) return res
470,321
def match_dav_eprop(self, cr, match, ns, prop): if ns == "DAV:" and prop == "getetag": dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() tem, dav_time = tuple(match.split(':')) model, res_id = tuple(tem.split('_')) model_obj = dirobj.pool.get(model) model = model_obj.browse(cr, uid, res_id, context=ctx) write_time = model.write_date or model.create_date wtime = time.mktime(time.strptime(write_time,'%Y-%m-%d %H:%M:%S')) if dav_time <= wtime: return True return False res = super(node_calendar, self).match_dav_eprop(cr, match, ns, prop) return res
def match_dav_eprop(self, cr, match, ns, prop): if ns == "DAV:" and prop == "getetag": dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() tem, dav_time = tuple(match.split(':')) model, res_id = tuple(tem.split('_')) model_obj = dirobj.pool.get(model) model = model_obj.browse(cr, uid, res_id, context=ctx) write_time = model.write_date or model.create_date wtime = time.mktime(time.strptime(write_time,'%Y-%m-%d %H:%M:%S')) if float(dav_time) == float(wtime): return True return False res = super(node_calendar, self).match_dav_eprop(cr, match, ns, prop) return res
470,322
def upgrade_module(self, cr, uid, ids, context): pool = pooler.get_pool(cr.dbname) mod_obj = self.pool.get('ir.module.module') data_obj = self.pool.get('ir.model.data') ids = mod_obj.search(cr, uid, [('state', 'in', ['to upgrade', 'to remove', 'to install'])]) unmet_packages = [] mod_dep_obj = pool.get('ir.module.module.dependency') for mod in mod_obj.browse(cr, uid, ids): depends_mod_ids = mod_dep_obj.search(cr, uid, [('module_id', '=', mod.id)]) for dep_mod in mod_dep_obj.browse(cr, uid, depends_mod_ids): if dep_mod.state in ('unknown','uninstalled'): unmet_packages.append(dep_mod.name) if len(unmet_packages): raise wizard.except_wizard('Unmet dependency !', 'Following modules are uninstalled or unknown. \n\n'+'\n'.join(unmet_packages)) mod_obj.download(cr, uid, ids, context=context) cr.commit() db, pool = pooler.restart_pool(cr.dbname, update_module=True)
def upgrade_module(self, cr, uid, ids, context): pool = pooler.get_pool(cr.dbname) mod_obj = self.pool.get('ir.module.module') data_obj = self.pool.get('ir.model.data') ids = mod_obj.search(cr, uid, [('state', 'in', ['to upgrade', 'to remove', 'to install'])]) unmet_packages = [] mod_dep_obj = pool.get('ir.module.module.dependency') for mod in mod_obj.browse(cr, uid, ids): depends_mod_ids = mod_dep_obj.search(cr, uid, [('module_id', '=', mod.id)]) for dep_mod in mod_dep_obj.browse(cr, uid, depends_mod_ids): if dep_mod.state in ('unknown','uninstalled'): unmet_packages.append(dep_mod.name) if len(unmet_packages): raise osv.except_osv('Unmet dependency !', 'Following modules are uninstalled or unknown. \n\n'+'\n'.join(unmet_packages)) mod_obj.download(cr, uid, ids, context=context) cr.commit() db, pool = pooler.restart_pool(cr.dbname, update_module=True)
470,323
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
470,324
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
470,325
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
470,326
def _get_company(self, cr, uid, ids, context={}): user_pool = self.pool.get('res.users') company_pool = self.pool.get('res.company') user = user_pool.browse(cr, uid, uid, uid) company_id = user.company_id and user.company_id.id if not company_id: company_id = company_pool.search(cr, uid, [])[0]
def _get_company(self, cr, uid, context={}): user_pool = self.pool.get('res.users') company_pool = self.pool.get('res.company') user = user_pool.browse(cr, uid, uid, uid) company_id = user.company_id and user.company_id.id if not company_id: company_id = company_pool.search(cr, uid, [])[0]
470,327
def _get_company(self, cr, uid, ids, context={}): user_pool = self.pool.get('res.users') company_pool = self.pool.get('res.company') user = user_pool.browse(cr, uid, uid, uid) company_id = user.company_id and user.company_id.id if not company_id: company_id = company_pool.search(cr, uid, [])[0]
def _get_company(self, cr, uid, ids, context={}): user_pool = self.pool.get('res.users') company_pool = self.pool.get('res.company') user = user_pool.browse(cr, uid, uid, context) company_id = user.company_id and user.company_id.id if not company_id: company_id = company_pool.search(cr, uid, [])[0]
470,328
def _get_cash_open_box_lines(self, cr, uid, ids, context={}): res = [] curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: dct = { 'pieces':rs, 'number':0 } res.append(dct) return res
def _get_cash_open_box_lines(self, cr, uid, context={}): res = [] curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: dct = { 'pieces':rs, 'number':0 } res.append(dct) return res
470,329
def _get_cash_open_box_lines(self, cr, uid, ids, context={}): res = [] curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: dct = { 'pieces':rs, 'number':0 } res.append(dct) return res
def _get_cash_open_box_lines(self, cr, uid, ids, context={}): res = [] curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: dct = { 'pieces':rs, 'number':0 } res.append(dct) return res
470,330
def _get_cash_close_box_lines(self, cr, uid, ids, context={}): res = [] curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: dct = { 'pieces':rs, 'number':0 } res.append((0, 0, dct)) return res
def _get_cash_close_box_lines(self, cr, uid, ids, context={}): res = [] curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: dct = { 'pieces':rs, 'number':0 } res.append(dct) return res def _get_cash_close_box_lines(self, cr, ids, uid, context={}): res = [] curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: dct = { 'pieces':rs, 'number':0 } res.append((0,0,dct)) return res
470,331
def _get_cash_close_box_lines(self, cr, uid, ids, context={}): res = [] curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: dct = { 'pieces':rs, 'number':0 } res.append((0, 0, dct)) return res
def _get_cash_close_box_lines(self, cr, uid, ids, context={}): res = [] curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: dct = { 'pieces':rs, 'number':0 } res.append((0, 0, dct)) return res
470,332
def button_open(self, cr, uid, ids, context=None):
def button_open(self, cr, uid, ids, context=None):
470,333
def _create_result_lines(self, cr, uid, wizard_data, context=None): user_obj = self.pool.get('res.users') result_obj = self.pool.get('share.wizard.result.line') share_root_url = wizard_data.share_root_url format_url = '%(login)s' in share_root_url\ and '%(password)s' in share_root_url\ and '%(dbname)s' in share_root_url existing_passwd_str = _('*usual password*') if wizard_data.user_type == 'new': for email in wizard_data.new_users.split('\n'): user_id = user_obj.search(cr, 1, [('login', '=', email)], context=context) password = user_obj.read(cr, 1, user_id[0], ['password'])['password'] share_url = share_root_url % \ {'login': email, 'password': password, 'dbname': cr.dbname} if format_url else share_root_url result_obj.create(cr, uid, { 'share_wizard_id': wizard_data.id, 'login': email, 'password': password, 'share_url': share_url, }, context=context) else: # existing users for user in wizard_data.user_ids: share_url = share_root_url % \ {'login': email, 'password': '', 'dbame': cr.dbname} if format_url else share_root_url result_obj.create(cr, uid, { 'share_wizard_id': wizard_data.id, 'login': user.user_id.login, 'password': existing_passwd_str, 'share_url': share_url, 'newly_created': False, }, context=context)
def _create_result_lines(self, cr, uid, wizard_data, context=None): user_obj = self.pool.get('res.users') result_obj = self.pool.get('share.wizard.result.line') share_root_url = wizard_data.share_root_url format_url = '%(login)s' in share_root_url\ and '%(password)s' in share_root_url\ and '%(dbname)s' in share_root_url existing_passwd_str = _('*usual password*') if wizard_data.user_type == 'new': for email in wizard_data.new_users.split('\n'): user_id = user_obj.search(cr, 1, [('login', '=', email)], context=context) password = user_obj.read(cr, 1, user_id[0], ['password'])['password'] share_url = share_root_url % \ {'login': user.user_id.login, 'password': password, 'dbname': cr.dbname} if format_url else share_root_url result_obj.create(cr, uid, { 'share_wizard_id': wizard_data.id, 'login': email, 'password': password, 'share_url': share_url, }, context=context) else: # existing users for user in wizard_data.user_ids: share_url = share_root_url % \ {'login': user.user_id.login, 'password': '', 'dbame': cr.dbname} if format_url else share_root_url result_obj.create(cr, uid, { 'share_wizard_id': wizard_data.id, 'login': user.user_id.login, 'password': existing_passwd_str, 'share_url': share_url, 'newly_created': False, }, context=context)
470,334
def _create_result_lines(self, cr, uid, wizard_data, context=None): user_obj = self.pool.get('res.users') result_obj = self.pool.get('share.wizard.result.line') share_root_url = wizard_data.share_root_url format_url = '%(login)s' in share_root_url\ and '%(password)s' in share_root_url\ and '%(dbname)s' in share_root_url existing_passwd_str = _('*usual password*') if wizard_data.user_type == 'new': for email in wizard_data.new_users.split('\n'): user_id = user_obj.search(cr, 1, [('login', '=', email)], context=context) password = user_obj.read(cr, 1, user_id[0], ['password'])['password'] share_url = share_root_url % \ {'login': email, 'password': password, 'dbname': cr.dbname} if format_url else share_root_url result_obj.create(cr, uid, { 'share_wizard_id': wizard_data.id, 'login': email, 'password': password, 'share_url': share_url, }, context=context) else: # existing users for user in wizard_data.user_ids: share_url = share_root_url % \ {'login': email, 'password': '', 'dbame': cr.dbname} if format_url else share_root_url result_obj.create(cr, uid, { 'share_wizard_id': wizard_data.id, 'login': user.user_id.login, 'password': existing_passwd_str, 'share_url': share_url, 'newly_created': False, }, context=context)
def _create_result_lines(self, cr, uid, wizard_data, context=None): user_obj = self.pool.get('res.users') result_obj = self.pool.get('share.wizard.result.line') share_root_url = wizard_data.share_root_url format_url = '%(login)s' in share_root_url\ and '%(password)s' in share_root_url\ and '%(dbname)s' in share_root_url existing_passwd_str = _('*usual password*') if wizard_data.user_type == 'new': for email in wizard_data.new_users.split('\n'): user_id = user_obj.search(cr, 1, [('login', '=', email)], context=context) password = user_obj.read(cr, 1, user_id[0], ['password'])['password'] share_url = share_root_url % \ {'login': email, 'password': password, 'dbname': cr.dbname} if format_url else share_root_url result_obj.create(cr, uid, { 'share_wizard_id': wizard_data.id, 'login': email, 'password': password, 'share_url': share_url, }, context=context) else: # existing users for user in wizard_data.user_ids: share_url = share_root_url % \ {'login': email, 'password': '', 'dbname': cr.dbname} if format_url else share_root_url result_obj.create(cr, uid, { 'share_wizard_id': wizard_data.id, 'login': user.user_id.login, 'password': existing_passwd_str, 'share_url': share_url, 'newly_created': False, }, context=context)
470,335
def _check_duration(self,cr,uid,ids): obj_fy=self.browse(cr,uid,ids[0]) if obj_fy.date_stop < obj_fy.date_start: return False return True
def _check_duration(self,cr,uid,ids): obj_fy = self.browse(cr,uid,ids[0]) if obj_fy.date_stop < obj_fy.date_start: return False return True
470,336
def _check_duration(self,cr,uid,ids): obj_fy=self.browse(cr,uid,ids[0]) if obj_fy.date_stop < obj_fy.date_start: return False return True
def _check_duration(self,cr,uid,ids): obj_fy=self.browse(cr,uid,ids[0]) if obj_fy.date_stop < obj_fy.date_start: return False return True
470,337
def createInstance(cls, pool, module, cr): parent_names = getattr(cls, '_inherit', None) if parent_names: for parent_name in ((type(parent_names)==list) and parent_names or [parent_names]): parent_class = pool.get(parent_name).__class__ assert pool.get(parent_name), "parent class %s does not exist in module %s !" % (parent_name, module) nattr = {} for s in ('_columns', '_defaults'): new = copy.copy(getattr(pool.get(parent_name), s)) if hasattr(new, 'update'): new.update(cls.__dict__.get(s, {})) else: new.extend(cls.__dict__.get(s, [])) nattr[s] = new name = cls._name or cls._inherit cls = type(name, (cls, parent_class), nattr)
def createInstance(cls, pool, module, cr): parent_names = getattr(cls, '_inherit', None) if parent_names: for parent_name in ((type(parent_names)==list) and parent_names or [parent_names]): parent_class = pool.get(parent_name).__class__ assert pool.get(parent_name), "parent class %s does not exist in module %s !" % (parent_name, module) nattr = {} for s in ('_columns', '_defaults'): new = copy.copy(getattr(pool.get(parent_name), s)) if hasattr(new, 'update'): new.update(cls.__dict__.get(s, {})) else: new.extend(cls.__dict__.get(s, [])) nattr[s] = new cls = type(name, (cls, parent_class), nattr)
470,338
def createInstance(cls, pool, module, cr): parent_names = getattr(cls, '_inherit', None) if parent_names: for parent_name in ((type(parent_names)==list) and parent_names or [parent_names]): parent_class = pool.get(parent_name).__class__ assert pool.get(parent_name), "parent class %s does not exist in module %s !" % (parent_name, module) nattr = {} for s in ('_columns', '_defaults', '_inherits', '_constraints', '_sql_constraints'): new = copy.copy(getattr(pool.get(parent_name), s)) if hasattr(new, 'update'): new.update(cls.__dict__.get(s, {})) else: if s=='_constraints': for c in cls.__dict__.get(s, []): exist = False for c2 in range(len(new)): if new[c2][2]==c[2]: new[c2] = c exist = True break if not exist: new.append(c) else: new.extend(cls.__dict__.get(s, [])) nattr[s] = new name = cls._name or cls._inherit cls = type(name, (cls, parent_class), nattr) obj = object.__new__(cls) obj.__init__(pool, cr) return obj
def createInstance(cls, pool, module, cr): parent_names = getattr(cls, '_inherit', None) if parent_names: for parent_name in ((type(parent_names)==list) and parent_names or [parent_names]): parent_class = pool.get(parent_name).__class__ assert pool.get(parent_name), "parent class %s does not exist in module %s !" % (parent_name, module) nattr = {} for s in ('_columns', '_defaults', '_inherits', '_constraints', '_sql_constraints'): new = copy.copy(getattr(pool.get(parent_name), s)) if hasattr(new, 'update'): new.update(cls.__dict__.get(s, {})) else: if s=='_constraints': for c in cls.__dict__.get(s, []): exist = False for c2 in range(len(new)): if new[c2][2]==c[2]: new[c2] = c exist = True break if not exist: new.append(c) else: new.extend(cls.__dict__.get(s, [])) nattr[s] = new cls = type(name, (cls, parent_class), nattr) obj = object.__new__(cls) obj.__init__(pool, cr) return obj
470,339
def action_move_create(self, cr, uid, ids, *args): """Creates invoice related analytics and financial move lines""" ait_obj = self.pool.get('account.invoice.tax') cur_obj = self.pool.get('res.currency') context = {} for inv in self.browse(cr, uid, ids): if inv.move_id: continue
def action_move_create(self, cr, uid, ids, *args): """Creates invoice related analytics and financial move lines""" ait_obj = self.pool.get('account.invoice.tax') cur_obj = self.pool.get('res.currency') context = {} for inv in self.browse(cr, uid, ids): if inv.move_id: continue
470,340
def create(self, cr, user, vals, context=None): """ Create new record with specified value
def create(self, cr, user, vals, context=None): """ Create new record with specified value
470,341
def login(self, db, login, password):
def login(self, db, login, password):
470,342
def _login(self, db, login, password): if not password: return False if db is False: raise RuntimeError("Cannot authenticate to False db!")
def _login(self, db, login, password): if not password: return False if db is False: raise RuntimeError("Cannot authenticate to False db!")
470,343
def _process_wi_paper(self, cr, uid, activity, workitem, context=None): service = netsvc.LocalService('report.%s'%activity.report_id.report_name) (report_data, format) = service.create(cr, uid, [], {}, {}) attach_vals = { 'name': '%s_%s_%s'%(activity.report_id.report_name, activity.name,workitem.partner_id.name), 'datas_fname': '%s.%s'%(activity.report_id.report_name, activity.report_id.report_type), 'parent_id': activity.report_directory_id.id, 'datas': base64.encodestring(report_data), 'file_type': format } self.pool.get('ir.attachment').create(cr, uid, attach_vals) return True
def _process_wi_report(self, cr, uid, activity, workitem, context=None): service = netsvc.LocalService('report.%s'%activity.report_id.report_name) (report_data, format) = service.create(cr, uid, [], {}, {}) attach_vals = { 'name': '%s_%s_%s'%(activity.report_id.report_name, activity.name,workitem.partner_id.name), 'datas_fname': '%s.%s'%(activity.report_id.report_name, activity.report_id.report_type), 'parent_id': activity.report_directory_id.id, 'datas': base64.encodestring(report_data), 'file_type': format } self.pool.get('ir.attachment').create(cr, uid, attach_vals) return True
470,344
def _build_context(self, cr, uid, ids, data, context=None): if context is None: context = {} result = {} period_obj = self.pool.get('account.period') result['fiscalyear'] = data['form']['fiscalyear_id'] and data['form']['fiscalyear_id'] or False if data['form']['filter'] == 'filter_date': result['date_from'] = data['form']['date_from'] result['date_to'] = data['form']['date_to'] elif data['form']['filter'] == 'filter_period': if not data['form']['period_from'] or not data['form']['period_to']: raise osv.except_osv(_('Error'),_('Select Start period and End period')) elif (data['form']['period_from'] > data['form']['period_to']): raise osv.except_osv(_('Error'),_('Start period should be smaller then End period')) period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])['date_start'] period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])['date_stop'] cr.execute('SELECT id FROM account_period WHERE date_start >= %s AND date_stop <= %s', (period_date_start, period_date_stop)) result['periods'] = lambda x: x[0], cr.fetchall() return result
def _build_context(self, cr, uid, ids, data, context=None): if context is None: context = {} result = {} period_obj = self.pool.get('account.period') result['fiscalyear'] = data['form']['fiscalyear_id'] and data['form']['fiscalyear_id'] or False if data['form']['filter'] == 'filter_date': result['date_from'] = data['form']['date_from'] result['date_to'] = data['form']['date_to'] elif data['form']['filter'] == 'filter_period': if not data['form']['period_from'] or not data['form']['period_to']: raise osv.except_osv(_('Error'),_('Select Start period and End period')) elif (data['form']['period_from'] > data['form']['period_to']): raise osv.except_osv(_('Error'),_('Start period should be smaller then End period')) period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])['date_start'] period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])['date_stop'] cr.execute('SELECT id FROM account_period WHERE date_start >= %s AND date_stop <= %s', (period_date_start, period_date_stop)) result['periods'] = map(lambda x: x[0], cr.fetchall()) return result
470,345
def _product_price(self, cr, uid, ids, name, arg, context={}): res = {} quantity = context.get('quantity', 1) pricelist = context.get('pricelist', False) if pricelist: for id in ids: try: price = self.pool.get('product.pricelist').price_get(cr,uid,[pricelist], id, quantity, context=context)[pricelist] except: price = 0.0 res[id] = price for id in ids: res.setdefault(id, 0.0) return res
def _product_price(self, cr, uid, ids, name, arg, context={}): res = {} quantity = context.get('quantity') or 1.0 pricelist = context.get('pricelist', False) if pricelist: for id in ids: try: price = self.pool.get('product.pricelist').price_get(cr,uid,[pricelist], id, quantity, context=context)[pricelist] except: price = 0.0 res[id] = price for id in ids: res.setdefault(id, 0.0) return res
470,346
def _email_set(self, cr, uid, ids, name, value, arg, context=None): if not isinstance(ids,list): ids = [ids] address_obj = self.pool.get('res.partner.address') for user in self.browse(cr, uid, ids, context=context): if user.address_id: address_obj.write(cr, uid, user.address_id.id, {'email': value or None}, context=context) else: address_id = address_obj.create(cr, uid, {'name': user.name, 'email': value or None}, context=context) self.write(cr, uid, ids, {'address_id': address_id}, context) return True
def _email_set(self, cr, uid, ids, name, value, arg, context=None): if not isinstance(ids,list): ids = [ids] address_obj = self.pool.get('res.partner.address') for user in self.browse(cr, uid, ids, context=context): if user.address_id: address_obj.write(cr, 1, user.address_id.id, {'email': value or None}) else: address_id = address_obj.create(cr, uid, {'name': user.name, 'email': value or None}, context=context) self.write(cr, uid, ids, {'address_id': address_id}, context) return True
470,347
def _email_set(self, cr, uid, ids, name, value, arg, context=None): if not isinstance(ids,list): ids = [ids] address_obj = self.pool.get('res.partner.address') for user in self.browse(cr, uid, ids, context=context): if user.address_id: address_obj.write(cr, uid, user.address_id.id, {'email': value or None}, context=context) else: address_id = address_obj.create(cr, uid, {'name': user.name, 'email': value or None}, context=context) self.write(cr, uid, ids, {'address_id': address_id}, context) return True
def _email_set(self, cr, uid, ids, name, value, arg, context=None): if not isinstance(ids,list): ids = [ids] address_obj = self.pool.get('res.partner.address') for user in self.browse(cr, uid, ids, context=context): if user.address_id: address_obj.write(cr, uid, user.address_id.id, {'email': value or None}, context=context) else: address_id = address_obj.create(cr, 1, {'name': user.name, 'email': value or None}) self.write(cr, uid, ids, {'address_id': address_id}, context) return True
470,348
def button_open(self, cr, uid, ids, context=None): """ Changes statement state to Running. @return: True """ if context is None: context = {} statement_pool = self.pool.get('account.bank.statement') for statement in statement_pool.browse(cr, uid, ids, context=context): vals = {}
def button_open(self, cr, uid, ids, context=None): """ Changes statement state to Running. @return: True """ if context is None: context = {} statement_pool = self.pool.get('account.bank.statement') for statement in statement_pool.browse(cr, uid, ids, context=context): vals = {}
470,349
def onchange_partner_id(self, cr, uid, ids, part): if not part: return {'value': {'partner_invoice_id': False, 'partner_shipping_id': False, 'partner_order_id': False, 'payment_term': False, 'fiscal_position': False}} addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['delivery', 'invoice', 'contact']) part = self.pool.get('res.partner').browse(cr, uid, part) pricelist = part.property_product_pricelist and part.property_product_pricelist.id or False payment_term = part.property_payment_term and part.property_payment_term.id or False fiscal_position = part.property_account_position and part.property_account_position.id or False val = {'partner_invoice_id': addr['invoice'], 'partner_order_id': addr['contact'], 'partner_shipping_id': addr['delivery'], 'payment_term': payment_term, 'fiscal_position': fiscal_position} if pricelist: val['pricelist_id'] = pricelist return {'value': val}
def onchange_partner_id(self, cr, uid, ids, part): if not part: return {'value': {'partner_invoice_id': False, 'partner_shipping_id': False, 'partner_order_id': False, 'payment_term': False, 'fiscal_position': False}} addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['delivery', 'invoice', 'contact']) part = self.pool.get('res.partner').browse(cr, uid, part) pricelist = part.property_product_pricelist and part.property_product_pricelist.id or False payment_term = part.property_payment_term and part.property_payment_term.id or False fiscal_position = part.property_account_position and part.property_account_position.id or False dedicated_salesman = part.user_id and part.user_id.id or False val = { 'partner_invoice_id': addr['invoice'], 'partner_order_id': addr['contact'], 'partner_shipping_id': addr['delivery'], 'payment_term': payment_term, 'fiscal_position': fiscal_position, 'user_id': dedicated_salesman, } if pricelist: val['pricelist_id'] = pricelist return {'value': val}
470,350
def _result_get(x, keys): if x[1] in keys: return False keys.append(x[1]) if x[3]: model,id = x[2].split(',') id = int(id) fields = self.pool.get(model).fields_get_keys(cr, uid) pos = 0 while pos<len(fields): if fields[pos] in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): del fields[pos] else: pos+=1 try: datas = self.pool.get(model).read(cr, uid, [id], fields, context) except except_orm, e: print 'false 1',model,fields,e return False datas= datas and datas[0] or None if not datas: #ir_del(cr, uid, x[0]) print 'false 2' return False else: datas = pickle.loads(str(x[2].encode('utf-8'))) if meta: meta2 = pickle.loads(x[4]) return (x[0],x[1],datas,meta2) return (x[0],x[1],datas)
def _result_get(x, keys): if x[1] in keys: return False keys.append(x[1]) if x[3]: model,id = x[2].split(',') id = int(id) fields = self.pool.get(model).fields_get_keys(cr, uid) pos = 0 while pos<len(fields): if fields[pos] in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): del fields[pos] else: pos+=1 try: datas = self.pool.get(model).read(cr, uid, [id], fields, context) except except_orm, e: return False datas= datas and datas[0] or None if not datas: #ir_del(cr, uid, x[0]) print 'false 2' return False else: datas = pickle.loads(str(x[2].encode('utf-8'))) if meta: meta2 = pickle.loads(x[4]) return (x[0],x[1],datas,meta2) return (x[0],x[1],datas)
470,351
def _result_get(x, keys): if x[1] in keys: return False keys.append(x[1]) if x[3]: model,id = x[2].split(',') id = int(id) fields = self.pool.get(model).fields_get_keys(cr, uid) pos = 0 while pos<len(fields): if fields[pos] in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): del fields[pos] else: pos+=1 try: datas = self.pool.get(model).read(cr, uid, [id], fields, context) except except_orm, e: print 'false 1',model,fields,e return False datas= datas and datas[0] or None if not datas: #ir_del(cr, uid, x[0]) print 'false 2' return False else: datas = pickle.loads(str(x[2].encode('utf-8'))) if meta: meta2 = pickle.loads(x[4]) return (x[0],x[1],datas,meta2) return (x[0],x[1],datas)
def _result_get(x, keys): if x[1] in keys: return False keys.append(x[1]) if x[3]: model,id = x[2].split(',') id = int(id) fields = self.pool.get(model).fields_get_keys(cr, uid) pos = 0 while pos<len(fields): if fields[pos] in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): del fields[pos] else: pos+=1 try: datas = self.pool.get(model).read(cr, uid, [id], fields, context) except except_orm, e: print 'false 1',model,fields,e return False datas= datas and datas[0] or None if not datas: #ir_del(cr, uid, x[0]) return False else: datas = pickle.loads(str(x[2].encode('utf-8'))) if meta: meta2 = pickle.loads(x[4]) return (x[0],x[1],datas,meta2) return (x[0],x[1],datas)
470,352
def state_running_set(self, cr, uid, ids, *args): campaign = self.browse(cr, uid, ids[0]) if not campaign.activity_ids : raise osv.except_osv("Error", "There is no associate activitity for the campaign") act_ids = [ act_id.id for act_id in campaign.activity_ids] act_ids = self.pool.get('marketing.campaign.activity').search(cr, uid, [('id', 'in', act_ids), ('start', '=', True)]) if not act_ids : raise osv.except_osv("Error", "There is no associate activitity for the campaign") segment_ids = self.pool.get('marketing.campaign.segment').search(cr, uid, [('campaign_id', '=', campaign.id), ('state', '=', 'draft')]) self.write(cr, uid, ids, {'state': 'running'}) return True
def state_running_set(self, cr, uid, ids, *args): campaign = self.browse(cr, uid, ids[0]) if not campaign.activity_ids : raise osv.except_osv("Error", "There is no activitity in the campaign") act_ids = [ act_id.id for act_id in campaign.activity_ids] act_ids = self.pool.get('marketing.campaign.activity').search(cr, uid, [('id', 'in', act_ids), ('start', '=', True)]) if not act_ids : raise osv.except_osv("Error", "There is no activitity in the campaign") segment_ids = self.pool.get('marketing.campaign.segment').search(cr, uid, [('campaign_id', '=', campaign.id), ('state', '=', 'draft')]) self.write(cr, uid, ids, {'state': 'running'}) return True
470,353
def state_running_set(self, cr, uid, ids, *args): campaign = self.browse(cr, uid, ids[0]) if not campaign.activity_ids : raise osv.except_osv("Error", "There is no associate activitity for the campaign") act_ids = [ act_id.id for act_id in campaign.activity_ids] act_ids = self.pool.get('marketing.campaign.activity').search(cr, uid, [('id', 'in', act_ids), ('start', '=', True)]) if not act_ids : raise osv.except_osv("Error", "There is no associate activitity for the campaign") segment_ids = self.pool.get('marketing.campaign.segment').search(cr, uid, [('campaign_id', '=', campaign.id), ('state', '=', 'draft')]) self.write(cr, uid, ids, {'state': 'running'}) return True
def state_running_set(self, cr, uid, ids, *args): campaign = self.browse(cr, uid, ids[0]) if not campaign.activity_ids : raise osv.except_osv("Error", "There is no associate activitity for the campaign") act_ids = [ act_id.id for act_id in campaign.activity_ids] act_ids = self.pool.get('marketing.campaign.activity').search(cr, uid, [('id', 'in', act_ids), ('start', '=', True)]) if not act_ids : raise osv.except_osv("Error", "There is no starting activitity in the campaign") self.write(cr, uid, ids, {'state': 'running'}) return True
470,354
def state_done_set(self, cr, uid, ids, *args): segment_ids = self.pool.get('marketing.campaign.segment').search(cr, uid, [('campaign_id', 'in', ids), ('state', '=', 'running')]) if segment_ids : raise osv.except_osv("Error", "Camapign cannot be done before all segments are done") self.write(cr, uid, ids, {'state': 'done'}) return True
def state_done_set(self, cr, uid, ids, *args): segment_ids = self.pool.get('marketing.campaign.segment').search(cr, uid, [('campaign_id', 'in', ids), ('state', '=', 'running')]) if segment_ids : raise osv.except_osv("Error", "Campaign cannot be marked as done before all segments are done") self.write(cr, uid, ids, {'state': 'done'}) return True
470,355
def state_cancel_set(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state': 'cancelled'}) return True
def state_cancel_set(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state': 'cancelled'}) return True
470,356
def state_running_set(self, cr, uid, ids, *args): segment = self.browse(cr, uid, ids[0]) curr_date = time.strftime('%Y-%m-%d %H:%M:%S') vals = {'state': 'running'} if not segment.date_run: vals['date_run'] = time.strftime('%Y-%m-%d %H:%M:%S')
def state_running_set(self, cr, uid, ids, *args): segment = self.browse(cr, uid, ids[0]) curr_date = time.strftime('%Y-%m-%d %H:%M:%S') vals = {'state': 'running'} if not segment.date_run: vals['date_run'] = time.strftime('%Y-%m-%d %H:%M:%S')
470,357
def state_done_set(self, cr, uid, ids, *args): date_done = self.browse(cr, uid, ids[0]).date_done if (date_done > time.strftime('%Y-%m-%d %H:%M:%S')): raise osv.except_osv("Error", "Segment cannot be closed before end date")
def state_done_set(self, cr, uid, ids, *args): date_done = self.browse(cr, uid, ids[0]).date_done if (date_done > time.strftime('%Y-%m-%d %H:%M:%S')): raise osv.except_osv("Error", "Segment cannot be closed before end date")
470,358
def state_done_set(self, cr, uid, ids, *args): date_done = self.browse(cr, uid, ids[0]).date_done if (date_done > time.strftime('%Y-%m-%d %H:%M:%S')): raise osv.except_osv("Error", "Segment cannot be closed before end date")
def state_done_set(self, cr, uid, ids, *args): date_done = self.browse(cr, uid, ids[0]).date_done if (date_done > time.strftime('%Y-%m-%d %H:%M:%S')): raise osv.except_osv("Error", "Segment cannot be closed before end date")
470,359
def state_cancel_set(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state': 'cancelled'}) return True
def state_cancel_set(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state': 'cancelled'}) return True
470,360
def synchroniz(self, cr, uid, ids, *args): self.process_segment(cr, uid, {'segment_ids' : ids}) return True
def synchroniz(self, cr, uid, ids, *args): self.process_segment(cr, uid, ids) return True
470,361
def process_segment(self, cr, uid, context={}): last_action_date = '' if 'segment_ids' in context: segment_ids = context['segment_ids'] last_action_date = (datetime.now() + _intervalTypes['days'](-1) \ ).strftime('%Y-%m-%d %H:%M:%S')
def process_segment(self, cr, uid, context={}): last_action_date = '' if 'segment_ids' in context: segment_ids = context['segment_ids'] last_action_date = (datetime.now() + _intervalTypes['days'](-1) \ ).strftime('%Y-%m-%d %H:%M:%S')
470,362
def process_segment(self, cr, uid, context={}): last_action_date = '' if 'segment_ids' in context: segment_ids = context['segment_ids'] last_action_date = (datetime.now() + _intervalTypes['days'](-1) \ ).strftime('%Y-%m-%d %H:%M:%S')
def process_segment(self, cr, uid, context={}): last_action_date = '' if 'segment_ids' in context: segment_ids = context['segment_ids'] last_action_date = (datetime.now() + _intervalTypes['days'](-1) \ ).strftime('%Y-%m-%d %H:%M:%S')
470,363
def process_segment(self, cr, uid, context={}): last_action_date = '' if 'segment_ids' in context: segment_ids = context['segment_ids'] last_action_date = (datetime.now() + _intervalTypes['days'](-1) \ ).strftime('%Y-%m-%d %H:%M:%S')
def process_segment(self, cr, uid, context={}): last_action_date = '' if 'segment_ids' in context: segment_ids = context['segment_ids'] last_action_date = (datetime.now() + _intervalTypes['days'](-1) \ ).strftime('%Y-%m-%d %H:%M:%S')
470,364
def process_segment(self, cr, uid, context={}): last_action_date = '' if 'segment_ids' in context: segment_ids = context['segment_ids'] last_action_date = (datetime.now() + _intervalTypes['days'](-1) \ ).strftime('%Y-%m-%d %H:%M:%S')
defprocess_segment(self,cr,uid,context={}):last_action_date=''if'segment_ids'incontext:segment_ids=context['segment_ids']last_action_date=(datetime.now()+_intervalTypes['days'](-1)\).strftime('%Y-%m-%d%H:%M:%S')
470,365
def process_segment(self, cr, uid, context={}): last_action_date = '' if 'segment_ids' in context: segment_ids = context['segment_ids'] last_action_date = (datetime.now() + _intervalTypes['days'](-1) \ ).strftime('%Y-%m-%d %H:%M:%S')
def process_segment(self, cr, uid, context={}): last_action_date = '' if 'segment_ids' in context: segment_ids = context['segment_ids'] last_action_date = (datetime.now() + _intervalTypes['days'](-1) \ ).strftime('%Y-%m-%d %H:%M:%S')
470,366
def process_segment(self, cr, uid, context={}): last_action_date = '' if 'segment_ids' in context: segment_ids = context['segment_ids'] last_action_date = (datetime.now() + _intervalTypes['days'](-1) \ ).strftime('%Y-%m-%d %H:%M:%S')
def process_segment(self, cr, uid, context={}): last_action_date = '' if 'segment_ids' in context: segment_ids = context['segment_ids'] last_action_date = (datetime.now() + _intervalTypes['days'](-1) \ ).strftime('%Y-%m-%d %H:%M:%S')
470,367
def process_segment(self, cr, uid, context={}): last_action_date = '' if 'segment_ids' in context: segment_ids = context['segment_ids'] last_action_date = (datetime.now() + _intervalTypes['days'](-1) \ ).strftime('%Y-%m-%d %H:%M:%S')
def process_segment(self, cr, uid, context={}): last_action_date = '' if 'segment_ids' in context: segment_ids = context['segment_ids'] last_action_date = (datetime.now() + _intervalTypes['days'](-1) \ ).strftime('%Y-%m-%d %H:%M:%S')
470,368
def process_segment(self, cr, uid, context={}): last_action_date = '' if 'segment_ids' in context: segment_ids = context['segment_ids'] last_action_date = (datetime.now() + _intervalTypes['days'](-1) \ ).strftime('%Y-%m-%d %H:%M:%S')
def process_segment(self, cr, uid, context={}): last_action_date = '' if 'segment_ids' in context: segment_ids = context['segment_ids'] last_action_date = (datetime.now() + _intervalTypes['days'](-1) \ ).strftime('%Y-%m-%d %H:%M:%S')
470,369
def __init__(self, *args): self._actions = {'paper' : self.process_wi_report, 'email' : self.process_wi_email, 'server_action' : self.process_wi_action, } return super(marketing_campaign_activity, self).__init__(*args)
def__init__(self,*args):self._actions={'paper':self.process_wi_report,'email':self.process_wi_email,'server_action':self.process_wi_action,}returnsuper(marketing_campaign_activity,self).__init__(*args)
470,370
def process(self, cr, uid, act_id, wi_id, context={}): activity = self.browse(cr, uid, act_id) workitem_obj = self.pool.get('marketing.campaign.workitem') workitem = workitem_obj.browse(cr, uid, wi_id) self._actions[activity.type](cr, uid, activity, workitem) return True
def process(self, cr, uid, act_id, wi_id, context={}): activity = self.browse(cr, uid, act_id) workitem_obj = self.pool.get('marketing.campaign.workitem') workitem = workitem_obj.browse(cr, uid, wi_id) self._actions[activity.type](cr, uid, activity, workitem) return True
470,371
def default_get(self, cr, uid, fields, context={}): value = super(marketing_campaign_transition, self).default_get(cr, uid, fields, context) if context.has_key('type_id'): value[context['type_id']] = context['activity_id'] return value
def default_get(self, cr, uid, fields, context={}): value = super(marketing_campaign_transition, self).default_get(cr, uid, fields, context) if context.has_key('type_id'): value[context['type_id']] = context['activity_id'] return value
470,372
def process_chain(self, cr, uid, workitem_id, context={}): workitem = self.browse(cr, uid, workitem_id) mct_obj = self.pool.get('marketing.campaign.transition') process_to_id = mct_obj.search(cr,uid, [ ('activity_from_id','=', workitem.activity_id.id)]) for mct_id in mct_obj.browse(cr, uid, process_to_id): if mct_id.interval_type and mct_id.interval_nbr : launch_date = (datetime.now() + _intervalTypes[ \ mct_id.interval_type](mct_id.interval_nbr) \ ).strftime('%Y-%m-%d %H:%M:%S') launch_date = time.strftime('%Y-%m-%d %H:%M:%S') workitem_vals = {'segment_id': workitem.segment_id.id, 'activity_id': mct_id.activity_to_id.id, 'date': launch_date, 'partner_id': workitem.partner_id.id, 'state': 'todo', } self.create(cr, uid, workitem_vals)
def process_chain(self, cr, uid, workitem_id, context={}): workitem = self.browse(cr, uid, workitem_id) for mct_id in workitem.activity_id.to_ids: launch_date = time.strftime('%Y-%m-%d %H:%M:%S') if mct_id.interval_type and mct_id.interval_nbr : launch_date = (datetime.now() + _intervalTypes[ \ mct_id.interval_type](mct_id.interval_nbr) \ ).strftime('%Y-%m-%d %H:%M:%S') launch_date = time.strftime('%Y-%m-%d %H:%M:%S') workitem_vals = {'segment_id': workitem.segment_id.id, 'activity_id': mct_id.activity_to_id.id, 'date': launch_date, 'partner_id': workitem.partner_id.id, 'state': 'todo', } self.create(cr, uid, workitem_vals)
470,373
def process_chain(self, cr, uid, workitem_id, context={}): workitem = self.browse(cr, uid, workitem_id) mct_obj = self.pool.get('marketing.campaign.transition') process_to_id = mct_obj.search(cr,uid, [ ('activity_from_id','=', workitem.activity_id.id)]) for mct_id in mct_obj.browse(cr, uid, process_to_id): if mct_id.interval_type and mct_id.interval_nbr : launch_date = (datetime.now() + _intervalTypes[ \ mct_id.interval_type](mct_id.interval_nbr) \ ).strftime('%Y-%m-%d %H:%M:%S') launch_date = time.strftime('%Y-%m-%d %H:%M:%S') workitem_vals = {'segment_id': workitem.segment_id.id, 'activity_id': mct_id.activity_to_id.id, 'date': launch_date, 'partner_id': workitem.partner_id.id, 'state': 'todo', } self.create(cr, uid, workitem_vals)
def process_chain(self, cr, uid, workitem_id, context={}): workitem = self.browse(cr, uid, workitem_id) mct_obj = self.pool.get('marketing.campaign.transition') process_to_id = mct_obj.search(cr,uid, [ ('activity_from_id','=', workitem.activity_id.id)]) for mct_id in mct_obj.browse(cr, uid, process_to_id): if mct_id.interval_type and mct_id.interval_nbr : launch_date = (datetime.now() + _intervalTypes[ \ mct_id.interval_type](mct_id.interval_nbr) \ ).strftime('%Y-%m-%d %H:%M:%S') workitem_vals = { 'segment_id': workitem.segment_id.id, 'activity_id': mct_id.activity_to_id.id, 'date': launch_date, 'partner_id': workitem.partner_id.id, 'res_id': workitem.res_id, 'state': 'todo', } self.create(cr, uid, workitem_vals)
470,374
def button_cancel(self, cr, uid, workitem_ids, context={}): for wi in self.browse(cr, uid, workitem_ids): if wi.state in ('todo','exception'): self.write(cr, uid, [wi.id], {'state':'cancelled'}, context=context) return True
def button_cancel(self, cr, uid, workitem_ids, context={}): for wi in self.browse(cr, uid, workitem_ids): if wi.state in ('todo','exception'): self.write(cr, uid, [wi.id], {'state':'cancelled'}, context=context) return True
470,375
def process(self, cr, uid, workitem_ids, context={}): for wi in self.browse(cr, uid, workitem_ids): if wi.state == 'todo':# we searched the wi which are in todo state #then y v keep this filter again eval_context = { 'pool': self.pool, 'cr': cr, 'uid': uid, 'wi': wi, 'object': wi.activity_id, 'transition': wi.activity_id.to_ids } expr = eval(str(wi.activity_id.condition), eval_context) if expr: try : res = self.pool.get('marketing.campaign.activity').process( cr, uid, wi.activity_id.id, wi.id, context) if res : self.write(cr, uid, wi.id, {'state': 'done'}) self.process_chain(cr, uid, wi.id, context) else : self.write(cr, uid, wi.id, {'state': 'exception', 'error_msg': res['error_msg']}) except Exception,e: self.write(cr, uid, wi.id, {'state': 'exception'}) else : self.write(cr, uid, wi.id, {'state': 'cancelled'})
def process(self, cr, uid, workitem_ids, context={}): for wi in self.browse(cr, uid, workitem_ids): if wi.state == 'todo':# we searched the wi which are in todo state #then y v keep this filter again eval_context = { 'pool': self.pool, 'cr': cr, 'uid': uid, 'wi': wi, 'object': wi.activity_id, 'transition': wi.activity_id.to_ids } expr = eval(str(wi.activity_id.condition), eval_context) if expr: try : res = self.pool.get('marketing.campaign.activity').process( cr, uid, wi.activity_id.id, wi.id, context) if res : self.write(cr, uid, wi.id, {'state': 'done'}) self.process_chain(cr, uid, wi.id, context) else : self.write(cr, uid, wi.id, {'state': 'exception', 'error_msg': res['error_msg']}) except Exception,e: self.write(cr, uid, wi.id, {'state': 'exception'}) else : self.write(cr, uid, wi.id, {'state': 'cancelled'})
470,376
def process(self, cr, uid, workitem_ids, context={}): for wi in self.browse(cr, uid, workitem_ids): if wi.state == 'todo':# we searched the wi which are in todo state #then y v keep this filter again eval_context = { 'pool': self.pool, 'cr': cr, 'uid': uid, 'wi': wi, 'object': wi.activity_id, 'transition': wi.activity_id.to_ids } expr = eval(str(wi.activity_id.condition), eval_context) if expr: try : res = self.pool.get('marketing.campaign.activity').process( cr, uid, wi.activity_id.id, wi.id, context) if res : self.write(cr, uid, wi.id, {'state': 'done'}) self.process_chain(cr, uid, wi.id, context) else : self.write(cr, uid, wi.id, {'state': 'exception', 'error_msg': res['error_msg']}) except Exception,e: self.write(cr, uid, wi.id, {'state': 'exception'}) else : self.write(cr, uid, wi.id, {'state': 'cancelled'})
def process(self, cr, uid, workitem_ids, context={}): for wi in self.browse(cr, uid, workitem_ids): if wi.state == 'todo':# we searched the wi which are in todo state #then y v keep this filter again eval_context = { 'pool': self.pool, 'cr': cr, 'uid': uid, 'wi': wi, 'object': wi.activity_id, 'transition': wi.activity_id.to_ids } expr = eval(str(wi.activity_id.condition), eval_context) if expr: try : if wi.campaign_id.mode in ('manual','active'): self.pool.get('marketing.campaign.activity').process( cr, uid, wi.activity_id.id, wi.id, context) self.write(cr, uid, wi.id, {'state': 'done'}) self.process_chain(cr, uid, wi.id, context) except Exception,e: self.write(cr, uid, wi.id, {'state': 'exception'}) else : self.write(cr, uid, wi.id, {'state': 'cancelled'})
470,377
def process_all(self, cr, uid, context={}): workitem_ids = self.search(cr, uid, [('state', '=', 'todo'), ('date','<=', time.strftime('%Y-%m-%d %H:%M:%S'))]) if workitem_ids: self.process(cr, uid, workitem_ids, context)
def process_all(self, cr, uid, context={}): camp_obj = self.pool.get('marketing.campaign') camp_ids = camp_obj.search(cr, uid, [('state','=','running')], context=context) for camp in camp_obj.browse(cr, uid, camp_ids, context=context): if camp.mode in ('test_realtime','active'): workitem_ids = self.search(cr, uid, [('state', '=', 'todo'), ('date','<=', time.strftime('%Y-%m-%d %H:%M:%S'))]) if workitem_ids: self.process(cr, uid, workitem_ids, context)
470,378
def process_all(self, cr, uid, context={}): workitem_ids = self.search(cr, uid, [('state', '=', 'todo'), ('date','<=', time.strftime('%Y-%m-%d %H:%M:%S'))]) if workitem_ids: self.process(cr, uid, workitem_ids, context)
def process_all(self, cr, uid, context={}): workitem_ids = self.search(cr, uid, [('state', '=', 'todo'), ('date','<=', time.strftime('%Y-%m-%d %H:%M:%S'))]) if workitem_ids: self.process(cr, uid, workitem_ids, context)
470,379
def process_all(self, cr, uid, context={}): workitem_ids = self.search(cr, uid, [('state', '=', 'todo'), ('date','<=', time.strftime('%Y-%m-%d %H:%M:%S'))]) if workitem_ids: self.process(cr, uid, workitem_ids, context)
defprocess_all(self,cr,uid,context={}):workitem_ids=self.search(cr,uid,[('state','=','todo'),('date','<=',time.strftime('%Y-%m-%d%H:%M:%S'))])ifworkitem_ids:self.process(cr,uid,workitem_ids,context)
470,380
def process_all(self, cr, uid, context={}): workitem_ids = self.search(cr, uid, [('state', '=', 'todo'), ('date','<=', time.strftime('%Y-%m-%d %H:%M:%S'))]) if workitem_ids: self.process(cr, uid, workitem_ids, context)
defprocess_all(self,cr,uid,context={}):workitem_ids=self.search(cr,uid,[('state','=','todo'),('date','<=',time.strftime('%Y-%m-%d%H:%M:%S'))])ifworkitem_ids:self.process(cr,uid,workitem_ids,context)
470,381
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): if not context: context = {} if context and 'object_id' in context and context['object_id']: model = self.pool.get('ir.model').browse(cr, uid, context['object_id']).model args.append(('model', '=', model)) return super(report_xml, self).search(cr, uid, args, offset, limit, order, context, count)
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): if not context: context = {} if context and 'object_id' in context and context['object_id']: model = self.pool.get('ir.model').browse(cr, uid, context['object_id']).model args.append(('model', '=', model)) return super(report_xml, self).search(cr, uid, args, offset, limit, order, context, count)
470,382
def __init__(self, pool, dbname, serialized=False): self.sql_from_log = {} self.sql_into_log = {}
def __init__(self, pool, dbname, serialized=False): self.sql_from_log = {} self.sql_into_log = {}
470,383
def __del__(self): if not self.__closed: # Oops. 'self' has not been closed explicitly. # The cursor will be deleted by the garbage collector, # but the database connection is not put back into the connection # pool, preventing some operation on the database like dropping it. # This can also lead to a server overload. msg = "Cursor not closed explicitly\n" \ "Cursor was created at %s:%s" self.__logger.warn(msg, *self.__caller) self._close(True)
def __del__(self): if not self.__closed: # Oops. 'self' has not been closed explicitly. # The cursor will be deleted by the garbage collector, # but the database connection is not put back into the connection # pool, preventing some operation on the database like dropping it. # This can also lead to a server overload. msg = "Cursor not closed explicitly\n" if self.__caller: msg += "Cursor was created at %s:%s" % self.__caller else: msg += "Please enable sql debugging to trace the caller." self.__logger.warn(msg) self._close(True)
470,384
def create(self, cr, uid, vals, context=None): if context is None: context = {} id = super(hr_employee, self).create(cr, uid, vals, context=context) if vals.get('evaluation_plan_id', False): self.pool.get('hr_evaluation.evaluation').create(cr, uid, {'employee_id' : id, 'plan_id': vals['evaluation_plan_id']}, context=context) return id
def create(self, cr, uid, vals, context=None): if context is None: context = {} id = super(hr_employee, self).create(cr, uid, vals, context=context) if vals.get('evaluation_plan_id', False): self.pool.get('hr_evaluation.evaluation').create(cr, uid, {'employee_id' : id, 'plan_id': vals['evaluation_plan_id']}, context=context) return id
470,385
def button_plan_in_progress(self, cr, uid, ids, context=None): hr_eval_inter_obj = self.pool.get('hr.evaluation.interview') if context is None: context = {} apprai_id = [] for evaluation in self.browse(cr, uid, ids, context=context): wait = False for phase in evaluation.plan_id.phase_ids: childs = [] if phase.action == "bottom-up": childs = evaluation.employee_id.child_ids elif phase.action in ("top-down", "final"): if evaluation.employee_id.parent_id: childs = [evaluation.employee_id.parent_id] elif phase.action == "self": childs = [evaluation.employee_id] for child in childs:
def button_plan_in_progress(self, cr, uid, ids, context=None): hr_eval_inter_obj = self.pool.get('hr.evaluation.interview') if context is None: context = {} apprai_id = [] for evaluation in self.browse(cr, uid, ids, context=context): wait = False for phase in evaluation.plan_id.phase_ids: childs = [] if phase.action == "bottom-up": childs = evaluation.employee_id.child_ids elif phase.action in ("top-down", "final"): if evaluation.employee_id.parent_id: childs = [evaluation.employee_id.parent_id] elif phase.action == "self": childs = [evaluation.employee_id] for child in childs:
470,386
def view_init(self, cr, uid, fields_list, context=None): if context is None: context = {} res= super(stock_invoice_onshipping, self).view_init(cr, uid, fields_list, context=context) pick_obj=self.pool.get('stock.picking') count=0 for pick in pick_obj.browse(cr, uid,context.get('active_ids', False)): if pick.invoice_state != '2binvoiced': count=count+1 if len(context.get('active_ids'))==1 and count==1: raise osv.except_osv(_('Warning !'),'This picking list does not require invoicing.') if len(context.get('active_ids'))==count: raise osv.except_osv(_('Warning !'),'None of these picking lists require invoicing.') return res
def view_init(self, cr, uid, fields_list, context=None): if context is None: context = {} res = super(stock_invoice_onshipping, self).view_init(cr, uid, fields_list, context=context) pick_obj = self.pool.get('stock.picking') count = 0 active_ids = context.get('active_ids',[]) for pick in pick_obj.browse(cr, uid, active_ids): if pick.invoice_state != '2binvoiced': count=count+1 if len(context.get('active_ids'))==1 and count==1: raise osv.except_osv(_('Warning !'),'This picking list does not require invoicing.') if len(context.get('active_ids'))==count: raise osv.except_osv(_('Warning !'),'None of these picking lists require invoicing.') return res
470,387
def view_init(self, cr, uid, fields_list, context=None): if context is None: context = {} res= super(stock_invoice_onshipping, self).view_init(cr, uid, fields_list, context=context) pick_obj=self.pool.get('stock.picking') count=0 for pick in pick_obj.browse(cr, uid,context.get('active_ids', False)): if pick.invoice_state != '2binvoiced': count=count+1 if len(context.get('active_ids'))==1 and count==1: raise osv.except_osv(_('Warning !'),'This picking list does not require invoicing.') if len(context.get('active_ids'))==count: raise osv.except_osv(_('Warning !'),'None of these picking lists require invoicing.') return res
def view_init(self, cr, uid, fields_list, context=None): if context is None: context = {} res= super(stock_invoice_onshipping, self).view_init(cr, uid, fields_list, context=context) pick_obj=self.pool.get('stock.picking') count=0 for pick in pick_obj.browse(cr, uid,context.get('active_ids', False)): if pick.invoice_state != '2binvoiced': count += 1 if len(active_ids) == 1 and count: raise osv.except_osv(_('Warning !'), _('This picking list does not require invoicing.')) if len(active_ids) == count: raise osv.except_osv(_('Warning !'), _('None of these picking lists require invoicing.')) return res
470,388
def view_init(self, cr, uid, fields_list, context=None): if context is None: context = {} res= super(stock_invoice_onshipping, self).view_init(cr, uid, fields_list, context=context) pick_obj=self.pool.get('stock.picking') count=0 for pick in pick_obj.browse(cr, uid,context.get('active_ids', False)): if pick.invoice_state != '2binvoiced': count=count+1 if len(context.get('active_ids'))==1 and count==1: raise osv.except_osv(_('Warning !'),'This picking list does not require invoicing.') if len(context.get('active_ids'))==count: raise osv.except_osv(_('Warning !'),'None of these picking lists require invoicing.') return res
def view_init(self, cr, uid, fields_list, context=None): if context is None: context = {} res= super(stock_invoice_onshipping, self).view_init(cr, uid, fields_list, context=context) pick_obj=self.pool.get('stock.picking') count=0 for pick in pick_obj.browse(cr, uid,context.get('active_ids', False)): if pick.invoice_state != '2binvoiced': count=count+1 if len(context.get('active_ids'))==1 and count==1: raise osv.except_osv(_('Warning !'),'This picking list does not require invoicing.') if len(context.get('active_ids'))==count: raise osv.except_osv(_('Warning !'),'None of these picking lists require invoicing.') return res
470,389
def _get_type(self, cr, uid, context=None): """ To get invoice type. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: The ID or list of IDs if we want more than one @param context: A standard dictionary @return: Invoice type """ if context is None: context = {} picking_obj = self.pool.get('stock.picking') src_usage = dest_usage = None for pick in picking_obj.browse(cr, uid, context['active_ids'], context=context): if pick.invoice_state=='2binvoiced': if pick.move_lines: src_usage = pick.move_lines[0].location_id.usage dest_usage = pick.move_lines[0].location_dest_id.usage if pick.type == 'out' and dest_usage == 'supplier': type = 'in_refund' elif pick.type == 'out' and dest_usage == 'customer': type = 'out_invoice' elif pick.type == 'in' and src_usage == 'supplier': type = 'in_invoice' elif pick.type == 'in' and src_usage == 'customer': type = 'out_refund' else: type = 'out_invoice' return type
def _get_type(self, cr, uid, context=None): """ To get invoice type. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: The ID or list of IDs if we want more than one @param context: A standard dictionary @return: Invoice type """ if context is None: context = {} picking_obj = self.pool.get('stock.picking') src_usage = dest_usage = None for pick in picking_obj.browse(cr, uid, context['active_ids'], context=context): if pick.invoice_state=='2binvoiced': if pick.move_lines: src_usage = pick.move_lines[0].location_id.usage dest_usage = pick.move_lines[0].location_dest_id.usage if pick.type == 'out' and dest_usage == 'supplier': type = 'in_refund' elif pick.type == 'out' and dest_usage == 'customer': type = 'out_invoice' elif pick.type == 'in' and src_usage == 'supplier': type = 'in_invoice' elif pick.type == 'in' and src_usage == 'customer': type = 'out_refund' else: type = 'out_invoice' return type
470,390
def create_invoice(self, cr, uid, ids, context): """ To create invoice @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs if we want more than one @param context: A standard dictionary @return: Invoice ids """ result = [] picking_obj = self.pool.get('stock.picking') mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') for onshipdata_obj in self.read(cr, uid, ids, ['journal_id', 'group', 'type', 'invoice_date']): if context.get('new_picking', False): onshipdata_obj[id] = onshipdata_obj.new_picking onshipdata_obj[ids] = onshipdata_obj.new_picking
def create_invoice(self, cr, uid, ids, context): """ To create invoice @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs if we want more than one @param context: A standard dictionary @return: Invoice ids """ result = [] picking_obj = self.pool.get('stock.picking') mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') for onshipdata_obj in self.read(cr, uid, ids, ['journal_id', 'group', 'type', 'invoice_date']): if context.get('new_picking', False): onshipdata_obj[id] = onshipdata_obj.new_picking onshipdata_obj[ids] = onshipdata_obj.new_picking
470,391
def create_invoice(self, cr, uid, ids, context): """ To create invoice @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs if we want more than one @param context: A standard dictionary @return: Invoice ids """ result = [] picking_obj = self.pool.get('stock.picking') mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') for onshipdata_obj in self.read(cr, uid, ids, ['journal_id', 'group', 'type', 'invoice_date']): if context.get('new_picking', False): onshipdata_obj[id] = onshipdata_obj.new_picking onshipdata_obj[ids] = onshipdata_obj.new_picking
def create_invoice(self, cr, uid, ids, context): """ To create invoice @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs if we want more than one @param context: A standard dictionary @return: Invoice ids """ result = [] picking_obj = self.pool.get('stock.picking') mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') for onshipdata_obj in self.read(cr, uid, ids, ['journal_id', 'group', 'type', 'invoice_date']): if context.get('new_picking', False): onshipdata_obj[id] = onshipdata_obj.new_picking onshipdata_obj[ids] = onshipdata_obj.new_picking
470,392
def create_invoice(self, cr, uid, ids, context): """ To create invoice @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs if we want more than one @param context: A standard dictionary @return: Invoice ids """ result = [] picking_obj = self.pool.get('stock.picking') mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') for onshipdata_obj in self.read(cr, uid, ids, ['journal_id', 'group', 'type', 'invoice_date']): if context.get('new_picking', False): onshipdata_obj[id] = onshipdata_obj.new_picking onshipdata_obj[ids] = onshipdata_obj.new_picking
def create_invoice(self, cr, uid, ids, context): """ To create invoice @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs if we want more than one @param context: A standard dictionary @return: Invoice ids """ result = [] picking_obj = self.pool.get('stock.picking') mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') for onshipdata_obj in self.read(cr, uid, ids, ['journal_id', 'group', 'type', 'invoice_date']): if context.get('new_picking', False): onshipdata_obj[id] = onshipdata_obj.new_picking onshipdata_obj[ids] = onshipdata_obj.new_picking
470,393
def _theorical_margin_calc(self, cr, uid, ids, name, arg, context=None): res = {} for account in self.browse(cr, uid, ids, context=context): res[account.id] = account.ca_theorical + account.total_cost for id in ids: res[id] = round(res.get(id, 0.0),2) return res
def _theorical_margin_calc(self, cr, uid, ids, name, arg, context=None): res = {} for account in self.browse(cr, uid, ids, context=context): res[account.id] = account.ca_theorical + account.total_cost for id in ids: res[id] = round(res.get(id, 0.0),2) return res
470,394
def _theorical_margin_calc(self, cr, uid, ids, name, arg, context=None): res = {} for account in self.browse(cr, uid, ids, context=context): res[account.id] = account.ca_theorical + account.total_cost for id in ids: res[id] = round(res.get(id, 0.0),2) return res
def _theorical_margin_calc(self, cr, uid, ids, name, arg, context=None): res = {} for account in self.browse(cr, uid, ids, context=context): res[account.id] = account.ca_theorical + account.total_cost for id in ids: res[id] = round(res.get(id, 0.0),2) return res
470,395
def sign_out_result(self, cr, uid, ids, context=None): if context is None: context = {} emp_obj = self.pool.get('hr.employee') for data in self.browse(cr, uid, ids, context=context): emp_id = data.emp_id.id emp_obj.attendance_action_change(cr, uid, [emp_id], type='action', dt=data.date) self._write(cr, uid, data, emp_id, context=context) return {}
def sign_out_result(self, cr, uid, ids, context=None): if context is None: context = {} emp_obj = self.pool.get('hr.employee') for data in self.browse(cr, uid, ids, context=context): emp_id = data.emp_id.id emp_obj.attendance_action_change(cr, uid, [emp_id], type='action', dt=data.date) self._write(cr, uid, data, emp_id, context=context) return {}
470,396
def sign_out_result(self, cr, uid, ids, context=None): if context is None: context = {} emp_obj = self.pool.get('hr.employee') for data in self.browse(cr, uid, ids, context=context): emp_id = data.emp_id.id emp_obj.attendance_action_change(cr, uid, [emp_id], type='action', dt=data.date) self._write(cr, uid, data, emp_id, context=context) return {}
defsign_out_result(self,cr,uid,ids,context=None):ifcontextisNone:context={}emp_obj=self.pool.get('hr.employee')fordatainself.browse(cr,uid,ids,context=context):emp_id=data.emp_id.idemp_obj.attendance_action_change(cr,uid,[emp_id],type='action',dt=data.date)self._write(cr,uid,data,emp_id,context=context)return{}
470,397
def check_state(self, cr, uid, ids, context=None): obj_model = self.pool.get('ir.model.data') if context is None: context = {} emp_id = self.default_get(cr, uid, context)['emp_id'] # get the latest action (sign_in or out) for this employee cr.execute('select action from hr_attendance where employee_id=%s and action in (\'sign_in\',\'sign_out\') order by name desc limit 1', (emp_id,)) res = (cr.fetchone() or ('sign_out',))[0] in_out = res == 'sign_out' and 'out' or 'in' #TODO: invert sign_in et sign_out model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_hr_timesheet_sign_%s' % in_out)], context=context) resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] return { 'name': 'Sign in / Sign out', 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'hr.sign.%s.project' % in_out, 'views': [(False,'tree'), (resource_id,'form')], 'type': 'ir.actions.act_window', 'target': 'new' }
def check_state(self, cr, uid, ids, context=None): obj_model = self.pool.get('ir.model.data') if context is None: context = {} emp_id = self.default_get(cr, uid, context)['emp_id'] # get the latest action (sign_in or out) for this employee cr.execute('select action from hr_attendance where employee_id=%s and action in (\'sign_in\',\'sign_out\') order by name desc limit 1', (emp_id,)) res = (cr.fetchone() or ('sign_out',))[0] in_out = (res == 'sign_out') and 'in' or 'out' #TODO: invert sign_in et sign_out model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_hr_timesheet_sign_%s' % in_out)], context=context) resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] return { 'name': 'Sign in / Sign out', 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'hr.sign.%s.project' % in_out, 'views': [(False,'tree'), (resource_id,'form')], 'type': 'ir.actions.act_window', 'target': 'new' }
470,398
def attendance_action_change(self, cr, uid, ids, type='action', context={}, dt=False, *args): id = False warning_sign = 'sign' if type == 'sign_in': warning_sign = "Sign In" elif type == 'sign_out': warning_sign = "Sign Out" for emp in self.read(cr, uid, ids, ['id'], context=context): if not self._action_check(cr, uid, emp['id'], dt, context): raise osv.except_osv(_('Warning'), _('You tried to %s with a date anterior to another event !\nTry to contact the administrator to correct attendances.')%(warning_sign,)) res = {'action' : type, 'employee_id' : emp['id']} if dt: res['name'] = dt id = self.pool.get('hr.attendance').create(cr, uid, res, context=context) if type != 'action': return id return True
def if isinstance(type,dict): type = type.get('type','action') attendance_action_change(self, if isinstance(type,dict): type = type.get('type','action') cr, if isinstance(type,dict): type = type.get('type','action') uid, if isinstance(type,dict): type = type.get('type','action') ids, if isinstance(type,dict): type = type.get('type','action') type='action', if isinstance(type,dict): type = type.get('type','action') context={}, if isinstance(type,dict): type = type.get('type','action') dt=False, if isinstance(type,dict): type = type.get('type','action') *args): if isinstance(type,dict): type = type.get('type','action') id if isinstance(type,dict): type = type.get('type','action') = if isinstance(type,dict): type = type.get('type','action') False if isinstance(type,dict): type = type.get('type','action') warning_sign if isinstance(type,dict): type = type.get('type','action') = if isinstance(type,dict): type = type.get('type','action') 'sign' if isinstance(type,dict): type = type.get('type','action') if isinstance(type,dict): type = type.get('type','action') if if isinstance(type,dict): type = type.get('type','action') type if isinstance(type,dict): type = type.get('type','action') == if isinstance(type,dict): type = type.get('type','action') 'sign_in': if isinstance(type,dict): type = type.get('type','action') warning_sign if isinstance(type,dict): type = type.get('type','action') = if isinstance(type,dict): type = type.get('type','action') "Sign if isinstance(type,dict): type = type.get('type','action') In" if isinstance(type,dict): type = type.get('type','action') elif if isinstance(type,dict): type = type.get('type','action') type if isinstance(type,dict): type = type.get('type','action') == if isinstance(type,dict): type = type.get('type','action') 'sign_out': if isinstance(type,dict): type = type.get('type','action') warning_sign if isinstance(type,dict): type = type.get('type','action') = if isinstance(type,dict): type = type.get('type','action') "Sign if isinstance(type,dict): type = type.get('type','action') Out" if isinstance(type,dict): type = type.get('type','action') if isinstance(type,dict): type = type.get('type','action') for if isinstance(type,dict): type = type.get('type','action') emp if isinstance(type,dict): type = type.get('type','action') in if isinstance(type,dict): type = type.get('type','action') self.read(cr, if isinstance(type,dict): type = type.get('type','action') uid, if isinstance(type,dict): type = type.get('type','action') ids, if isinstance(type,dict): type = type.get('type','action') ['id'], if isinstance(type,dict): type = type.get('type','action') context=context): if isinstance(type,dict): type = type.get('type','action') if if isinstance(type,dict): type = type.get('type','action') not if isinstance(type,dict): type = type.get('type','action') self._action_check(cr, if isinstance(type,dict): type = type.get('type','action') uid, if isinstance(type,dict): type = type.get('type','action') emp['id'], if isinstance(type,dict): type = type.get('type','action') dt, if isinstance(type,dict): type = type.get('type','action') context): if isinstance(type,dict): type = type.get('type','action') raise if isinstance(type,dict): type = type.get('type','action') osv.except_osv(_('Warning'), if isinstance(type,dict): type = type.get('type','action') _('You if isinstance(type,dict): type = type.get('type','action') tried if isinstance(type,dict): type = type.get('type','action') to if isinstance(type,dict): type = type.get('type','action') %s if isinstance(type,dict): type = type.get('type','action') with if isinstance(type,dict): type = type.get('type','action') a if isinstance(type,dict): type = type.get('type','action') date if isinstance(type,dict): type = type.get('type','action') anterior if isinstance(type,dict): type = type.get('type','action') to if isinstance(type,dict): type = type.get('type','action') another if isinstance(type,dict): type = type.get('type','action') event if isinstance(type,dict): type = type.get('type','action') !\nTry if isinstance(type,dict): type = type.get('type','action') to if isinstance(type,dict): type = type.get('type','action') contact if isinstance(type,dict): type = type.get('type','action') the if isinstance(type,dict): type = type.get('type','action') administrator if isinstance(type,dict): type = type.get('type','action') to if isinstance(type,dict): type = type.get('type','action') correct if isinstance(type,dict): type = type.get('type','action') attendances.')%(warning_sign,)) if isinstance(type,dict): type = type.get('type','action') if isinstance(type,dict): type = type.get('type','action') res if isinstance(type,dict): type = type.get('type','action') = if isinstance(type,dict): type = type.get('type','action') {'action' if isinstance(type,dict): type = type.get('type','action') : if isinstance(type,dict): type = type.get('type','action') type, if isinstance(type,dict): type = type.get('type','action') 'employee_id' if isinstance(type,dict): type = type.get('type','action') : if isinstance(type,dict): type = type.get('type','action') emp['id']} if isinstance(type,dict): type = type.get('type','action') if isinstance(type,dict): type = type.get('type','action') if if isinstance(type,dict): type = type.get('type','action') dt: if isinstance(type,dict): type = type.get('type','action') res['name'] if isinstance(type,dict): type = type.get('type','action') = if isinstance(type,dict): type = type.get('type','action') dt if isinstance(type,dict): type = type.get('type','action') if isinstance(type,dict): type = type.get('type','action') id if isinstance(type,dict): type = type.get('type','action') = if isinstance(type,dict): type = type.get('type','action') self.pool.get('hr.attendance').create(cr, if isinstance(type,dict): type = type.get('type','action') uid, if isinstance(type,dict): type = type.get('type','action') res, if isinstance(type,dict): type = type.get('type','action') context=context) if isinstance(type,dict): type = type.get('type','action') if isinstance(type,dict): type = type.get('type','action') if if isinstance(type,dict): type = type.get('type','action') type if isinstance(type,dict): type = type.get('type','action') != if isinstance(type,dict): type = type.get('type','action') 'action': if isinstance(type,dict): type = type.get('type','action') return if isinstance(type,dict): type = type.get('type','action') id if isinstance(type,dict): type = type.get('type','action') return if isinstance(type,dict): type = type.get('type','action') True if isinstance(type,dict): type = type.get('type','action')
470,399