From a26fe9f3d058149e4f5e966a4444957e1f2ad23c Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Tue, 6 Apr 2010 10:41:22 +0530 Subject: [PATCH 01/59] [REM]: crm: Removed unused date fields demo from opportunity bzr revid: rpa@tinyerp.com-20100406051122-mf72e1qpcrpn8g0l --- addons/crm/crm_opportunity_demo.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/addons/crm/crm_opportunity_demo.xml b/addons/crm/crm_opportunity_demo.xml index e88e0f1ec8e..b893d536e44 100644 --- a/addons/crm/crm_opportunity_demo.xml +++ b/addons/crm/crm_opportunity_demo.xml @@ -18,7 +18,6 @@ - @@ -34,7 +33,6 @@ - @@ -51,7 +49,6 @@ - @@ -68,7 +65,6 @@ - @@ -84,7 +80,6 @@ - From df4bf2ea53a09debbfe2f87acd44162c7446726b Mon Sep 17 00:00:00 2001 From: "Ysa (Open ERP)" Date: Tue, 6 Apr 2010 12:45:46 +0530 Subject: [PATCH 02/59] [IMP] board_document :- remove dependency report_document and change action name. bzr revid: ysa@tinyerp.co.in-20100406071546-yxbfqvkipy8rbm9e --- addons/board_document/__terp__.py | 2 +- addons/board_document/board_document_view.xml | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/board_document/__terp__.py b/addons/board_document/__terp__.py index 77fd09fdf45..3dcd00627b4 100644 --- a/addons/board_document/__terp__.py +++ b/addons/board_document/__terp__.py @@ -32,7 +32,7 @@ * Files by Month (graph) """, 'author': 'Tiny', - 'depends': ['board', 'document', 'report_document'], + 'depends': ['board', 'document'], 'update_xml': ['board_document_view.xml'], 'demo_xml': ['board_document_demo.xml'], 'installable': True, diff --git a/addons/board_document/board_document_view.xml b/addons/board_document/board_document_view.xml index a35e6f9efe7..8cedcd02296 100644 --- a/addons/board_document/board_document_view.xml +++ b/addons/board_document/board_document_view.xml @@ -15,24 +15,24 @@ + domain="[('name','=',time.strftime('%%Y')),('month','=',time.strftime('%%m'))]"/> @@ -75,19 +75,19 @@ From be62cac907e916d2ae64f7efd194e7c889eea71e Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Tue, 6 Apr 2010 12:55:15 +0530 Subject: [PATCH 03/59] [IMP]: base_calendar: Improvement in compute rrule string and fixed minor problem in set rrule function bzr revid: rpa@tinyerp.com-20100406072515-k51v9mq6mwx81t67 --- addons/base_calendar/base_calendar.py | 34 ++++++++++++++++----------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index f7608219b9d..c6bc1984f55 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -828,15 +828,16 @@ class calendar_event(osv.osv): Set rule string. @param self: The object pointer @param cr: the current row, from the database cursor, - @param id: List of calendar event's ids. + @param id: List of calendar event's ids. @param context: A standard dictionary for contextual values @return: dictionary of rrule value. """ - cr.execute("UPDATE %s set freq='',interval=0,count=0,end_date=Null,\ + cr.execute("UPDATE %s set freq='None',interval=0,count=0,end_date=Null,\ mo=False,tu=False,we=False,th=False,fr=False,sa=False,su=False,\ - day=0,select1=False,month_list=0 ,byday=False where id=%s" % (self._table, id)) + day=0,select1='date',month_list=Null ,byday=Null where id=%s" % (self._table, id)) if not value: + cr.execute("UPDATE %s set rrule_type='none' where id=%s" % (self._table, id)) return True val = {} for part in value.split(';'): @@ -849,7 +850,9 @@ class calendar_event(osv.osv): ans = value.split(';') for i in ans: val[i.split('=')[0].lower()] = i.split('=')[1].lower() - if int(val.get('interval')) > 1: #If interval is other than 1 rule is custom + if not val.get('interval'): + rrule_type = 'custom' + elif int(val.get('interval')) > 1: #If interval is other than 1 rule is custom rrule_type = 'custom' qry = "UPDATE %(table)s set rrule_type=\'%(rule_type)s\' " @@ -876,8 +879,12 @@ class calendar_event(osv.osv): if val.get('byday'): d = val.get('byday') - new_val['byday'] = d[:1] - new_val['week_list'] = d[1:].upper() + if '-' in d: + new_val['byday'] = d[:2] + new_val['week_list'] = d[2:4].upper() + else: + new_val['byday'] = d[:1] + new_val['week_list'] = d[1:3].upper() new_val['select1'] = 'day' if val.get('bymonth'): @@ -1136,7 +1143,7 @@ class calendar_event(osv.osv): @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param datas: dictionary of freq and interval value. - @return: string value which compute FREQILY;INTERVAL + @return: string value which compute FREQILY;INTERVAL """ weekdays = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su'] @@ -1148,9 +1155,8 @@ class calendar_event(osv.osv): if freq == 'None': return '' - if datas.get('interval') < 1: - raise osv.except_osv(_('Error!'), ("Please select proper Interval")) - + interval_srting = datas.get('interval') and (';INTERVAL=' + str(datas.get('interval'))) or '' + if freq == 'weekly': byday = map(lambda x: x.upper(), filter(lambda x: datas.get(x) and x in weekdays, datas)) @@ -1166,7 +1172,7 @@ class calendar_event(osv.osv): monthstring = ';BYMONTHDAY=' + str(datas.get('day')) elif freq == 'yearly': - if datas.get('select1')=='date' and (datas.get('day') < 1 or datas.get('day') > 31): + if datas.get('select1')=='date' and (datas.get('day') < 1 or datas.get('day') > 31): raise osv.except_osv(_('Error!'), ("Please select proper Day of month")) bymonth = ';BYMONTH=' + str(datas.get('month_list')) if datas.get('select1')=='day': @@ -1177,11 +1183,11 @@ class calendar_event(osv.osv): if datas.get('end_date'): datas['end_date'] = ''.join((re.compile('\d')).findall(datas.get('end_date'))) + '235959Z' - enddate = (datas.get('count') and (';COUNT=' + str(datas.get('count'))) or '') +\ + enddate = (datas.get('count') and (';COUNT=' + str(datas.get('count'))) or '') +\ ((datas.get('end_date') and (';UNTIL=' + datas.get('end_date'))) or '') - rrule_string = 'FREQ=' + freq.upper() + weekstring + ';INTERVAL=' + \ - str(datas.get('interval')) + enddate + monthstring + yearstring + rrule_string = 'FREQ=' + freq.upper() + weekstring + interval_srting \ + + enddate + monthstring + yearstring # End logic return rrule_string From e337a2a2166cc3cc931934dd8dabb1ba704c64df Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Tue, 6 Apr 2010 12:58:49 +0530 Subject: [PATCH 04/59] [IMP]: base_calendar: Improvement in code bzr revid: rpa@tinyerp.com-20100406072849-nuo7gib275wra1do --- addons/base_calendar/base_calendar.py | 126 ++++++++++++++------------ 1 file changed, 67 insertions(+), 59 deletions(-) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index c6bc1984f55..0e8b36bc3fd 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -90,7 +90,7 @@ def real_id2base_calendar_id(real_id, recurrent_date): if real_id and recurrent_date: recurrent_date = time.strftime("%Y%m%d%H%M%S", \ - time.strptime(recurrent_date, "%Y-%m-%d %H:%M:%S")) + time.strptime(recurrent_date, "%Y-%m-%d %H:%M:%S")) return '%d-%s' % (real_id, recurrent_date) return real_id @@ -253,7 +253,7 @@ class calendar_attendee(osv.osv): result[id][name] = '' continue else: - result[id][name] = self._get_address(attdata.sent_by_uid.name, \ + result[id][name] = self._get_address(attdata.sent_by_uid.name, \ attdata.sent_by_uid.address_id.email) if name == 'cn': if attdata.user_id: @@ -350,36 +350,37 @@ request was delegated to"), 'delegated_from': fields.function(_compute_data, method=True, string=\ 'Delegated From', type="char", store=True, size=124, multi='delegated_from'), 'parent_ids': fields.many2many('calendar.attendee', 'calendar_attendee_parent_rel',\ - 'attendee_id', 'parent_id', 'Delegrated From'), + 'attendee_id', 'parent_id', 'Delegrated From'), 'child_ids': fields.many2many('calendar.attendee', 'calendar_attendee_child_rel',\ 'attendee_id', 'child_id', 'Delegrated To'), 'sent_by': fields.function(_compute_data, method=True, string='Sent By',\ - type="char", multi='sent_by', store=True, size=124,\ - help="Specify the user that is acting on behalf of the calendar user"), + type="char", multi='sent_by', store=True, size=124,\ + help="Specify the user that is acting on behalf of the calendar user"), 'sent_by_uid': fields.function(_compute_data, method=True, string='Sent By User',\ - type="many2one", relation="res.users", multi='sent_by_uid'), + type="many2one", relation="res.users", multi='sent_by_uid'), 'cn': fields.function(_compute_data, method=True, string='Common name',\ - type="char", size=124, multi='cn', store=True), + type="char", size=124, multi='cn', store=True), 'dir': fields.char('URI Reference', size=124, help="Reference to the URI\ - that points to the directory information corresponding to the attendee."), - 'language': fields.function(_compute_data, method=True, string='Language',\ - type="selection", selection=_lang_get, multi='language',\ - store=True, help="To specify the language for text values in a\ - property or property parameter."), +that points to the directory information corresponding to the attendee."), + 'language': fields.function(_compute_data, method=True, string='Language',\ + type="selection", selection=_lang_get, multi='language',\ + store=True, help="To specify the language for text values in a\ +property or property parameter."), 'user_id': fields.many2one('res.users', 'User'), 'partner_address_id': fields.many2one('res.partner.address', 'Contact'), 'partner_id': fields.related('partner_address_id', 'partner_id', type='many2one',\ relation='res.partner', string='Partner', help="Partner related to contact"), 'email': fields.char('Email', size=124, help="Email of Invited Person"), 'event_date': fields.function(_compute_data, method=True, string='Event Date',\ - type="datetime", multi='event_date'), - 'event_end_date': fields.function(_compute_data, method=True, string='Event End Date',\ - type="datetime", multi='event_end_date'), + type="datetime", multi='event_date'), + 'event_end_date': fields.function(_compute_data, method=True, \ + string='Event End Date', type="datetime", \ + multi='event_end_date'), 'ref': fields.reference('Event Ref', selection=_links_get, size=128), 'availability': fields.selection([('free', 'Free'), ('busy', 'Busy')], 'Free/Busy', readonly="True"), } _defaults = { - 'state': lambda *x: 'needs-action', + 'state': lambda *x: 'needs-action', } response_re = re.compile("Are you coming\?.*\n*.*(YES|NO|MAYBE).*", re.UNICODE) @@ -419,7 +420,7 @@ request was delegated to"), if msg_actions['state'] in ['YES', 'NO', 'MAYBE']: mapping = {'YES': 'accepted', 'NO': 'declined', 'MAYBE': 'tentative'} status = mapping[msg_actions['state']] - print 'Got response for invitation id: %s as %s' % (ids, status) + print 'Got response for invitation id: %s as %s' % (ids, status) self.write(cr, uid, ids, {'state': status}) return True @@ -438,13 +439,13 @@ request was delegated to"), sign = att.sent_by_uid and att.sent_by_uid.signature or '' sign = '
'.join(sign and sign.split('\n') or []) res_obj = att.ref - sub = '[%s Invitation][%d] %s' % (company, att.id, res_obj.name) + sub = '[%s Invitation][%d] %s' % (company, att.id, res_obj.name) att_infos = [] other_invitaion_ids = self.search(cr, uid, [('ref','=', att.ref._name + ',' + str(att.ref.id))]) for att2 in self.browse(cr, uid, other_invitaion_ids): att_infos.append(((att2.user_id and att2.user_id.name) or \ (att2.partner_id and att2.partner_id.name) or \ - att2.email) + ' - Status: ' + att2.state.title()) + att2.email) + ' - Status: ' + att2.state.title()) body_vals = {'name': res_obj.name, 'start_date': res_obj.date, 'end_date': res_obj.date_deadline or False, @@ -468,7 +469,7 @@ request was delegated to"), return True def onchange_user_id(self, cr, uid, ids, user_id, *args, **argv): """ - Make entry on email and availbility on change of user_id field. + Make entry on email and availbility on change of user_id field. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of calendar attendee’s IDs. @@ -494,7 +495,7 @@ request was delegated to"), def do_accept(self, cr, uid, ids, context=None, *args): """ - Update state which value is accepted. + Update state which value is accepted. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of calendar attendee’s IDs. @@ -511,7 +512,7 @@ request was delegated to"), mod_obj = self.pool.get(vals.ref._name) if vals.ref: if vals.ref.user_id.id != user.id: - defaults = {'user_id': user.id} + defaults = {'user_id': user.id} new_event = mod_obj.copy(cr, uid, vals.ref.id, default=defaults, context=context) self.write(cr, uid, vals.id, {'state': 'accepted'}, context) @@ -538,7 +539,7 @@ request was delegated to"), context = {} if not vals.get("email") and vals.get("cn"): cnval = vals.get("cn").split(':') - email = filter(lambda x:x.__contains__('@'), cnval) + email = filter(lambda x:x.__contains__('@'), cnval) vals['email'] = email[0] vals['cn'] = vals.get("cn") res = super(calendar_attendee, self).create(cr, uid, vals, context) @@ -551,13 +552,17 @@ class res_alarm(osv.osv): _description = 'Basic Alarm Information' _columns = { 'name':fields.char('Name', size=256, required=True), - 'trigger_occurs': fields.selection([('before', 'Before'), ('after', 'After')], \ + 'trigger_occurs': fields.selection([('before', 'Before'), \ + ('after', 'After')], \ 'Triggers', required=True), - 'trigger_interval': fields.selection([('minutes', 'Minutes'), ('hours', 'Hours'), \ - ('days', 'Days')], 'Interval', required=True), - 'trigger_duration': fields.integer('Duration', required=True), - 'trigger_related': fields.selection([('start', 'The event starts'), ('end', \ - 'The event ends')], 'Related to', required=True), + 'trigger_interval': fields.selection([('minutes', 'Minutes'), \ + ('hours', 'Hours'), \ + ('days', 'Days')], 'Interval',\ + required=True), + 'trigger_duration': fields.integer('Duration', required=True), + 'trigger_related': fields.selection([('start', 'The event starts'), \ + ('end', 'The event ends')], \ + 'Related to', required=True), 'duration': fields.integer('Duration', help="""Duration' and 'Repeat' \ are both optional, but if one occurs, so MUST the other"""), 'repeat': fields.integer('Repeat'), @@ -567,7 +572,7 @@ are both optional, but if one occurs, so MUST the other"""), } _defaults = { - 'trigger_interval': lambda *x: 'minutes', + 'trigger_interval': lambda *x: 'minutes', 'trigger_duration': lambda *x: 5, 'trigger_occurs': lambda *x: 'before', 'trigger_related': lambda *x: 'start', @@ -641,7 +646,7 @@ are both optional, but if one occurs, so MUST the other"""), if alarm_ids: alarm_obj.unlink(cr, uid, alarm_ids) cr.execute('Update %s set base_calendar_alarm_id=NULL, alarm_id=NULL\ - where id=%s' % (model_obj._table, datas.id)) + where id=%s' % (model_obj._table, datas.id)) cr.commit() return True @@ -656,8 +661,8 @@ class calendar_alarm(osv.osv): _columns = { 'alarm_id': fields.many2one('res.alarm', 'Basic Alarm', ondelete='cascade'), 'name': fields.char('Summary', size=124, help="""Contains the text to be \ - used as the message subject for email \ - or contains the text to be used for display"""), + used as the message subject for email \ + or contains the text to be used for display"""), 'action': fields.selection([('audio', 'Audio'), ('display', 'Display'), \ ('procedure', 'Procedure'), ('email', 'Email') ], 'Action', \ required=True, help="Defines the action to be invoked when an alarm is triggered"), @@ -686,7 +691,7 @@ class calendar_alarm(osv.osv): } _defaults = { - 'action': lambda *x: 'email', + 'action': lambda *x: 'email', 'state': lambda *x: 'run', } @@ -709,7 +714,7 @@ class calendar_alarm(osv.osv): delta = timedelta(hours=vals['trigger_duration']) if vals['trigger_interval'] == 'minutes': delta = timedelta(minutes=vals['trigger_duration']) - trigger_date = dtstart + (vals['trigger_occurs'] == 'after' and delta or -delta) + trigger_date = dtstart + (vals['trigger_occurs'] == 'after' and delta or -delta) vals['trigger_date'] = trigger_date res = super(calendar_alarm, self).create(cr, uid, vals, context) return res @@ -745,7 +750,7 @@ class calendar_alarm(osv.osv): 'act_to': alarm.user_id.id, 'body': alarm.description, 'trigger_date': alarm.trigger_date, - 'ref_doc1': '%s,%s' % (alarm.model_id.model, alarm.res_id) + 'ref_doc1': '%s,%s' % (alarm.model_id.model, alarm.res_id) } request_id = request_obj.create(cr, uid, value) request_ids = [request_id] @@ -757,7 +762,7 @@ class calendar_alarm(osv.osv): request_obj.request_send(cr, uid, request_ids) if alarm.action == 'email': - sub = '[Openobject Remainder] %s' % (alarm.name) + sub = '[Openobject Remainder] %s' % (alarm.name) body = """ Name: %s Date: %s @@ -816,7 +821,7 @@ class calendar_event(osv.osv): if end_date and not duration: end = datetime.strptime(end_date, "%Y-%m-%d %H:%M:%S") diff = end - start - duration = float(diff.days)* 24 + (float(diff.seconds) / 3600) + duration = float(diff.days)* 24 + (float(diff.seconds) / 3600) value['duration'] = round(duration, 2) elif not end_date: end = start + timedelta(hours=duration) @@ -911,7 +916,7 @@ class calendar_event(osv.osv): Get rule string. @param self: The object pointer @param cr: the current row, from the database cursor, - @param id: List of calendar event's ids. + @param id: List of calendar event's ids. @param context: A standard dictionary for contextual values @return: dictionary of rrule value. """ @@ -953,7 +958,10 @@ class calendar_event(osv.osv): 'exrule': fields.char('Exception Rule', size=352, help="defines a \ rule or repeating pattern for anexception to a recurrence set"), 'rrule': fields.function(_get_rulestring, type='char', size=124, method=True,\ - string='Recurrent Rule', store=True, fnct_inv=_set_rrulestring), + string='Recurrent Rule', store=True, \ + fnct_inv=_set_rrulestring, help='Defines a\ + rule or repeating pattern for recurring events\n\ + e.g.: '), 'rrule_type': fields.selection([('none', ''), ('daily', 'Daily'), \ ('weekly', 'Weekly'), ('monthly', 'Monthly'), \ ('yearly', 'Yearly'), ('custom', 'Custom')], 'Recurrency'), @@ -998,9 +1006,9 @@ class calendar_event(osv.osv): _defaults = { 'class': lambda *a: 'public', 'show_as': lambda *a: 'busy', - 'freq': lambda *x: 'None', - 'select1': lambda *x: 'date', - 'interval': lambda *x: 1, + 'freq': lambda *x: 'None', + 'select1': lambda *x: 'date', + 'interval': lambda *x: 1, } def modify_this(self, cr, uid, event_id, defaults, real_date, context=None, *args): @@ -1018,11 +1026,11 @@ class calendar_event(osv.osv): event_id = base_calendar_id2real_id(event_id) datas = self.read(cr, uid, event_id, context=context) defaults.update({ - 'recurrent_uid': base_calendar_id2real_id(datas['id']), - 'recurrent_id': defaults.get('date') or real_date, - 'rrule_type': 'none', - 'rrule': '' - }) + 'recurrent_uid': base_calendar_id2real_id(datas['id']), + 'recurrent_id': defaults.get('date') or real_date, + 'rrule_type': 'none', + 'rrule': '' + }) exdate = datas['exdate'] and datas['exdate'].split(',') or [] if real_date and defaults.get('date'): exdate.append(real_date) @@ -1046,7 +1054,7 @@ class calendar_event(osv.osv): defaults.update({'table': self._table}) qry = "UPDATE %(table)s set name = '%(name)s', \ - date = '%(date)s', date_deadline = '%(date_deadline)s'" + date = '%(date)s', date_deadline = '%(date_deadline)s'" if defaults.get('alarm_id'): qry += ", alarm_id = %(alarm_id)s" if defaults.get('location'): @@ -1074,7 +1082,7 @@ class calendar_event(osv.osv): result = [] if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, m.date, m.date_deadline, \ - m.exdate from " + self._table + \ + m.exdate from " + self._table + \ " m where m.id in ("\ + ','.join(map(lambda x: str(x), ids))+")") @@ -1196,7 +1204,7 @@ class calendar_event(osv.osv): def search(self, cr, uid, args, offset=0, limit=100, order=None, context=None, count=False): """ - Overrides orm search method. + Overrides orm search method. @param cr: the current row, from the database cursor, @param user: the current user’s ID for security checks, @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. @@ -1262,7 +1270,7 @@ class calendar_event(osv.osv): def browse(self, cr, uid, ids, context=None, list_class=None, fields_process={}): """ - Overrides orm browse method. + Overrides orm browse method. @param self: the object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @@ -1283,7 +1291,7 @@ class calendar_event(osv.osv): def read(self, cr, uid, ids, fields=None, context={}, load='_classic_read'): """ - Overrides orm Read method.Read List of fields for calendar event. + Overrides orm Read method.Read List of fields for calendar event. @param cr: the current row, from the database cursor, @param user: the current user’s ID for security checks, @param ids: List of calendar event's id. @@ -1299,8 +1307,7 @@ class calendar_event(osv.osv): if fields and 'date' not in fields: fields.append('date') for base_calendar_id, real_id in select: - res = super(calendar_event, self).read(cr, uid, real_id, fields=fields, context=context, \ - load=load) + res = super(calendar_event, self).read(cr, uid, real_id, fields=fields, context=context, load=load) ls = base_calendar_id2real_id(base_calendar_id, with_date=res.get('duration', 0)) if not isinstance(ls, (str, int, long)) and len(ls) >= 2: res['date'] = ls[1] @@ -1342,7 +1349,7 @@ class calendar_event(osv.osv): for record in self.read(cr, uid, [base_calendar_id2real_id(id)], \ ['date', 'rrule', 'exdate']): if record['rrule']: - exdate = (record['exdate'] and (record['exdate'] + ',') or '') + ''.join((re.compile('\d')).findall(date_new)) + 'Z' + exdate = (record['exdate'] and (record['exdate'] + ',') or '') + ''.join((re.compile('\d')).findall(date_new)) + 'Z' if record['date'] == date_new: res = self.write(cr, uid, [base_calendar_id2real_id(id)], {'exdate': exdate}) else: @@ -1408,8 +1415,8 @@ class calendar_todo(osv.osv): """ event = self.browse(cr, uid, id, context=context) - cr.execute("UPDATE %s set date_start='%s' where id=%s" \ - % (self._table, value, id)) + cr.execute("UPDATE %s set date_start='%s' where id=%s" \ + % (self._table, value, id)) return True _columns = { @@ -1600,4 +1607,5 @@ class res_users(osv.osv): } res_users() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file From 72b0b218d78529183fe236e265f8ef2c4ae01a50 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Tue, 6 Apr 2010 14:09:14 +0530 Subject: [PATCH 05/59] [IMP]: base_calendar: Improvement in rrule help put proper example bzr revid: rpa@tinyerp.com-20100406083914-3ag7ahewk9zxipk8 --- addons/base_calendar/base_calendar.py | 339 +++++++++--------- .../wizard/calendar_event_edit_all.py | 2 +- 2 files changed, 171 insertions(+), 170 deletions(-) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 0e8b36bc3fd..c60b75a9815 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -327,60 +327,60 @@ class calendar_attendee(osv.osv): 'cutype': fields.selection([('individual', 'Individual'), \ ('group', 'Group'), ('resource', 'Resource'), \ ('room', 'Room'), ('unknown', '') ], \ - 'Invite Type', help="Specify the type of Invitation"), - 'member': fields.char('Member', size=124, - help="Indicate the groups that the attendee belongs to"), + 'Invite Type', help="Specify the type of Invitation"), + 'member': fields.char('Member', size=124, + help="Indicate the groups that the attendee belongs to"), 'role': fields.selection([('req-participant', 'Participation required'), \ ('chair', 'Chair Person'), \ ('opt-participant', 'Optional Participation'), \ ('non-participant', 'For information Purpose')], 'Role', \ - help='Participation role for the calendar user'), - 'state': fields.selection([('tentative', 'Tentative'), - ('needs-action', 'Needs Action'), - ('accepted', 'Accepted'), - ('declined', 'Declined'), - ('delegated', 'Delegated')], 'State', readonly=True,\ - help="Status of the attendee's participation"), - 'rsvp': fields.boolean('Required Reply?', - help="Indicats whether the favor of a reply is requested"), + help='Participation role for the calendar user'), + 'state': fields.selection([('tentative', 'Tentative'), + ('needs-action', 'Needs Action'), + ('accepted', 'Accepted'), + ('declined', 'Declined'), + ('delegated', 'Delegated')], 'State', readonly=True, \ + help="Status of the attendee's participation"), + 'rsvp': fields.boolean('Required Reply?', + help="Indicats whether the favor of a reply is requested"), 'delegated_to': fields.function(_compute_data, method=True, \ string='Delegated To', type="char", size=124, store=True, \ multi='delegated_to', help="The users that the original \ -request was delegated to"), +request was delegated to"), 'delegated_from': fields.function(_compute_data, method=True, string=\ - 'Delegated From', type="char", store=True, size=124, multi='delegated_from'), - 'parent_ids': fields.many2many('calendar.attendee', 'calendar_attendee_parent_rel',\ - 'attendee_id', 'parent_id', 'Delegrated From'), - 'child_ids': fields.many2many('calendar.attendee', 'calendar_attendee_child_rel',\ - 'attendee_id', 'child_id', 'Delegrated To'), - 'sent_by': fields.function(_compute_data, method=True, string='Sent By',\ - type="char", multi='sent_by', store=True, size=124,\ - help="Specify the user that is acting on behalf of the calendar user"), - 'sent_by_uid': fields.function(_compute_data, method=True, string='Sent By User',\ - type="many2one", relation="res.users", multi='sent_by_uid'), - 'cn': fields.function(_compute_data, method=True, string='Common name',\ - type="char", size=124, multi='cn', store=True), + 'Delegated From', type="char", store=True, size=124, multi='delegated_from'), + 'parent_ids': fields.many2many('calendar.attendee', 'calendar_attendee_parent_rel', \ + 'attendee_id', 'parent_id', 'Delegrated From'), + 'child_ids': fields.many2many('calendar.attendee', 'calendar_attendee_child_rel', \ + 'attendee_id', 'child_id', 'Delegrated To'), + 'sent_by': fields.function(_compute_data, method=True, string='Sent By', \ + type="char", multi='sent_by', store=True, size=124, \ + help="Specify the user that is acting on behalf of the calendar user"), + 'sent_by_uid': fields.function(_compute_data, method=True, string='Sent By User', \ + type="many2one", relation="res.users", multi='sent_by_uid'), + 'cn': fields.function(_compute_data, method=True, string='Common name', \ + type="char", size=124, multi='cn', store=True), 'dir': fields.char('URI Reference', size=124, help="Reference to the URI\ -that points to the directory information corresponding to the attendee."), - 'language': fields.function(_compute_data, method=True, string='Language',\ - type="selection", selection=_lang_get, multi='language',\ +that points to the directory information corresponding to the attendee."), + 'language': fields.function(_compute_data, method=True, string='Language', \ + type="selection", selection=_lang_get, multi='language', \ store=True, help="To specify the language for text values in a\ -property or property parameter."), - 'user_id': fields.many2one('res.users', 'User'), - 'partner_address_id': fields.many2one('res.partner.address', 'Contact'), - 'partner_id': fields.related('partner_address_id', 'partner_id', type='many2one',\ - relation='res.partner', string='Partner', help="Partner related to contact"), - 'email': fields.char('Email', size=124, help="Email of Invited Person"), - 'event_date': fields.function(_compute_data, method=True, string='Event Date',\ - type="datetime", multi='event_date'), +property or property parameter."), + 'user_id': fields.many2one('res.users', 'User'), + 'partner_address_id': fields.many2one('res.partner.address', 'Contact'), + 'partner_id': fields.related('partner_address_id', 'partner_id', type='many2one', \ + relation='res.partner', string='Partner', help="Partner related to contact"), + 'email': fields.char('Email', size=124, help="Email of Invited Person"), + 'event_date': fields.function(_compute_data, method=True, string='Event Date', \ + type="datetime", multi='event_date'), 'event_end_date': fields.function(_compute_data, method=True, \ string='Event End Date', type="datetime", \ - multi='event_end_date'), - 'ref': fields.reference('Event Ref', selection=_links_get, size=128), - 'availability': fields.selection([('free', 'Free'), ('busy', 'Busy')], 'Free/Busy', readonly="True"), + multi='event_end_date'), + 'ref': fields.reference('Event Ref', selection=_links_get, size=128), + 'availability': fields.selection([('free', 'Free'), ('busy', 'Busy')], 'Free/Busy', readonly="True"), } _defaults = { - 'state': lambda *x: 'needs-action', + 'state': lambda *x: 'needs-action', } response_re = re.compile("Are you coming\?.*\n*.*(YES|NO|MAYBE).*", re.UNICODE) @@ -441,29 +441,29 @@ property or property parameter."), res_obj = att.ref sub = '[%s Invitation][%d] %s' % (company, att.id, res_obj.name) att_infos = [] - other_invitaion_ids = self.search(cr, uid, [('ref','=', att.ref._name + ',' + str(att.ref.id))]) + other_invitaion_ids = self.search(cr, uid, [('ref', '=', att.ref._name + ',' + str(att.ref.id))]) for att2 in self.browse(cr, uid, other_invitaion_ids): att_infos.append(((att2.user_id and att2.user_id.name) or \ (att2.partner_id and att2.partner_id.name) or \ att2.email) + ' - Status: ' + att2.state.title()) - body_vals = {'name': res_obj.name, - 'start_date': res_obj.date, - 'end_date': res_obj.date_deadline or False, - 'description': res_obj.description or '-', - 'location': res_obj.location or '-', - 'attendees': '
'.join(att_infos), - 'user': res_obj.user_id and res_obj.user_id.name or 'OpenERP User', - 'sign': sign, + body_vals = {'name': res_obj.name, + 'start_date': res_obj.date, + 'end_date': res_obj.date_deadline or False, + 'description': res_obj.description or '-', + 'location': res_obj.location or '-', + 'attendees': '
'.join(att_infos), + 'user': res_obj.user_id and res_obj.user_id.name or 'OpenERP User', + 'sign': sign, 'company': company } body = html_invitation % body_vals if mail_to and email_from: tools.email_send( - email_from, - mail_to, - sub, - body, - subtype='html', + email_from, + mail_to, + sub, + body, + subtype='html', reply_to=email_from ) return True @@ -551,32 +551,32 @@ class res_alarm(osv.osv): _name = 'res.alarm' _description = 'Basic Alarm Information' _columns = { - 'name':fields.char('Name', size=256, required=True), + 'name':fields.char('Name', size=256, required=True), 'trigger_occurs': fields.selection([('before', 'Before'), \ ('after', 'After')], \ - 'Triggers', required=True), + 'Triggers', required=True), 'trigger_interval': fields.selection([('minutes', 'Minutes'), \ ('hours', 'Hours'), \ - ('days', 'Days')], 'Interval',\ - required=True), - 'trigger_duration': fields.integer('Duration', required=True), + ('days', 'Days')], 'Interval', \ + required=True), + 'trigger_duration': fields.integer('Duration', required=True), 'trigger_related': fields.selection([('start', 'The event starts'), \ ('end', 'The event ends')], \ - 'Related to', required=True), + 'Related to', required=True), 'duration': fields.integer('Duration', help="""Duration' and 'Repeat' \ -are both optional, but if one occurs, so MUST the other"""), - 'repeat': fields.integer('Repeat'), +are both optional, but if one occurs, so MUST the other"""), + 'repeat': fields.integer('Repeat'), 'active': fields.boolean('Active', help="If the active field is set to \ - true, it will allow you to hide the event alarm information without removing it."), + true, it will allow you to hide the event alarm information without removing it."), } _defaults = { - 'trigger_interval': lambda *x: 'minutes', - 'trigger_duration': lambda *x: 5, - 'trigger_occurs': lambda *x: 'before', - 'trigger_related': lambda *x: 'start', - 'active': lambda *x: 1, + 'trigger_interval': lambda *x: 'minutes', + 'trigger_duration': lambda *x: 5, + 'trigger_occurs': lambda *x: 'before', + 'trigger_related': lambda *x: 'start', + 'active': lambda *x: 1, } def do_alarm_create(self, cr, uid, ids, model, date, context={}): @@ -604,20 +604,20 @@ are both optional, but if one occurs, so MUST the other"""), self.do_alarm_unlink(cr, uid, [data.id], model) if basic_alarm: vals = { - 'action': 'display', - 'description': data.description, - 'name': data.name, - 'attendee_ids': [(6, 0, map(lambda x:x.id, data.attendee_ids))], - '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, - 'state': 'run', - 'event_date': data[date], - 'res_id': data.id, - 'model_id': model_id, + 'action': 'display', + 'description': data.description, + 'name': data.name, + 'attendee_ids': [(6, 0, map(lambda x:x.id, data.attendee_ids))], + '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, + 'state': 'run', + 'event_date': data[date], + 'res_id': data.id, + 'model_id': model_id, 'user_id': uid } alarm_id = alarm_obj.create(cr, uid, vals) @@ -659,40 +659,40 @@ class calendar_alarm(osv.osv): __attribute__ = {} _columns = { - 'alarm_id': fields.many2one('res.alarm', 'Basic Alarm', ondelete='cascade'), + 'alarm_id': fields.many2one('res.alarm', 'Basic Alarm', ondelete='cascade'), 'name': fields.char('Summary', size=124, help="""Contains the text to be \ used as the message subject for email \ - or contains the text to be used for display"""), + or contains the text to be used for display"""), 'action': fields.selection([('audio', 'Audio'), ('display', 'Display'), \ ('procedure', 'Procedure'), ('email', 'Email') ], 'Action', \ - required=True, help="Defines the action to be invoked when an alarm is triggered"), + required=True, help="Defines the action to be invoked when an alarm is triggered"), 'description': fields.text('Description', help='Provides a more complete \ description of the calendar component, than that \ - provided by the "SUMMARY" property'), + provided by the "SUMMARY" property'), 'attendee_ids': fields.many2many('calendar.attendee', 'alarm_attendee_rel', \ - 'alarm_id', 'attendee_id', 'Attendees', readonly=True), + 'alarm_id', 'attendee_id', 'Attendees', readonly=True), 'attach': fields.binary('Attachment', help="""* Points to a sound resource,\ which is rendered when the alarm is triggered for audio, * File which is intended to be sent as message attachments for email, * Points to a procedure resource, which is invoked when\ - the alarm is triggered for procedure."""), - 'res_id': fields.integer('Resource ID'), - 'model_id': fields.many2one('ir.model', 'Model'), - 'user_id': fields.many2one('res.users', 'Owner'), - 'event_date': fields.datetime('Event Date'), - 'event_end_date': fields.datetime('Event End Date'), - 'trigger_date': fields.datetime('Trigger Date', readonly="True"), + the alarm is triggered for procedure."""), + 'res_id': fields.integer('Resource ID'), + 'model_id': fields.many2one('ir.model', 'Model'), + 'user_id': fields.many2one('res.users', 'Owner'), + 'event_date': fields.datetime('Event Date'), + 'event_end_date': fields.datetime('Event End Date'), + 'trigger_date': fields.datetime('Trigger Date', readonly="True"), 'state':fields.selection([ - ('draft', 'Draft'), - ('run', 'Run'), - ('stop', 'Stop'), - ('done', 'Done'), - ], 'State', select=True, readonly=True), + ('draft', 'Draft'), + ('run', 'Run'), + ('stop', 'Stop'), + ('done', 'Done'), + ], 'State', select=True, readonly=True), } _defaults = { - 'action': lambda *x: 'email', - 'state': lambda *x: 'run', + 'action': lambda *x: 'email', + 'state': lambda *x: 'run', } def create(self, cr, uid, vals, context={}): @@ -745,11 +745,11 @@ class calendar_alarm(osv.osv): for alarm in self.browse(cr, uid, alarm_ids): if alarm.action == 'display': value = { - 'name': alarm.name, - 'act_from': alarm.user_id.id, - 'act_to': alarm.user_id.id, - 'body': alarm.description, - 'trigger_date': alarm.trigger_date, + 'name': alarm.name, + 'act_from': alarm.user_id.id, + 'act_to': alarm.user_id.id, + 'body': alarm.description, + 'trigger_date': alarm.trigger_date, 'ref_doc1': '%s,%s' % (alarm.model_id.model, alarm.res_id) } request_id = request_obj.create(cr, uid, value) @@ -779,9 +779,9 @@ class calendar_alarm(osv.osv): mail_to.append(att.user_id.address_id.email) if mail_to: tools.email_send( - tools.config.get('email_from', False), - mail_to, - sub, + tools.config.get('email_from', False), + mail_to, + sub, body ) self.write(cr, uid, [alarm.id], {'state':'done'}) @@ -885,8 +885,8 @@ class calendar_event(osv.osv): if val.get('byday'): d = val.get('byday') if '-' in d: - new_val['byday'] = d[:2] - new_val['week_list'] = d[2:4].upper() + new_val['byday'] = d[:2] + new_val['week_list'] = d[2:4].upper() else: new_val['byday'] = d[:1] new_val['week_list'] = d[1:3].upper() @@ -938,40 +938,41 @@ class calendar_event(osv.osv): return result _columns = { - 'id': fields.integer('ID'), - 'sequence': fields.integer('Sequence'), - 'name': fields.char('Description', size=64, required=True), - 'date': fields.datetime('Date'), - 'date_deadline': fields.datetime('Deadline'), - 'create_date': fields.datetime('Created', readonly=True), - 'duration': fields.float('Duration'), - 'description': fields.text('Your action'), + 'id': fields.integer('ID'), + 'sequence': fields.integer('Sequence'), + 'name': fields.char('Description', size=64, required=True), + 'date': fields.datetime('Date'), + 'date_deadline': fields.datetime('Deadline'), + 'create_date': fields.datetime('Created', readonly=True), + 'duration': fields.float('Duration'), + 'description': fields.text('Your action'), 'class': fields.selection([('public', 'Public'), ('private', 'Private'), \ - ('confidential', 'Confidential')], 'Mark as'), - 'location': fields.char('Location', size=264, help="Location of Event"), + ('confidential', 'Confidential')], 'Mark as'), + 'location': fields.char('Location', size=264, help="Location of Event"), 'show_as': fields.selection([('free', 'Free'), \ - ('busy', 'Busy')], - 'Show as'), - 'base_calendar_url': fields.char('Caldav URL', size=264), + ('busy', 'Busy')], + 'Show as'), + 'base_calendar_url': fields.char('Caldav URL', size=264), 'exdate': fields.text('Exception Date/Times', help="This property \ - defines the list of date/time exceptions for arecurring calendar component."), + defines the list of date/time exceptions for arecurring calendar component."), 'exrule': fields.char('Exception Rule', size=352, help="defines a \ - rule or repeating pattern for anexception to a recurrence set"), - 'rrule': fields.function(_get_rulestring, type='char', size=124, method=True,\ + rule or repeating pattern for anexception to a recurrence set"), + 'rrule': fields.function(_get_rulestring, type='char', size=124, method=True, \ string='Recurrent Rule', store=True, \ fnct_inv=_set_rrulestring, help='Defines a\ rule or repeating pattern for recurring events\n\ - e.g.: '), +e.g.: Every other month on the last Sunday of the month for 10 occurrences:\ + FREQ=MONTHLY;INTERVAL=2;COUNT=10;BYDAY=-1SU'), 'rrule_type': fields.selection([('none', ''), ('daily', 'Daily'), \ ('weekly', 'Weekly'), ('monthly', 'Monthly'), \ - ('yearly', 'Yearly'), ('custom', 'Custom')], 'Recurrency'), - 'alarm_id': fields.many2one('res.alarm', 'Alarm'), - 'base_calendar_alarm_id': fields.many2one('calendar.alarm', 'Alarm'), - 'recurrent_uid': fields.integer('Recurrent ID'), - 'recurrent_id': fields.datetime('Recurrent ID date'), - 'vtimezone': fields.related('user_id', 'context_tz', type='char', size=24,\ - string='Timezone', store=True), - 'user_id': fields.many2one('res.users', 'Responsible'), + ('yearly', 'Yearly'), ('custom', 'Custom')], 'Recurrency'), + 'alarm_id': fields.many2one('res.alarm', 'Alarm'), + 'base_calendar_alarm_id': fields.many2one('calendar.alarm', 'Alarm'), + 'recurrent_uid': fields.integer('Recurrent ID'), + 'recurrent_id': fields.datetime('Recurrent ID date'), + 'vtimezone': fields.related('user_id', 'context_tz', type='char', size=24, \ + string='Timezone', store=True), + 'user_id': fields.many2one('res.users', 'Responsible'), 'freq': fields.selection([('None', 'No Repeat'), \ ('secondly', 'Secondly'), \ ('minutely', 'Minutely'), \ @@ -979,36 +980,36 @@ class calendar_event(osv.osv): ('daily', 'Daily'), \ ('weekly', 'Weekly'), \ ('monthly', 'Monthly'), \ - ('yearly', 'Yearly')], 'Frequency'), - 'interval': fields.integer('Interval'), - 'count': fields.integer('Count'), - 'mo': fields.boolean('Mon'), - 'tu': fields.boolean('Tue'), - 'we': fields.boolean('Wed'), - 'th': fields.boolean('Thu'), - 'fr': fields.boolean('Fri'), - 'sa': fields.boolean('Sat'), - 'su': fields.boolean('Sun'), + ('yearly', 'Yearly')], 'Frequency'), + 'interval': fields.integer('Interval'), + 'count': fields.integer('Count'), + 'mo': fields.boolean('Mon'), + 'tu': fields.boolean('Tue'), + 'we': fields.boolean('Wed'), + 'th': fields.boolean('Thu'), + 'fr': fields.boolean('Fri'), + 'sa': fields.boolean('Sat'), + 'su': fields.boolean('Sun'), 'select1': fields.selection([('date', 'Date of month'), \ - ('day', 'Day of month')], 'Option'), - 'day': fields.integer('Date of month'), + ('day', 'Day of month')], 'Option'), + 'day': fields.integer('Date of month'), 'week_list': fields.selection([('MO', 'Monday'), ('TU', 'Tuesday'), \ ('WE', 'Wednesday'), ('TH', 'Thursday'), \ ('FR', 'Friday'), ('SA', 'Saturday'), \ - ('SU', 'Sunday')], 'Weekday'), + ('SU', 'Sunday')], 'Weekday'), 'byday': fields.selection([('1', 'First'), ('2', 'Second'), \ ('3', 'Third'), ('4', 'Fourth'), \ - ('5', 'Fifth'), ('-1', 'Last')], 'By day'), - 'month_list': fields.selection(months.items(), 'Month'), + ('5', 'Fifth'), ('-1', 'Last')], 'By day'), + 'month_list': fields.selection(months.items(), 'Month'), 'end_date': fields.date('Repeat Until') } _defaults = { - 'class': lambda *a: 'public', - 'show_as': lambda *a: 'busy', - 'freq': lambda *x: 'None', - 'select1': lambda *x: 'date', - 'interval': lambda *x: 1, + 'class': lambda *a: 'public', + 'show_as': lambda *a: 'busy', + 'freq': lambda *x: 'None', + 'select1': lambda *x: 'date', + 'interval': lambda *x: 1, } def modify_this(self, cr, uid, event_id, defaults, real_date, context=None, *args): @@ -1026,9 +1027,9 @@ class calendar_event(osv.osv): event_id = base_calendar_id2real_id(event_id) datas = self.read(cr, uid, event_id, context=context) defaults.update({ - 'recurrent_uid': base_calendar_id2real_id(datas['id']), - 'recurrent_id': defaults.get('date') or real_date, - 'rrule_type': 'none', + 'recurrent_uid': base_calendar_id2real_id(datas['id']), + 'recurrent_id': defaults.get('date') or real_date, + 'rrule_type': 'none', 'rrule': '' }) exdate = datas['exdate'] and datas['exdate'].split(',') or [] @@ -1201,7 +1202,7 @@ class calendar_event(osv.osv): return rrule_string - def search(self, cr, uid, args, offset=0, limit=100, order=None, + def search(self, cr, uid, args, offset=0, limit=100, order=None, context=None, count=False): """ Overrides orm search method. @@ -1421,8 +1422,8 @@ class calendar_todo(osv.osv): _columns = { 'date': fields.function(_get_date, method=True, fnct_inv=_set_date, \ - string='Duration', store=True, type='datetime'), - 'duration': fields.integer('Duration'), + string='Duration', store=True, type='datetime'), + 'duration': fields.integer('Duration'), } __attribute__ = {} @@ -1447,7 +1448,7 @@ class ir_attachment(osv.osv): args1.append(map(lambda x:str(x).split('-')[0], arg)) return super(ir_attachment, self).search_count(cr, user, args1, context) - def search(self, cr, uid, args, offset=0, limit=None, order=None, + def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): """ @param self: The object pointer @@ -1463,8 +1464,8 @@ class ir_attachment(osv.osv): for i, arg in enumerate(new_args): if arg[0] == 'res_id': new_args[i] = (arg[0], arg[1], base_calendar_id2real_id(arg[2])) - return super(ir_attachment, self).search(cr, uid, new_args, offset=offset, - limit=limit, order=order, + return super(ir_attachment, self).search(cr, uid, new_args, offset=offset, + limit=limit, order=order, context=context, count=False) ir_attachment() @@ -1513,7 +1514,7 @@ class ir_model(osv.osv): _inherit = 'ir.model' - def read(self, cr, uid, ids, fields=None, context={}, + def read(self, cr, uid, ids, fields=None, context={}, load='_classic_read'): """ Read IR Model @@ -1572,7 +1573,7 @@ class res_users(osv.osv): res = {} attendee_obj = self.pool.get('calendar.attendee') attendee_ids = attendee_obj.search(cr, uid, [ - ('event_date', '<=', current_datetime), ('event_end_date', '<=', current_datetime), + ('event_date', '<=', current_datetime), ('event_end_date', '<=', current_datetime), ('state', '=', 'accepted'), ('user_id', 'in', ids) ]) @@ -1603,9 +1604,9 @@ class res_users(osv.osv): _columns = { 'availability': fields.function(_get_user_avail_fun, type='selection', \ selection=[('free', 'Free'), ('busy', 'Busy')], \ - string='Free/Busy', method=True), + string='Free/Busy', method=True), } res_users() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_calendar/wizard/calendar_event_edit_all.py b/addons/base_calendar/wizard/calendar_event_edit_all.py index d99e864a148..d17195f9a27 100755 --- a/addons/base_calendar/wizard/calendar_event_edit_all.py +++ b/addons/base_calendar/wizard/calendar_event_edit_all.py @@ -35,7 +35,7 @@ class calendar_event_edit_all(osv.osv_memory): context_id = context and context.get('active_id', False) or False if context_id: if context.get('date'): - return context.get('date') + return context.get('date') else: model = context.get('model', False) model_obj = self.pool.get(model) From 0d2009aa866a94b56bc9c3bbff848f2e0551230c Mon Sep 17 00:00:00 2001 From: "Ysa (Open ERP)" Date: Tue, 6 Apr 2010 14:37:49 +0530 Subject: [PATCH 06/59] [IMP] document :- improve storage media view. bzr revid: ysa@tinyerp.co.in-20100406090749-i8i0h7eg18gtcj3i --- addons/document/document_view.xml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/addons/document/document_view.xml b/addons/document/document_view.xml index cdbdf161891..252b9b36a26 100644 --- a/addons/document/document_view.xml +++ b/addons/document/document_view.xml @@ -13,12 +13,16 @@ form
- - - - - - + + + + + + + + + + From cadaff60b3e9fd0fc86ed77d0b060bca8d947ae5 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Tue, 6 Apr 2010 15:16:03 +0530 Subject: [PATCH 07/59] [IMP]: crm: Apply changes in crm bzr revid: ksa@tinyerp.co.in-20100406094603-3up90zudqg7nhze3 --- addons/crm/crm.py | 2 +- addons/crm/crm_lead.py | 12 +++--------- addons/crm/crm_opportunity.py | 12 +++--------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 3cebf30f3c3..3c51cc87d39 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -747,7 +747,7 @@ class crm_case(osv.osv): data = {'state': 'open', 'active': True} if not case.user_id: data['user_id'] = uid - self.write(cr, uid, ids, data) + self.write(cr, uid, ids, {'state': 'open', 'active': True}) self._action(cr, uid, cases, 'open') return True diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 8863791a28c..31a0c4b9f0c 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -44,15 +44,9 @@ class crm_lead(osv.osv): @param *args: Give Tuple Value """ - cases = self.browse(cr, uid, ids) - for case in cases: - data = {'state': 'open', 'active': True} - if not case.user_id: - data['user_id'] = uid - data.update({'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}) - self.write(cr, uid, ids, data) - self._action(cr, uid, cases, 'open') - return True + res = super(crm_lead, self).case_open(cr, uid, ids, *args) + self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}) + return res def _compute_day(self, cr, uid, ids, fields, args, context={}): """ diff --git a/addons/crm/crm_opportunity.py b/addons/crm/crm_opportunity.py index a13eade4427..58d490346f8 100644 --- a/addons/crm/crm_opportunity.py +++ b/addons/crm/crm_opportunity.py @@ -50,15 +50,9 @@ class crm_opportunity(osv.osv): @param *args: Give Tuple Value """ - cases = self.browse(cr, uid, ids) - for case in cases: - data = {'state': 'open', 'active': True} - if not case.user_id: - data['user_id'] = uid - data.update({'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}) - self.write(cr, uid, ids, data) - self._action(cr, uid, cases, 'open') - return True + res = super(crm_opportunity, self).case_open(cr, uid, ids, *args) + self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}) + return res def _compute_day(self, cr, uid, ids, fields, args, context={}): """ From 19badf7f1659313eebd21e4beea3d383ca07504d Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Tue, 6 Apr 2010 15:22:42 +0530 Subject: [PATCH 08/59] [IMP]: project_issue: Apply changes in project_issue bzr revid: ksa@tinyerp.co.in-20100406095242-ud8uggkehzajys1d --- addons/project_issue/project_issue.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index f566e357dfd..b9a80d400a3 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -23,7 +23,6 @@ import base64 import os import re import time -import time import tools from crm import crm from datetime import datetime, timedelta @@ -46,15 +45,9 @@ class project_issue(osv.osv): @param *args: Give Tuple Value """ - cases = self.browse(cr, uid, ids) - for case in cases: - data = {'state': 'open', 'active': True} - if not case.user_id: - data['user_id'] = uid - data.update({'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}) - self.write(cr, uid, ids, data) - self._action(cr, uid, cases, 'open') - return True + res = super(project_issue, self).case_open(cr, uid, ids, *args) + self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}) + return res def _compute_day(self, cr, uid, ids, fields, args, context={}): """ From 74650c60cd107a29f66bd661066139fc1d18a7ce Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Tue, 6 Apr 2010 15:50:15 +0530 Subject: [PATCH 09/59] [IMP]: crm: Improvement in crm.py removed unused functions, Improvement in docstring: put proper description and params + code improvement bzr revid: rpa@tinyerp.com-20100406102015-yle99yjrshjg7j20 --- addons/crm/crm.py | 504 ++++++++++++++++++++-------------------------- 1 file changed, 218 insertions(+), 286 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 3c51cc87d39..23e04e19609 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -30,18 +30,18 @@ from tools.translate import _ MAX_LEVEL = 15 AVAILABLE_STATES = [ - ('draft', 'Draft'), - ('open', 'Open'), - ('cancel', 'Cancelled'), - ('done', 'Closed'), + ('draft', 'Draft'), + ('open', 'Open'), + ('cancel', 'Cancelled'), + ('done', 'Closed'), ('pending', 'Pending') ] AVAILABLE_PRIORITIES = [ - ('5', 'Lowest'), - ('4', 'Low'), - ('3', 'Normal'), - ('2', 'High'), + ('5', 'Lowest'), + ('4', 'Low'), + ('3', 'Normal'), + ('2', 'High'), ('1', 'Highest') ] @@ -53,22 +53,22 @@ class crm_case_section(osv.osv): _order = "name" _columns = { - 'name': fields.char('Sales Team', size=64, required=True, translate=True), - 'code': fields.char('Code', size=8), + 'name': fields.char('Sales Team', size=64, required=True, translate=True), + 'code': fields.char('Code', size=8), 'active': fields.boolean('Active', help="If the active field is set to \ - true, it will allow you to hide the sales team without removing it."), - 'allow_unlink': fields.boolean('Allow Delete', help="Allows to delete non draft cases"), - 'user_id': fields.many2one('res.users', 'Responsible User'), + true, it will allow you to hide the sales team without removing it."), + 'allow_unlink': fields.boolean('Allow Delete', help="Allows to delete non draft cases"), + 'user_id': fields.many2one('res.users', 'Responsible User'), 'reply_to': fields.char('Reply-To', size=64, help="The email address put \ - in the 'Reply-To' of all emails sent by Open ERP about cases in this sales team"), - 'parent_id': fields.many2one('crm.case.section', 'Parent Section'), - 'child_ids': fields.one2many('crm.case.section', 'parent_id', 'Child Sections'), - 'resource_calendar_id': fields.many2one('resource.calendar', "Resource's Calendar"), + in the 'Reply-To' of all emails sent by Open ERP about cases in this sales team"), + 'parent_id': fields.many2one('crm.case.section', 'Parent Section'), + 'child_ids': fields.one2many('crm.case.section', 'parent_id', 'Child Sections'), + 'resource_calendar_id': fields.many2one('resource.calendar', "Resource's Calendar"), } _defaults = { - 'active': lambda *a: 1, - 'allow_unlink': lambda *a: 1, + 'active': lambda *a: 1, + 'allow_unlink': lambda *a: 1, } _sql_constraints = [ @@ -98,18 +98,20 @@ class crm_case_section(osv.osv): (_check_recursion, 'Error ! You cannot create recursive sections.', ['parent_id']) ] - def name_get(self, cr, uid, ids, context={}): + def name_get(self, cr, uid, ids, context=None): """Overrides orm name_get method @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of section ids """ + if not context: + context = {} - if not len(ids): - return [] - reads = self.read(cr, uid, ids, ['name', 'parent_id'], context) res = [] + if not ids: + return res + reads = self.read(cr, uid, ids, ['name', 'parent_id'], context) for record in reads: name = record['name'] @@ -117,6 +119,7 @@ class crm_case_section(osv.osv): name = record['parent_id'][1] + ' / ' + name res.append((record['id'], name)) return res + crm_case_section() @@ -127,14 +130,14 @@ class crm_case_categ(osv.osv): _description = "Category of case" _columns = { - 'name': fields.char('Case Category Name', size=64, required=True, translate=True), - 'section_id': fields.many2one('crm.case.section', 'Sales Team'), - 'object_id': fields.many2one('ir.model', 'Object Name'), + 'name': fields.char('Case Category Name', size=64, required=True, translate=True), + 'section_id': fields.many2one('crm.case.section', 'Sales Team'), + 'object_id': fields.many2one('ir.model', 'Object Name'), } def _find_object_id(self, cr, uid, context=None): - """ + """Finds id for case object @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @@ -148,7 +151,7 @@ class crm_case_categ(osv.osv): _defaults = { 'object_id' : _find_object_id } -# + crm_case_categ() @@ -160,20 +163,18 @@ class crm_case_resource_type(osv.osv): _rec_name = "name" _columns = { - 'name': fields.char('Case Resource Type', size=64, required=True, translate=True), - 'section_id': fields.many2one('crm.case.section', 'Sales Team'), - 'object_id': fields.many2one('ir.model', 'Object Name'), + 'name': fields.char('Case Resource Type', size=64, required=True, translate=True), + 'section_id': fields.many2one('crm.case.section', 'Sales Team'), + 'object_id': fields.many2one('ir.model', 'Object Name'), } def _find_object_id(self, cr, uid, context=None): - """ + """Finds id for case object @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """ - - object_id = context and context.get('object_id', False) or False ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', object_id)]) return ids and ids[0] @@ -194,47 +195,45 @@ class crm_case_stage(osv.osv): _order = "sequence" _columns = { - 'name': fields.char('Stage Name', size=64, required=True, translate=True), - 'section_id': fields.many2one('crm.case.section', 'Sales Team'), + 'name': fields.char('Stage Name', size=64, required=True, translate=True), + 'section_id': fields.many2one('crm.case.section', 'Sales Team'), 'sequence': fields.integer('Sequence', help="Gives the sequence order \ - when displaying a list of case stages."), - 'object_id': fields.many2one('ir.model', 'Object Name'), - 'probability': fields.float('Probability (%)', required=True), - 'on_change': fields.boolean('Change Probability Automatically',\ - help="Change Probability on next and previous stages."), + when displaying a list of case stages."), + 'object_id': fields.many2one('ir.model', 'Object Name'), + 'probability': fields.float('Probability (%)', required=True), + 'on_change': fields.boolean('Change Probability Automatically', \ + help="Change Probability on next and previous stages."), 'requirements': fields.text('Requirements') } def _find_object_id(self, cr, uid, context=None): - - """ + """Finds id for case object @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """ - object_id = context and context.get('object_id', False) or False ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', object_id)]) return ids and ids[0] _defaults = { - 'sequence': lambda *args: 1, - 'probability': lambda *args: 0.0, + 'sequence': lambda *args: 1, + 'probability': lambda *args: 0.0, 'object_id' : _find_object_id } crm_case_stage() -def _links_get(self, cr, uid, context={}): +def _links_get(self, cr, uid, context=None): + """Gets links value for reference field + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param context: A standard dictionary for contextual values """ - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param context: A standard dictionary for contextual values - """ - - + if not context: + context = {} obj = self.pool.get('res.request.link') ids = obj.search(cr, uid, []) res = obj.read(cr, uid, ids, ['object', 'name'], context) @@ -247,16 +246,13 @@ class crm_case(osv.osv): _description = "Case" def _email_last(self, cursor, user, ids, name, arg, context=None): - - """Return History + """Return last email from History @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case’s IDs @param context: A standard dictionary for contextual values """ - - res = {} for case in self.browse(cursor, user, ids): if case.history_line: @@ -265,30 +261,31 @@ class crm_case(osv.osv): res[case.id] = False return res - def copy(self, cr, uid, id, default=None, context={}): - - """ + def copy(self, cr, uid, id, default=None, context=None): + """Overrides orm copy method @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case’s IDs @param context: A standard dictionary for contextual values """ - + if not context: + context = {} if not default: default = {} default.update({'state': 'draft', 'id': False}) return super(crm_case, self).copy(cr, uid, id, default, context) - def _get_log_ids(self, cr, uid, ids, field_names, arg, context={}): - - """ + def _get_log_ids(self, cr, uid, ids, field_names, arg, context=None): + """Gets id for case log from history of particular case @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param ids: List of case log’s IDs + @param ids: List of Case IDs @param context: A standard dictionary for contextual values """ + if not context: + context = {} result = {} history_obj = False @@ -307,7 +304,7 @@ class crm_case(osv.osv): for case in self.browse(cr, uid, ids, context): model_ids = model_obj.search(cr, uid, [('model', '=', case._name)]) - history_ids = history_obj.search(cr, uid, [('model_id', '=', model_ids[0]),\ + history_ids = history_obj.search(cr, uid, [('model_id', '=', model_ids[0]), \ ('res_id', '=', case.id)]) if history_ids: result[case.id] = {name: history_ids} @@ -317,65 +314,61 @@ class crm_case(osv.osv): return result _columns = { - 'id': fields.integer('ID', readonly=True), - 'name': fields.char('Description', size=1024, required=True), + 'id': fields.integer('ID', readonly=True), + 'name': fields.char('Description', size=1024, required=True), 'active': fields.boolean('Active', help="If the active field is set to\ - true, it will allow you to hide the case without removing it."), - 'description': fields.text('Description'), - 'section_id': fields.many2one('crm.case.section', 'Sales Team',\ + true, it will allow you to hide the case without removing it."), + 'description': fields.text('Description'), + 'section_id': fields.many2one('crm.case.section', 'Sales Team', \ select=True, help='Sales team to which Case belongs to.\ - Define Responsible user and Email account for mail gateway.'), - 'email_from': fields.char('Email', size=128, help="These people will receive email."), + Define Responsible user and Email account for mail gateway.'), + 'email_from': fields.char('Email', size=128, help="These people will receive email."), 'email_cc': fields.text('Watchers Emails', size=252 , help="These people\ will receive a copy of the future" \ - " communication between partner and users by email"), - 'probability': fields.float('Probability'), - 'email_last': fields.function(_email_last, method=True, - string='Latest E-Mail', type='text'), - 'partner_id': fields.many2one('res.partner', 'Partner'), - 'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact',\ - domain="[('partner_id','=',partner_id)]"), - 'create_date': fields.datetime('Creation Date' , readonly=True), - 'write_date': fields.datetime('Update Date' , readonly=True), - 'date_deadline': fields.date('Deadline'), - 'user_id': fields.many2one('res.users', 'Responsible'), - 'history_line': fields.function(_get_log_ids, method=True, type='one2many',\ - multi="history_line", relation="crm.case.history", string="Communication"), - 'log_ids': fields.function(_get_log_ids, method=True, type='one2many',\ - multi="log_ids", relation="crm.case.log", string="Logs History"), - 'stage_id': fields.many2one ('crm.case.stage', 'Stage',\ + " communication between partner and users by email"), + 'probability': fields.float('Probability'), + 'email_last': fields.function(_email_last, method=True, + string='Latest E-Mail', type='text'), + 'partner_id': fields.many2one('res.partner', 'Partner'), + 'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \ + domain="[('partner_id','=',partner_id)]"), + 'create_date': fields.datetime('Creation Date' , readonly=True), + 'write_date': fields.datetime('Update Date' , readonly=True), + 'date_deadline': fields.date('Deadline'), + 'user_id': fields.many2one('res.users', 'Responsible'), + 'history_line': fields.function(_get_log_ids, method=True, type='one2many', \ + multi="history_line", relation="crm.case.history", string="Communication"), + 'log_ids': fields.function(_get_log_ids, method=True, type='one2many', \ + multi="log_ids", relation="crm.case.log", string="Logs History"), + 'stage_id': fields.many2one ('crm.case.stage', 'Stage', \ domain="[('section_id','=',section_id),\ - ('object_id.model', '=', 'crm.opportunity')]"), - 'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True, + ('object_id.model', '=', 'crm.opportunity')]"), + 'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True, help='The state is set to \'Draft\', when a case is created.\ \nIf the case is in progress the state is set to \'Open\'.\ \nWhen the case is over, the state is set to \'Done\'.\ - \nIf the case needs to be reviewed then the state is set to \'Pending\'.'), - 'company_id': fields.many2one('res.company', 'Company'), + \nIf the case needs to be reviewed then the state is set to \'Pending\'.'), + 'company_id': fields.many2one('res.company', 'Company'), } def _get_default_partner_address(self, cr, uid, context): - - """ + """Gives id of default address for current user @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """ - if not context.get('portal', False): return False return self.pool.get('res.users').browse(cr, uid, uid, context).address_id.id def _get_default_partner(self, cr, uid, context): - - """ + """Gives id of partner for current user @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """ - if not context.get('portal', False): return False user = self.pool.get('res.users').browse(cr, uid, uid, context) @@ -384,14 +377,12 @@ class crm_case(osv.osv): return user.address_id.partner_id.id def _get_default_email(self, cr, uid, context): - - """ + """Gives default email address for current user @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """ - if not context.get('portal', False): return False user = self.pool.get('res.users').browse(cr, uid, uid, context) @@ -400,63 +391,66 @@ class crm_case(osv.osv): return user.address_id.email def _get_default_user(self, cr, uid, context): - """ + """Gives current user id @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """ - if context.get('portal', False): return False return uid def _get_section(self, cr, uid, context): - """ + """Gives section id for current User @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """ - user = self.pool.get('res.users').browse(cr, uid, uid, context=context) return user.context_section_id.id or False _defaults = { - 'active': lambda *a: 1, - 'user_id': _get_default_user, - 'partner_id': _get_default_partner, - 'partner_address_id': _get_default_partner_address, - 'email_from': _get_default_email, - 'state': lambda *a: 'draft', - 'section_id': _get_section, - 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.case', context=c), + 'active': lambda *a: 1, + 'user_id': _get_default_user, + 'partner_id': _get_default_partner, + 'partner_address_id': _get_default_partner_address, + 'email_from': _get_default_email, + 'state': lambda *a: 'draft', + 'section_id': _get_section, + 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.case', context=c), } _order = 'date_deadline desc, create_date desc,id desc' - def unlink(self, cr, uid, ids, context={}): - - """ + def unlink(self, cr, uid, ids, context=None): + """Overrides orm unlink method @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param ids: List of case’s IDs - @param context: A standard dictionary for contextual values""" + @param ids: List of case IDs + @param context: A standard dictionary for contextual values + """ + if not context: + context = {} for case in self.browse(cr, uid, ids, context): if (not case.section_id.allow_unlink) and (case.state <> 'draft'): - raise osv.except_osv(_('Warning !'), + raise osv.except_osv(_('Warning !'), _('You can not delete this case. You should better cancel it.')) return super(crm_case, self).unlink(cr, uid, ids, context) - def stage_next(self, cr, uid, ids, context={}): - """ + def stage_next(self, cr, uid, ids, context=None): + """This function computes next stage for case from its current stage + using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param ids: List of stage next’s IDs + @param ids: List of case IDs @param context: A standard dictionary for contextual values""" + if not context: + context = {} s = self.get_stage_dict(cr, uid, ids, context=context) for case in self.browse(cr, uid, ids, context): @@ -467,15 +461,17 @@ class crm_case(osv.osv): self.write(cr, uid, [case.id], {'stage_id': s[section][st]}) return True - def get_stage_dict(self, cr, uid, ids, context={}): - """ + def get_stage_dict(self, cr, uid, ids, context=None): + """This function gives dictionary for stage according to stage levels @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param ids: List of stage dict’s IDs + @param ids: List of case IDs @param context: A standard dictionary for contextual values""" + if not context: + context = {} - sid = self.pool.get('crm.case.stage').search(cr, uid,\ + sid = self.pool.get('crm.case.stage').search(cr, uid, \ [('object_id.model', '=', self._name)], context=context) s = {} previous = {} @@ -486,86 +482,99 @@ class crm_case(osv.osv): previous[section] = stage.id return s - def stage_previous(self, cr, uid, ids, context={}): - """ + def stage_previous(self, cr, uid, ids, context=None): + """This function computes previous stage for case from its current stage + using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param ids: List of stage previous’s IDs + @param ids: List of case IDs @param context: A standard dictionary for contextual values""" + if not context: + context = {} s = self.get_stage_dict(cr, uid, ids, context=context) for case in self.browse(cr, uid, ids, context): section = (case.section_id.id or False) if section in s: - st = case.stage_id.id or False + st = case.stage_id.id or False s[section] = dict([(v, k) for (k, v) in s[section].iteritems()]) if st in s[section]: self.write(cr, uid, [case.id], {'stage_id': s[section][st]}) return True - def history(self, cr, uid, ids, keyword, history=False, email=False, details=None, context={}): - """ + def history(self, cr, uid, ids, keyword, history=False, email=False, details=None, context=None): + """This function is used to make entry in case history according to action performed @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param ids: List of History’s IDs + @param ids: List of Case ids + @param keyword: Case action keyword e.g.: If case is closed "Close" keyword is used + @param history: Value True/False, If True it makes entry in case History otherwise in Case Log + @param email: Email address if any + @param details: Details of case history if any @param context: A standard dictionary for contextual values""" + + if not context: + context = {} cases = self.browse(cr, uid, ids, context=context) return self.__history(cr, uid, cases, keyword=keyword, \ history=history, email=email, details=details, \ context=context) - def __history(self, cr, uid, cases, keyword, history=False, email=False, details=None, email_from=False, context={}): - """ + def __history(self, cr, uid, cases, keyword, history=False, email=False, details=None, email_from=False, context=None): + """This function is used to make entry in case history according to action performed @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param ids: List of History’s IDs + @param ids: List of Case ids + @param keyword: Case action keyword e.g.: If case is closed "Close" keyword is used + @param history: Value True/False, If True it makes entry in case History otherwise in Case Log + @param email: Email address if any + @param details: Details of case history if any @param context: A standard dictionary for contextual values""" - + if not context: + context = {} model_obj = self.pool.get('ir.model') - + obj = self.pool.get('crm.case.log') for case in cases: model_ids = model_obj.search(cr, uid, [('model', '=', case._name)]) data = { - 'name': keyword, - 'user_id': uid, - 'date': time.strftime('%Y-%m-%d %H:%M:%S'), - 'model_id' : model_ids and model_ids[0] or False, - 'res_id': case.id, + 'name': keyword, + 'user_id': uid, + 'date': time.strftime('%Y-%m-%d %H:%M:%S'), + 'model_id' : model_ids and model_ids[0] or False, + 'res_id': case.id, 'section_id': case.section_id.id } - obj = self.pool.get('crm.case.log') if history: obj = self.pool.get('crm.case.history') data['description'] = details or case.description data['email_to'] = email or \ (case.section_id and case.section_id.reply_to) or \ (case.user_id and case.user_id.address_id and \ - case.user_id.address_id.email) or tools.config.get('email_from',False) + case.user_id.address_id.email) or tools.config.get('email_from', False) data['email_from'] = email_from or \ (case.section_id and case.section_id.reply_to) or \ (case.user_id and case.user_id.address_id and \ - case.user_id.address_id.email) or tools.config.get('email_from',False) + case.user_id.address_id.email) or tools.config.get('email_from', False) res = obj.create(cr, uid, data, context) return True + _history = __history def create(self, cr, uid, *args, **argv): - - """ + """Overrides orm create method @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param *args: Give Tuple Value - @Paran **args: Give Dictionay of Keyword Value + @param *args: Tuple Value for additional Params + @param **argv: Dictionay of Keyword Params """ - res = super(crm_case, self).create(cr, uid, *args, **argv) cases = self.browse(cr, uid, [res]) cases[0].state # to fill the browse record cache @@ -573,99 +582,33 @@ class crm_case(osv.osv): return res def add_reply(self, cursor, user, ids, context=None): - - """ + """This function finds last email and gives its description value for reply mail @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, + @param cursor: the current row, from the database cursor, + @param user: the current user’s ID for security checks + @param ids: List of case IDs @param context: A standard dictionary for contextual values """ - for case in self.browse(cursor, user, ids, context=context): if case.email_last: description = case.email_last self.write(cursor, user, case.id, { - 'description': '> ' + description.replace('\n', '\n> '), + 'description': '> ' + description.replace('\n', '\n> '), }, context=context) return True - def case_log(self, cr, uid, ids, context={}, email=False, *args): - - """ - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param context: A standard dictionary for contextual values - @param *args: Give Tuple Value - """ - - cases = self.browse(cr, uid, ids) - self.__history(cr, uid, cases, _('Historize'), history=True, email=email) - return self.write(cr, uid, ids, {'description': False, 'som': False, - 'canal_id': False}) - - def case_log_reply(self, cr, uid, ids, context={}, email=False, *args): - - """ - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param context: A standard dictionary for contextual values - @param *args: Give Tuple Value - """ - - cases = self.browse(cr, uid, ids) - for case in cases: - if not case.email_from: - raise osv.except_osv(_('Error!'), - _('You must put a Partner eMail to use this action!')) - - if not case.user_id: - raise osv.except_osv(_('Error!'), - _('You must define a responsible user for this case in order to use this action!')) - - if not case.description: - raise osv.except_osv(_('Error!'), - _('Can not send mail with empty body,you should have description in the body')) - - self.__history(cr, uid, cases, _('Send'), history=True, email=False) - for case in cases: - self.write(cr, uid, [case.id], { - 'description': False, - }) - emails = [case.email_from] + (case.email_cc or '').split(',') - emails = filter(None, emails) - body = case.description or '' - if case.user_id.signature: - body += '\n\n%s' % (case.user_id.signature) - - emailfrom = case.user_id.address_id and case.user_id.address_id.email or False - if not emailfrom: - raise osv.except_osv(_('Error!'), - _("No E-Mail ID Found for your Company address!")) - - tools.email_send( - emailfrom, - emails, - '[' + str(case.id) + '] ' + case.name, - self.format_body(body), - reply_to = case.section_id.reply_to, - openobject_id = str(case.id) - ) - self.__history(cr, uid, [case], _('Send'), history=True, email=emails, details=body, email_from=emailfrom) - return True - def onchange_partner_id(self, cr, uid, ids, part, email=False): - - """ + """This function returns value of partner address based on partner @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, + @param ids: List of case IDs + @param part: Partner's id + @email: Partner's email ID """ - if not part: - return {'value': {'partner_address_id': False, - 'email_from': False, + return {'value': {'partner_address_id': False, + 'email_from': False, }} addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['contact']) data = {'partner_address_id': addr['contact']} @@ -673,29 +616,27 @@ class crm_case(osv.osv): return {'value': data} def onchange_partner_address_id(self, cr, uid, ids, add, email=False): - - """ + """This function returns value of partner email based on Partner Address @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, + @param ids: List of case IDs + @param add: Id of Partner's address + @email: Partner's email ID """ - - data = {} if not add: return {'value': {'email_from': False, 'partner_name2': False}} address = self.pool.get('res.partner.address').browse(cr, uid, add) - data['email_from'] = address.email - return {'value': data} + return {'value': {'email_from': address.email}} def case_close(self, cr, uid, ids, *args): - """ + """Closes Case @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param ids: List of case's Ids - @param *args: Give Tuple Value + @param ids: List of case Ids + @param *args: Tuple Value for additional Params """ - cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.__history(cr, uid, cases, _('Close')) @@ -707,14 +648,13 @@ class crm_case(osv.osv): return True def case_escalate(self, cr, uid, ids, *args): - """ + """Escalates case to top level @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param ids: List of case's Ids - @param *args: Give Tuple Value + @param ids: List of case Ids + @param *args: Tuple Value for additional Params """ - cases = self.browse(cr, uid, ids) for case in cases: data = {'active': True, 'user_id': False} @@ -731,36 +671,33 @@ class crm_case(osv.osv): self._action(cr, uid, cases, 'escalate') return True - def case_open(self, cr, uid, ids, *args): - """ + """Opens Case @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param ids: List of case's Ids - @param *args: Give Tuple Value + @param ids: List of case Ids + @param *args: Tuple Value for additional Params """ - cases = self.browse(cr, uid, ids) self.__history(cr, uid, cases, _('Open')) + for case in cases: data = {'state': 'open', 'active': True} if not case.user_id: data['user_id'] = uid - self.write(cr, uid, ids, {'state': 'open', 'active': True}) + self.write(cr, uid, case.id, data) self._action(cr, uid, cases, 'open') return True - def case_cancel(self, cr, uid, ids, *args): - """ + """Cancels Case @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param ids: List of case's Ids - @param *args: Give Tuple Value + @param ids: List of case Ids + @param *args: Tuple Value for additional Params """ - cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.__history(cr, uid, cases, _('Cancel')) @@ -769,15 +706,13 @@ class crm_case(osv.osv): return True def case_pending(self, cr, uid, ids, *args): - - """ + """Marks case as pending @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param ids: List of case's Ids - @param *args: Give Tuple Value + @param ids: List of case Ids + @param *args: Tuple Value for additional Params """ - cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.__history(cr, uid, cases, _('Pending')) @@ -786,15 +721,13 @@ class crm_case(osv.osv): return True def case_reset(self, cr, uid, ids, *args): - - """ + """Resets case as draft @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param ids: List of case's Ids - @param *args: Give Tuple Value + @param ids: List of case Ids + @param *args: Tuple Value for additional Params """ - cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.__history(cr, uid, cases, _('Draft')) @@ -812,16 +745,16 @@ class crm_case_log(osv.osv): _order = "id desc" _columns = { - 'name': fields.char('Status', size=64), - 'date': fields.datetime('Date'), - 'section_id': fields.many2one('crm.case.section', 'Section'), - 'user_id': fields.many2one('res.users', 'User Responsible', readonly=True), - 'model_id': fields.many2one('ir.model', "Model"), - 'res_id': fields.integer('Resource ID'), + 'name': fields.char('Status', size=64), + 'date': fields.datetime('Date'), + 'section_id': fields.many2one('crm.case.section', 'Section'), + 'user_id': fields.many2one('res.users', 'User Responsible', readonly=True), + 'model_id': fields.many2one('ir.model', "Model"), + 'res_id': fields.integer('Resource ID'), } _defaults = { - 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), + 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), } crm_case_log() @@ -835,14 +768,13 @@ class crm_case_history(osv.osv): _inherits = {'crm.case.log': "log_id"} def _note_get(self, cursor, user, ids, name, arg, context=None): - - """ @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param ids: List of case History’s IDs - @param context: A standard dictionary for contextual values + """ Gives case History Description + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of case History’s IDs + @param context: A standard dictionary for contextual values """ - res = {} for hist in self.browse(cursor, user, ids, context or {}): res[hist.id] = (hist.email or '/') + ' (' + str(hist.date) + ')\n' @@ -850,11 +782,11 @@ class crm_case_history(osv.osv): return res _columns = { - 'description': fields.text('Description'), - 'note': fields.function(_note_get, method=True, string="Description", type="text"), - 'email_to': fields.char('Email TO', size=84), - 'email_from' : fields.char('Email From', size=84), - 'log_id': fields.many2one('crm.case.log','Log',ondelete='cascade'), + 'description': fields.text('Description'), + 'note': fields.function(_note_get, method=True, string="Description", type="text"), + 'email_to': fields.char('Email TO', size=84), + 'email_from' : fields.char('Email From', size=84), + 'log_id': fields.many2one('crm.case.log', 'Log', ondelete='cascade'), } crm_case_history() @@ -864,7 +796,7 @@ class users(osv.osv): _inherit = 'res.users' _description = "Users" _columns = { - 'context_section_id': fields.many2one('crm.case.section', 'Sales Team'), + 'context_section_id': fields.many2one('crm.case.section', 'Sales Team'), } users() @@ -872,7 +804,7 @@ users() class res_partner(osv.osv): _inherit = 'res.partner' _columns = { - 'section_id': fields.many2one('crm.case.section', 'Sales Team'), + 'section_id': fields.many2one('crm.case.section', 'Sales Team'), } res_partner() From fdecfbfd408e9cf46269e57dbb6f8b41389997e6 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Tue, 6 Apr 2010 18:10:22 +0530 Subject: [PATCH 10/59] [IMP]: crm_caldav: Improved module description bzr revid: rpa@tinyerp.com-20100406124022-mww5cxktdj9dglg4 --- addons/crm_caldav/__terp__.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/addons/crm_caldav/__terp__.py b/addons/crm_caldav/__terp__.py index 0bfb48e328a..92924a80d7a 100644 --- a/addons/crm_caldav/__terp__.py +++ b/addons/crm_caldav/__terp__.py @@ -21,25 +21,25 @@ { - 'name': 'Extened Module to Add CalDav future on Meeting', - 'version': '1.0', - 'category': 'Generic Modules/CRM & SRM', + 'name': 'Extened Module to Add CalDAV feature on Meeting', + 'version': '1.0', + 'category': 'Generic Modules/CRM & SRM', 'description': """ - New Futures in Meeting: - * Share meeting with other calendar clients like sunbird + New Features in Meeting: + * Meeting synchronization using Caldav + * Share Meeting with other Calendar clients like Sunbird """, 'author': 'Tiny', 'website': 'http://www.openerp.com', - 'depends': ['caldav', 'crm' - ], + 'depends': ['caldav', 'crm'], 'init_xml': [ - 'crm_caldav_data.xml', + 'crm_caldav_data.xml', ], - 'update_xml': [], + 'update_xml': [], 'demo_xml': [], 'installable': True, - 'active': False, + 'active': False, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 62115d03dc867ccff9aa304b27587e9c048d6e35 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Wed, 7 Apr 2010 18:48:54 +0530 Subject: [PATCH 11/59] [FIX]: document: Corrected relation table with group bzr revid: rpa@tinyerp.com-20100407131854-wa3avfr60zxh52te --- addons/document/document.py | 2 +- addons/document/document_storage.py | 2 +- addons/document/document_view.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/document/document.py b/addons/document/document.py index f6cbddebae7..2b2ac2f7587 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -73,7 +73,7 @@ class document_file(osv.osv): _columns = { 'user_id': fields.many2one('res.users', 'Owner', select=1), - 'group_ids': fields.many2many('res.groups', 'document_directory_group_rel', 'item_id', 'group_id', 'Groups'), + 'group_ids': fields.many2many('res.groups', 'document_group_rel', 'item_id', 'group_id', 'Groups'), # the directory id now is mandatory. It can still be computed automatically. 'parent_id': fields.many2one('document.directory', 'Directory', select=1, required=True), 'file_size': fields.integer('File Size', required=True), diff --git a/addons/document/document_storage.py b/addons/document/document_storage.py index bea11d6d12e..421c423b900 100644 --- a/addons/document/document_storage.py +++ b/addons/document/document_storage.py @@ -103,7 +103,7 @@ class document_storage(osv.osv): 'create_date': fields.datetime('Date Created', readonly=True), 'create_uid': fields.many2one('res.users', 'Creator', readonly=True), 'user_id': fields.many2one('res.users', 'Owner'), - 'group_ids': fields.many2many('res.groups', 'document_directory_group_rel', 'item_id', 'group_id', 'Groups'), + 'group_ids': fields.many2many('res.groups', 'document_storage_group_rel', 'item_id', 'group_id', 'Groups'), 'dir_ids': fields.one2many('document.directory', 'parent_id', 'Directories'), 'type': fields.selection([('db', 'Database'), ('filestore', 'Internal File storage'), ('realstore', 'External file storage'), ('virtual', 'Virtual storage')], 'Type', required=True), diff --git a/addons/document/document_view.xml b/addons/document/document_view.xml index 252b9b36a26..cab0fb7ac78 100644 --- a/addons/document/document_view.xml +++ b/addons/document/document_view.xml @@ -77,7 +77,7 @@