rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
return
return
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
if name == "alarms":
if name == "alarms":
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
'res_id' : meeting.id,
'res_id' : meeting.id,
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
('weekly', 'Weekly'), ('monthly', 'Monthly'), ('yearly', 'Yearly'), ('custom','Custom')], 'Recurrency'),
('weekly', 'Weekly'), ('monthly', 'Monthly'), ('yearly', 'Yearly'), ('custom','Custom')], 'Recurrency'),
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
fnct_inv=_set_data, string='Attendees', type="text", multi='attendees'),
fnct_inv=_set_data, string='Attendees', type="text", multi='attendees'),
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
'show_as' : lambda *a : 'busy',
'show_as' : lambda *a : 'busy',
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
'action': 'display', 'description': meeting.description, 'name': meeting.name,
'action': 'display', 'description': meeting.description, 'name': meeting.name,
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]
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
'trigger_related': basic_alarm.trigger_related, 'trigger_duration': basic_alarm.trigger_duration, 'trigger_occurs': basic_alarm.trigger_occurs, 'trigger_interval': basic_alarm.trigger_interval, 'duration': basic_alarm.duration, 'repeat': basic_alarm.repeat,
'trigger_related': basic_alarm.trigger_related, 'trigger_duration': basic_alarm.trigger_duration, 'trigger_occurs': basic_alarm.trigger_occurs, 'trigger_interval': basic_alarm.trigger_interval, 'duration': basic_alarm.duration, 'repeat': basic_alarm.repeat,
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]
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
'event_end_date' : meeting.date_deadline, 'res_id' : meeting.id,
'event_end_date' : meeting.date_deadline, 'res_id' : meeting.id,
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]
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
'user_id' : uid }
'user_id' : uid }
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]
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
alarm_obj.unlink(cr, uid, alarm_ids)
alarm_obj.unlink(cr, uid, alarm_ids)
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
event_obj.__attribute__.update(self.__attribute__)
event_obj.__attribute__.update(self.__attribute__)
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
if is_exists:
if is_exists:
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
case_id = self.create(cr, uid, val) ids.append(case_id)
case_id = self.create(cr, uid, val) ids.append(case_id)
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
count = 0
count = 0
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
until_date = base_until_date and datetime.datetime.strptime(base_until_date, "%Y-%m-%d") or False
until_date = base_until_date and datetime.datetime.strptime(base_until_date, "%Y-%m-%d") or False
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
value = until_date.strftime("%Y%m%d%H%M%S")
value = until_date.strftime("%Y%m%d%H%M%S")
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S")
if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S")
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
until_date = arg[2]
until_date = arg[2]
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)
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
return self.get_recurrent_ids(cr, uid, res, start_date, until_date, limit)
if not isinstance(res,list): res= [res] 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)
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
and crm_case.date <= %s and crm_case.date_deadline >= %s and crm_case.user_id = ANY(%s) and meeting.show_as = %s",
and crm_case.date <= %s and crm_case.date_deadline >= %s and crm_case.user_id = ANY(%s) and meeting.show_as = %s",
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
res.update({user_id:status})
res.update({user_id:status})
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
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
if dav_time <= wtime:
if float(dav_time) == float(wtime):
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
7b2b72b2f47865f7c9d0a40d79fefe0a9727bef5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7b2b72b2f47865f7c9d0a40d79fefe0a9727bef5/caldav_node.py
raise wizard.except_wizard('Unmet dependency !', 'Following modules are uninstalled or unknown. \n\n'+'\n'.join(unmet_packages))
raise osv.except_osv('Unmet dependency !', 'Following modules are uninstalled or unknown. \n\n'+'\n'.join(unmet_packages))
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)
573ea5722f467031b1b018a3aa7e107c206da1ef /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/573ea5722f467031b1b018a3aa7e107c206da1ef/base_module_upgrade.py
'product_id': fields.many2one('product.product', 'Product', required=True, select=True, domain=[('type','<>','service')]), 'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product UoM'), required=True), 'product_uom': fields.many2one('product.uom', 'Unit of Measure', required=True),
'product_id': fields.many2one('product.product', 'Product', required=True, select=True, domain=[('type','<>','service')],states={'done': [('readonly', True)]}), 'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product UoM'), required=True,states={'done': [('readonly', True)]}), 'product_uom': fields.many2one('product.uom', 'Unit of Measure', required=True,states={'done': [('readonly', 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
e322b982c67bdf68a84192b0643a5e204d765ae3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e322b982c67bdf68a84192b0643a5e204d765ae3/stock.py
'location_id': fields.many2one('stock.location', 'Source Location', required=True, select=True, help="Sets a location if you produce at a fixed location. This can be a partner location if you subcontract the manufacturing operations."), 'location_dest_id': fields.many2one('stock.location', 'Destination Location', required=True, select=True, help="Location where the system will stock the finished products."),
'location_id': fields.many2one('stock.location', 'Source Location', required=True, select=True,states={'done': [('readonly', True)]}, help="Sets a location if you produce at a fixed location. This can be a partner location if you subcontract the manufacturing operations."), 'location_dest_id': fields.many2one('stock.location', 'Destination Location', required=True,states={'done': [('readonly', True)]}, select=True, help="Location where the system will stock the finished products."),
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
e322b982c67bdf68a84192b0643a5e204d765ae3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e322b982c67bdf68a84192b0643a5e204d765ae3/stock.py
'picking_id': fields.many2one('stock.picking', 'Picking List', select=True),
'picking_id': fields.many2one('stock.picking', 'Picking List', select=True,states={'done': [('readonly', 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
e322b982c67bdf68a84192b0643a5e204d765ae3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e322b982c67bdf68a84192b0643a5e204d765ae3/stock.py
def _get_company(self, cr, uid, ids, context={}):
def _get_company(self, cr, uid, context={}):
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]
4fd67b69c6b0fc3ce35920df8e8fdc664e1fbc7b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4fd67b69c6b0fc3ce35920df8e8fdc664e1fbc7b/account_cash_statement.py
user = user_pool.browse(cr, uid, uid, uid)
user = user_pool.browse(cr, uid, uid, context)
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]
4fd67b69c6b0fc3ce35920df8e8fdc664e1fbc7b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4fd67b69c6b0fc3ce35920df8e8fdc664e1fbc7b/account_cash_statement.py
def _get_cash_open_box_lines(self, cr, uid, ids, context={}):
def _get_cash_open_box_lines(self, cr, uid, context={}):
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
4fd67b69c6b0fc3ce35920df8e8fdc664e1fbc7b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4fd67b69c6b0fc3ce35920df8e8fdc664e1fbc7b/account_cash_statement.py
return res def _get_cash_close_box_lines(self, cr, uid, ids, context={}):
journal_ids = self.pool.get('account.journal').search(cr, uid, [('type','=','cash')], context=context) if journal_ids: results = self.search(cr, uid, [('journal_id','in',journal_ids),('state','=','confirm')],context=context) if results: cash_st = self.browse(cr, uid, results, context)[0] for cash_line in cash_st.ending_details_ids: for r in res: if cash_line.pieces == r['pieces']: r['number'] = cash_line.number return res def _get_default_cash_close_box_lines(self, cr, uid, context={}):
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
4fd67b69c6b0fc3ce35920df8e8fdc664e1fbc7b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4fd67b69c6b0fc3ce35920df8e8fdc664e1fbc7b/account_cash_statement.py
res.append((0, 0, dct))
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))
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
4fd67b69c6b0fc3ce35920df8e8fdc664e1fbc7b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4fd67b69c6b0fc3ce35920df8e8fdc664e1fbc7b/account_cash_statement.py
'ending_details_ids':_get_cash_open_box_lines
'ending_details_ids':_get_default_cash_close_box_lines
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
4fd67b69c6b0fc3ce35920df8e8fdc664e1fbc7b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4fd67b69c6b0fc3ce35920df8e8fdc664e1fbc7b/account_cash_statement.py
cr.execute("select id from account_bank_statement where journal_id=%s and user_id=%s and state=%s order by id desc limit 1", (statement.journal_id.id, uid, 'confirm')) rs = cr.fetchone() rs = rs and rs[0] or None if rs: if len(statement.starting_details_ids) > 0: sid = [] for line in statement.starting_details_ids: sid.append(line.id) cash_pool.unlink(cr, uid, sid) statement = statement_pool.browse(cr, uid, rs) balance_start = statement.balance_end_real or 0.0 open_ids = cash_pool.search(cr, uid, [('ending_id','=',statement.id)]) for sid in open_ids: default = { 'ending_id': False, 'starting_id':ids[0] } cash_pool.copy(cr, uid, sid, default)
def button_open(self, cr, uid, ids, context=None):
4fd67b69c6b0fc3ce35920df8e8fdc664e1fbc7b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4fd67b69c6b0fc3ce35920df8e8fdc664e1fbc7b/account_cash_statement.py
{'login': email,
{'login': user.user_id.login,
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)
78ca098cf7fe60dc4b69a20ce0dcdbfd0919a84b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/78ca098cf7fe60dc4b69a20ce0dcdbfd0919a84b/share_wizard.py
'dbame': cr.dbname} if format_url else share_root_url
'dbname': cr.dbname} if format_url else share_root_url
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)
78ca098cf7fe60dc4b69a20ce0dcdbfd0919a84b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/78ca098cf7fe60dc4b69a20ce0dcdbfd0919a84b/share_wizard.py
obj_fy=self.browse(cr,uid,ids[0])
obj_fy = self.browse(cr,uid,ids[0])
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
0d467eeea01a357ff900af7e3c1985980995335f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0d467eeea01a357ff900af7e3c1985980995335f/account.py
(_check_duration, 'Error ! The duration of the Fiscal Year is invalid. ', ['date_stop'])
(_check_duration, 'Error ! The duration of the Fiscal Year is invalid. ', ['date_stop']), (_check_fiscal_year, 'Error ! This Fiscal Year overlaps an existing Fiscal Year',['date_start', 'date_stop'])
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
0d467eeea01a357ff900af7e3c1985980995335f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0d467eeea01a357ff900af7e3c1985980995335f/account.py
name = cls._name or cls._inherit
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)
e5af7c9c7364d03b834b40a8db9c862fcec1b270 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e5af7c9c7364d03b834b40a8db9c862fcec1b270/osv.py
name = cls._name or cls._inherit
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
e5af7c9c7364d03b834b40a8db9c862fcec1b270 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e5af7c9c7364d03b834b40a8db9c862fcec1b270/osv.py
line = self.finalize_invoice_move_lines(self, cr, uid, inv, line)
line = self.finalize_invoice_move_lines(cr, uid, inv, line)
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
20996ec0cb286298cf34e1a1f718c08c09579e68 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/20996ec0cb286298cf34e1a1f718c08c09579e68/invoice.py
if self._columns[field]._type == 'reference': val = vals[field].split(',')[0] else: val = vals[field] if isinstance(self._columns[field].selection, (tuple, list)): if val not in dict(self._columns[field].selection): raise except_orm(_('ValidateError'), _('The value "%s" for the field "%s" is not in the selection') \ % (vals[field], field)) else: if val not in dict(self._columns[field].selection( self, cr, user, context=context)): raise except_orm(_('ValidateError'), _('The value "%s" for the field "%s" is not in the selection') \ % (vals[field], field))
self._check_selection_field_value(cr, user, field, vals[field], context=context)
def create(self, cr, user, vals, context=None): """ Create new record with specified value
0fedbb3215081590d6d7fc52bb29f56dedd271e1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0fedbb3215081590d6d7fc52bb29f56dedd271e1/orm.py
try: return self._login(db, login, password) except Exception, e: import logging logging.getLogger('netsvc').exception('Could not authenticate') return Exception('Access Denied') def _login(self, db, login, password):
def login(self, db, login, password):
b102ade21f740d008611203cd38a28a83e28c866 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b102ade21f740d008611203cd38a28a83e28c866/crypt.py
cr = pooler.get_db(db).cursor()
cr = None try: cr = pooler.get_db(db).cursor() return self._login(cr, db, login, password) except Exception, e: if cr: cr.close() import logging logging.getLogger('netsvc').exception('Could not authenticate') return Exception('Access Denied') def _login(self, cr, db, login, password):
def _login(self, db, login, password): if not password: return False if db is False: raise RuntimeError("Cannot authenticate to False db!")
b102ade21f740d008611203cd38a28a83e28c866 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b102ade21f740d008611203cd38a28a83e28c866/crypt.py
def _process_wi_paper(self, cr, uid, activity, workitem, context=None):
def _process_wi_report(self, cr, uid, activity, workitem, context=None):
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
5247699a18d2d6e00b926eefd35827e885793326 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/5247699a18d2d6e00b926eefd35827e885793326/marketing_campaign.py
result['periods'] = lambda x: x[0], cr.fetchall()
result['periods'] = map(lambda x: x[0], cr.fetchall())
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
8d32deca8ca9ca51b49710c8404d50ee00cac5e3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/8d32deca8ca9ca51b49710c8404d50ee00cac5e3/account_common_report.py
quantity = context.get('quantity', 1)
quantity = context.get('quantity') or 1.0
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
88d2e8b5301aadca2355031a3c80a82358c82f68 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/88d2e8b5301aadca2355031a3c80a82358c82f68/product.py
address_obj.write(cr, uid, user.address_id.id, {'email': value or None}, context=context)
address_obj.write(cr, 1, user.address_id.id, {'email': value or None})
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
6164550d1d7ff4113e9a4994d29b58937c766786 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6164550d1d7ff4113e9a4994d29b58937c766786/res_user.py
address_id = address_obj.create(cr, uid, {'name': user.name, 'email': value or None}, context=context)
address_id = address_obj.create(cr, 1, {'name': user.name, 'email': value or None})
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
6164550d1d7ff4113e9a4994d29b58937c766786 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6164550d1d7ff4113e9a4994d29b58937c766786/res_user.py
if not self._user_allow(cr, uid, statement.id, context=context):
force_allow = context.get('force_allow',False) if not force_allow and not self._user_allow(cr, uid, statement.id, context=context):
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 = {}
abc40474e03ee0f6f1a855ecd461a7561adfe579 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/abc40474e03ee0f6f1a855ecd461a7561adfe579/account_cash_statement.py
val = {'partner_invoice_id': addr['invoice'], 'partner_order_id': addr['contact'], 'partner_shipping_id': addr['delivery'], 'payment_term': payment_term, 'fiscal_position': fiscal_position}
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, }
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}
7f1589769b193a9e127e810c95abc47eb5868bf1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7f1589769b193a9e127e810c95abc47eb5868bf1/sale.py
print 'false 1',model,fields,e
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)
8994901475defa1a651a0b0db80b76f994e35bf0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/8994901475defa1a651a0b0db80b76f994e35bf0/ir_values.py
print 'false 2'
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)
8994901475defa1a651a0b0db80b76f994e35bf0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/8994901475defa1a651a0b0db80b76f994e35bf0/ir_values.py
raise osv.except_osv("Error", "There is no associate activitity for the campaign")
raise osv.except_osv("Error", "There is no activitity in the campaign")
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
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
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')])
raise osv.except_osv("Error", "There is no starting activitity in the campaign")
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
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
raise osv.except_osv("Error", "Camapign cannot be done before all segments are done")
raise osv.except_osv("Error", "Campaign cannot be marked as done before all segments are done")
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
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
marketing_campaign() class marketing_campaign_segment(osv.osv):
marketing_campaign() class marketing_campaign_segment(osv.osv):
def state_cancel_set(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state': 'cancelled'}) return True
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
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')
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
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")
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
[('state', 'in', ['inprogress', 'todo']), ('segment_id', '=', ids[0])]) if wi_ids : raise osv.except_osv("Error", "Segment cannot be done before all workitems are processed") self.write(cr, uid, ids, {'state': 'done'})
[('state', '=', 'todo'), ('segment_id', 'in', ids)]) self.pool.get("marketing.campaign.workitem").write(cr, uid, wi_ids, {'state':'cancelled'}) self.write(cr, uid, ids, {'state': 'done','date_done': time.strftime('%Y-%m-%d %H:%M:%S')})
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")
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
self.write(cr, uid, ids, {'state': 'cancelled'}) return True
wi_ids = self.pool.get("marketing.campaign.workitem").search(cr, uid, [('state', '=', 'todo'), ('segment_id', 'in', ids)]) self.pool.get("marketing.campaign.workitem").write(cr, uid, wi_ids, {'state':'cancelled'}) self.write(cr, uid, ids, {'state': 'cancelled','date_done': time.strftime('%Y-%m-%d %H:%M:%S')}) return True
def state_cancel_set(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state': 'cancelled'}) return True
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
self.process_segment(cr, uid, {'segment_ids' : ids})
self.process_segment(cr, uid, ids)
def synchroniz(self, cr, uid, ids, *args): self.process_segment(cr, uid, {'segment_ids' : ids}) return True
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
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') else : segment_ids = self.search(cr, uid, [('state', '=', 'running')])
def process_segment(self, cr, uid, segment_ids=None, context={}): if not segment_ids: segment_ids = self.search(cr, uid, [('state', '=', 'running')], context=context)
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')
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
for segment in self.browse(cr, uid, segment_ids):
for segment in self.browse(cr, uid, segment_ids, context=context):
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')
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
uid, [('start', '=', True), ('campaign_id', '=', segment.campaign_id.id)]) if (segment.sync_last_date and \ segment.sync_last_date <= action_date )\ or not segment.sync_last_date : model_obj = self.pool.get(segment.object_id.model) criteria = [(segment.sync_mode, '<=', action_date)] if last_action_date : criteria.append((segment.sync_mode, '>=', last_action_date)) object_ids = model_obj.search(cr, uid, criteria) for o_ids in model_obj.read(cr, uid, object_ids) : partner_id = 'partner_id' in o_ids and o_ids['partner_id'] \ or False if partner_id: for act_id in act_ids: wi_vals = {'segment_id': segment.id, 'activity_id': act_id, 'date': action_date, 'partner_id': partner_id[0], 'state': 'todo', } self.pool.get('marketing.campaign.workitem').create( cr, uid, wi_vals) self.write(cr, uid, segment.id, {'sync_last_date':action_date}) return True marketing_campaign_segment() class marketing_campaign_activity(osv.osv):
uid, [('start', '=', True), ('campaign_id', '=', segment.campaign_id.id)]) model_obj = self.pool.get(segment.object_id.model) criteria = [] if segment.sync_last_date: criteria += [(segment.sync_mode, '>', segment.sync_last_date)] if segment.ir_filter_id: criteria += segment.ir_filter_id.domain object_ids = model_obj.search(cr, uid, criteria) for o_ids in model_obj.browse(cr, uid, object_ids, context=context) : for act_id in act_ids: wi_vals = { 'segment_id': segment.id, 'activity_id': act_id, 'date': action_date, 'partner_id': o_ids.partner_id and o_ids.partner_id.id or False, 'state': 'todo', 'res_id': o_ids.id } self.pool.get('marketing.campaign.workitem').create(cr, uid, wi_vals) self.write(cr, uid, segment.id, {'sync_last_date':action_date}) return True marketing_campaign_segment() class marketing_campaign_activity(osv.osv):
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')
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
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')
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
('subcampaign', 'Sub-Campaign')]
('subcampaign', 'Sub-Campaign')]
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')
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
'start': fields.boolean('Start',help= "Its necessary to start activity \ before running campaign"),
'start': fields.boolean('Start',help= "This activity is launched when the campaign starts."),
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')
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
help="It is simple python condition that is to \ be tested before action is executed. Eg : revenue > 10"),
help="Python condition to know if the activity can be launched"),
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')
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
}
}
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')
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
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)
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
return True marketing_campaign_activity() class marketing_campaign_transition(osv.osv):
return True marketing_campaign_activity() class marketing_campaign_transition(osv.osv):
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
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
marketing_campaign_transition() class marketing_campaign_workitem(osv.osv):
marketing_campaign_transition() class marketing_campaign_workitem(osv.osv):
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
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
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):
for mct_id in workitem.activity_id.to_ids: launch_date = time.strftime('%Y-%m-%d %H:%M:%S')
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)
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
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', }
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', }
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)
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
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
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
if wi.state == 'todo':
if wi.state == 'todo':
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'})
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
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']})
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)
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'})
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
workitem_ids = self.search(cr, uid, [('state', '=', 'todo'),
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'),
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)
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
marketing_campaign_workitem()
marketing_campaign_workitem()
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)
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
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)
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
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)
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
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)
4760a832f354437350b06aae5ddce4f88aa00f51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4760a832f354437350b06aae5ddce4f88aa00f51/marketing_campaign.py
self.__caller = frame_codeinfo(currentframe(),2)
if self.sql_log: self.__caller = frame_codeinfo(currentframe(),2) else: self.__caller = False
def __init__(self, pool, dbname, serialized=False): self.sql_from_log = {} self.sql_into_log = {}
12f4f6232cf2b9bf2475844cdcdb12599bab952c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/12f4f6232cf2b9bf2475844cdcdb12599bab952c/sql_db.py
msg = "Cursor not closed explicitly\n" \ "Cursor was created at %s:%s" self.__logger.warn(msg, *self.__caller)
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)
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)
12f4f6232cf2b9bf2475844cdcdb12599bab952c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/12f4f6232cf2b9bf2475844cdcdb12599bab952c/sql_db.py
'date' : lambda *a: (parser.parse(datetime.date.today().strftime('%Y-%m-%d')) + relativedelta(months =+ 1)).strftime('%Y-%m-%d'),
'date' : lambda *a: (parser.parse(datetime.now().strftime('%Y-%m-%d')) + relativedelta(months =+ 1)).strftime('%Y-%m-%d'),
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
7604859423abfdf9e74b502298d57ea590d77636 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7604859423abfdf9e74b502298d57ea590d77636/hr_evaluation.py
'date_deadline': (parser.parse(datetime.date.today().strftime('%Y-%m-%d')) + relativedelta(months =+ 1)).strftime('%Y-%m-%d'),
'date_deadline': (parser.parse(datetime.now().strftime('%Y-%m-%d')) + relativedelta(months =+ 1)).strftime('%Y-%m-%d'),
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:
7604859423abfdf9e74b502298d57ea590d77636 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7604859423abfdf9e74b502298d57ea590d77636/hr_evaluation.py
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)):
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):
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
68a015bc4203dd005537806be9b34072f6dd0e25 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/68a015bc4203dd005537806be9b34072f6dd0e25/stock_invoice_onshipping.py
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.')
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.'))
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
68a015bc4203dd005537806be9b34072f6dd0e25 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/68a015bc4203dd005537806be9b34072f6dd0e25/stock_invoice_onshipping.py
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 """
def _get_type(self, pick): src_usage = dest_usage = None pick_type = None 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': pick_type = 'in_refund' elif pick.type == 'out' and dest_usage == 'customer': pick_type = 'out_invoice' elif pick.type == 'in' and src_usage == 'supplier': pick_type = 'in_invoice' elif pick.type == 'in' and src_usage == 'customer': pick_type = 'out_refund' else: pick_type = 'out_invoice' return pick_type def create_invoice(self, cr, uid, ids, context=None):
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
68a015bc4203dd005537806be9b34072f6dd0e25 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/68a015bc4203dd005537806be9b34072f6dd0e25/stock_invoice_onshipping.py
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 _defaults = { 'type': _get_type, } 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 """
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
68a015bc4203dd005537806be9b34072f6dd0e25 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/68a015bc4203dd005537806be9b34072f6dd0e25/stock_invoice_onshipping.py
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
onshipdata_obj = self.read(cr, uid, ids[0], ['journal_id', 'group', '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
68a015bc4203dd005537806be9b34072f6dd0e25 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/68a015bc4203dd005537806be9b34072f6dd0e25/stock_invoice_onshipping.py
type = onshipdata_obj['type'] context['date_inv'] = onshipdata_obj['invoice_date'] res = picking_obj.action_invoice_create(cr, uid,context['active_ids'], journal_id = onshipdata_obj['journal_id'], group=onshipdata_obj['group'], type=type, context=context) invoice_ids = res.values() if not invoice_ids: raise osv.except_osv(_('Error'), _('Invoice is not created'))
context['date_inv'] = onshipdata_obj['invoice_date'] invoice_ids = [] for picking in picking_obj.browse(cr, uid, context.get('active_ids', []), context=context): if picking.invoice_state == '2binvoiced': res = picking_obj.action_invoice_create(cr, uid, [picking.id], journal_id = onshipdata_obj['journal_id'], group=onshipdata_obj['group'], type=self._get_type(picking), context=context) invoice_ids.extend(res.values()) if not invoice_ids: raise osv.except_osv(_('Error'), _('No invoice were created'))
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
68a015bc4203dd005537806be9b34072f6dd0e25 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/68a015bc4203dd005537806be9b34072f6dd0e25/stock_invoice_onshipping.py
'views': False,
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
68a015bc4203dd005537806be9b34072f6dd0e25 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/68a015bc4203dd005537806be9b34072f6dd0e25/stock_invoice_onshipping.py
'ca_theorical': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='float', string='Theorical Revenue',
'ca_theorical': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='float', string='Theoretical Revenue',
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
0ca6e99f67d85abaf2272302141555f7d648e2b2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0ca6e99f67d85abaf2272302141555f7d648e2b2/account_analytic_analysis.py
'theorical_margin': fields.function(_theorical_margin_calc, method=True, type='float', string='Theorical Margin',
'theorical_margin': fields.function(_theorical_margin_calc, method=True, type='float', string='Theoretical Margin',
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
0ca6e99f67d85abaf2272302141555f7d648e2b2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0ca6e99f67d85abaf2272302141555f7d648e2b2/account_analytic_analysis.py
'state': fields.char('Current state', size=32, readonly=True),
'state': fields.related('emp_id', 'state', string='Current state', type='char', required=True, readonly=True),
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 {}
0f7486574ad35fbeba0bdd2b18dd42dbf5ff8752 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0f7486574ad35fbeba0bdd2b18dd42dbf5ff8752/hr_timesheet_sign_in_out.py
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 {}
0f7486574ad35fbeba0bdd2b18dd42dbf5ff8752 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0f7486574ad35fbeba0bdd2b18dd42dbf5ff8752/hr_timesheet_sign_in_out.py
in_out = res == 'sign_out' and 'out' or 'in'
in_out = (res == 'sign_out') and 'in' or 'out'
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' }
0f7486574ad35fbeba0bdd2b18dd42dbf5ff8752 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0f7486574ad35fbeba0bdd2b18dd42dbf5ff8752/hr_timesheet_sign_in_out.py
if isinstance(type,dict): type = type.get('type','action')
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
f1918969ee73de516c55b6894138ddae2fb76ce8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f1918969ee73de516c55b6894138ddae2fb76ce8/hr_attendance.py