From 5ac2971eeff10c01a0e6950235b684e7169a8c83 Mon Sep 17 00:00:00 2001 From: "Harry (Open ERP)" Date: Wed, 30 Dec 2009 12:48:13 +0530 Subject: [PATCH 1/6] [IMP] document_ics : removed ics_field_id field bzr revid: hmo@tinyerp.com-20091230071813-1np7fagrrp5c7k2s --- addons/document_ics/document_demo.xml | 4 ++-- addons/document_ics/document_ics.py | 4 ++-- addons/document_ics/document_view.xml | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/document_ics/document_demo.xml b/addons/document_ics/document_demo.xml index 964be6511e0..b21842214b1 100644 --- a/addons/document_ics/document_demo.xml +++ b/addons/document_ics/document_demo.xml @@ -17,8 +17,8 @@ .ics - - + + diff --git a/addons/document_ics/document_ics.py b/addons/document_ics/document_ics.py index 09029975255..8d78080b1b2 100644 --- a/addons/document_ics/document_ics.py +++ b/addons/document_ics/document_ics.py @@ -80,7 +80,7 @@ class document_directory_content(osv.osv): 'obj_iterate': fields.boolean('Iterate object',help="If set, a separate instance will be created for each record of Object"), 'fname_field': fields.char("Filename field",size=16,help="The field of the object used in the filename. Has to be a unique identifier."), 'ics_domain': fields.char('Domain', size=64), - 'ics_field_ids': fields.one2many('document.directory.ics.fields', 'content_id', 'Fields Mapping') + #'ics_field_ids': fields.one2many('document.directory.ics.fields', 'content_id', 'Fields Mapping') } _defaults = { 'ics_domain': lambda *args: '[]' @@ -140,7 +140,7 @@ class document_directory_content(osv.osv): idomain[d[0]]=d[2] fobj = self.pool.get(content.object_id.model) - fobj.import_cal(cr, uid, base64.encodestring(data), context=context) + fobj.import_cal(cr, uid, base64.encodestring(data), context=context) return True def process_read(self, cr, uid, node, context=None): diff --git a/addons/document_ics/document_view.xml b/addons/document_ics/document_view.xml index e5212fc7f66..36e3ad87b87 100644 --- a/addons/document_ics/document_view.xml +++ b/addons/document_ics/document_view.xml @@ -21,17 +21,18 @@ form - + + - + From f012f8aa756ae70513fc845a4783025b4bf9e8ee Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Wed, 30 Dec 2009 13:47:59 +0530 Subject: [PATCH 2/6] [ADD]: project_calendar: Added wizard to subscribe to remote calendar bzr revid: rpa@tinyerp.com-20091230081759-dbvvosaj8vlx7hw4 --- .../project_calendar_wizard.xml | 4 + addons/project_calendar/wizard/__init__.py | 1 + .../wizard/wizard_cal_subscribe.py | 95 +++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 addons/project_calendar/wizard/wizard_cal_subscribe.py diff --git a/addons/project_calendar/project_calendar_wizard.xml b/addons/project_calendar/project_calendar_wizard.xml index 97410cade5c..b30abb809e0 100644 --- a/addons/project_calendar/project_calendar_wizard.xml +++ b/addons/project_calendar/project_calendar_wizard.xml @@ -9,6 +9,10 @@ multi="True" /> + + diff --git a/addons/project_calendar/wizard/__init__.py b/addons/project_calendar/wizard/__init__.py index 009d377ad04..6bb857e3a21 100644 --- a/addons/project_calendar/wizard/__init__.py +++ b/addons/project_calendar/wizard/__init__.py @@ -21,5 +21,6 @@ import wizard_cal_export import wizard_cal_import +import wizard_cal_subscribe # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/project_calendar/wizard/wizard_cal_subscribe.py b/addons/project_calendar/wizard/wizard_cal_subscribe.py new file mode 100644 index 00000000000..a67ff03879c --- /dev/null +++ b/addons/project_calendar/wizard/wizard_cal_subscribe.py @@ -0,0 +1,95 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from tools.translate import _ +import base64 +import pooler +import urllib +import wizard + +class project_cal_subscribe_wizard(wizard.interface): + form1 = ''' +
+ + + ''' + + form1_fields = { + 'url_path': { + 'string': 'Provide path for remote calendar', + 'type': 'char', + 'required': True, + 'size': 124 + } + } + display = ''' +
+ + ''' + + display_fields = { + 'msg': { + 'string': '', + 'type': 'text', + 'readonly': True, + } + } + + def _process_imp_ics(self, cr, uid, data, context=None): + global cnt + cnt = 0 + try: + f = urllib.urlopen(data['form']['url_path']) + caldata= f.fp.read() + f.close() + except Exception,e: + raise wizard.except_wizard(_('Error!'), _('Please provide Proper URL !')) + + task_obj = pooler.get_pool(cr.dbname).get('project.task') + context.update({'url': data['form']['url_path']}) + vals = task_obj.import_cal(cr, uid, base64.encodestring(caldata), context) + if vals: + cnt = vals['count'] + return {} + + def _result_set(self, cr, uid, data, context=None): + return {'msg': 'Subscribed %s Task(s)' % cnt} + + states = { + 'init': { + 'actions': [], + 'result': {'type': 'form', 'arch': form1, 'fields': form1_fields, \ + 'state': [('end', '_Cancel', 'gtk-cancel'), ('open', '_Subscribe', 'gtk-ok')]} + }, + 'open': { + 'actions': [], + 'result': {'type': 'action', 'action': _process_imp_ics, 'state': 'display'} + }, + 'display': { + 'actions': [_result_set], + 'result': {'type': 'form', 'arch': display, 'fields': display_fields, \ + 'state': [('end', 'Ok', 'gtk-ok')]} + }, + } + +project_cal_subscribe_wizard('caldav.project.subscribe') + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file From 4f7553af95adc7b0b39aa9504063193a81348463 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Wed, 30 Dec 2009 13:49:57 +0530 Subject: [PATCH 3/6] [IMP]: crm: Added validation for Remote URL bzr revid: rpa@tinyerp.com-20091230081957-ozpvdtd9uyfb8ei2 --- addons/crm/wizard/wizard_cal_subscribe.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/crm/wizard/wizard_cal_subscribe.py b/addons/crm/wizard/wizard_cal_subscribe.py index 587b21f6f24..5c6fa0250d0 100644 --- a/addons/crm/wizard/wizard_cal_subscribe.py +++ b/addons/crm/wizard/wizard_cal_subscribe.py @@ -19,10 +19,11 @@ # ############################################################################## -import wizard +from tools.translate import _ +import base64 import pooler import urllib -import base64 +import wizard class crm_cal_subscribe_wizard(wizard.interface): form1 = ''' @@ -55,9 +56,12 @@ class crm_cal_subscribe_wizard(wizard.interface): def _process_imp_ics(self, cr, uid, data, context=None): global cnt cnt = 0 - f = urllib.urlopen(data['form']['url_path']) - caldata= f.fp.read() - f.close() + try: + f = urllib.urlopen(data['form']['url_path']) + caldata= f.fp.read() + f.close() + except Exception,e: + raise wizard.except_wizard(_('Error!'), _('Please provide Proper URL !')) case_obj = pooler.get_pool(cr.dbname).get('crm.meeting') context.update({'url': data['form']['url_path']}) vals = case_obj.import_cal(cr, uid, base64.encodestring(caldata), context) From 232bf160b2ee04b4af2e8fb85377013e045d7d3a Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Wed, 30 Dec 2009 15:03:26 +0530 Subject: [PATCH 4/6] [FIX]: Fixed problem of importing calendar without alarm details bzr revid: rpa@tinyerp.com-20091230093326-5tu3hn8jeorkcs8p --- addons/caldav/calendar.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/addons/caldav/calendar.py b/addons/caldav/calendar.py index aeac98ecdf8..ee55e4671b3 100644 --- a/addons/caldav/calendar.py +++ b/addons/caldav/calendar.py @@ -38,13 +38,18 @@ def map_data(cr, uid, obj): map_val = obj.ical_get(map_dict, 'value') field = obj.ical_get(map_dict, 'field') field_type = obj.ical_get(map_dict, 'type') - if field and map_val: + if field: if field_type == 'selection': + if not map_val: + continue mapping =obj.__attribute__[map_dict].get('mapping', False) if mapping: map_val = mapping[map_val] if field_type == 'many2many': ids = [] + if not map_val: + vals[field] = ids + continue model = obj.__attribute__[map_dict].get('object', False) modobj = obj.pool.get(model) for map_vall in map_val: @@ -54,12 +59,16 @@ def map_data(cr, uid, obj): continue if field_type == 'many2one': id = None + if not map_val: + vals[field] = id + continue model = obj.__attribute__[map_dict].get('object', False) modobj = obj.pool.get(model) id = modobj.create(cr, uid, map_val) vals[field] = id continue - vals[field] = map_val + if map_val: + vals[field] = map_val return vals class CalDAV(object): @@ -75,6 +84,7 @@ class CalDAV(object): else: startdate = todate(startdate) rset1 = rrulestr(rrulestring, dtstart=startdate, forceset=True) + for date in exdate: datetime_obj = todate(date) rset1._exdate.append(datetime_obj) @@ -162,9 +172,9 @@ class CalDAV(object): continue if cal_data.name.lower() in self.__attribute__: self.ical_set(cal_data.name.lower(), cal_data.value, 'value') - vals = map_data(cr, uid, self) - if vals: res.append(vals) - self.ical_reset('value') + vals = map_data(cr, uid, self) + if vals: res.append(vals) + self.ical_reset('value') return res From 5fdd61845bd8e0f30aaa6505651dc35ea6623c5c Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Wed, 30 Dec 2009 15:09:19 +0530 Subject: [PATCH 5/6] [IMP]: crm, caldav: Improvement in crm+caldav for recurrent dates and virtual events computation bzr revid: rpa@tinyerp.com-20091230093919-lgegnmy0de5lgn58 --- addons/caldav/common.py | 2 +- addons/crm/crm_meeting.py | 78 +++++++++++---------------------- addons/crm/crm_meeting_view.xml | 3 -- 3 files changed, 27 insertions(+), 56 deletions(-) diff --git a/addons/caldav/common.py b/addons/caldav/common.py index 2654c51caa9..91d90f67653 100644 --- a/addons/caldav/common.py +++ b/addons/caldav/common.py @@ -319,7 +319,7 @@ class set_rrule_wizard(osv.osv_memory): freq = datas.get('freq') if freq == 'None': - obj.write(cr, uid, [res_obj.id], {'rrule' : '', 'rdates': ''}) + obj.write(cr, uid, [res_obj.id], {'rrule' : ''}) return {} if datas.get('interval') <= 0: raise osv.except_osv(_('Error!'), ("Please select proper Interval")) diff --git a/addons/crm/crm_meeting.py b/addons/crm/crm_meeting.py index e40be8c91a1..ea2c52c5d51 100644 --- a/addons/crm/crm_meeting.py +++ b/addons/crm/crm_meeting.py @@ -70,22 +70,6 @@ class crm_meeting(osv.osv): 'valarm' : {'field':'alarm_id', 'type':'many2one', 'object' : 'crm.caldav.alarm'}, } - def _get_rdates(self, cr, uid, ids, name, arg, context=None): - res = {} - context.update({'read':True}) - for case in self.read(cr, uid, ids, ['date', 'rrule', 'exdate', 'exrule'], context=context): - if case['rrule']: - rule = case['rrule'] - exdate = case['exdate'] and case['exdate'].split(',') or [] - event_obj = self.pool.get('caldav.event') - res[case['id']] = str(event_obj.get_recurrent_dates(str(rule), exdate, case['date'])) - return res - - def _data_set(self, cr, uid, id, name, value, arg, context): - if not self.browse(cr, uid, id, context).rrule: - cr.execute("UPDATE crm_meeting set rdates='' where id=%s" % id) - return True - _columns = { 'inherit_case_id': fields.many2one('crm.case','Case',ondelete='cascade'), 'class' : fields.selection([('PUBLIC', 'PUBLIC'), ('PRIVATE', 'PRIVATE'), \ @@ -100,8 +84,6 @@ class crm_meeting(osv.osv): 'exrule' : fields.char('Exception Rule', size=352, help="defines a rule or repeating pattern\ for anexception to a recurrence set"), 'rrule' : fields.char('Recurrent Rule', size=352), - 'rdates' : fields.function(_get_rdates, method=True, fnct_inv=_data_set \ - , store=True, type='text'), 'attendees': fields.many2many('crm.caldav.attendee', 'crm_attendee_rel', 'case_id', \ 'attendee_id', 'Attendees'), 'alarm_id' : fields.many2one('crm.caldav.alarm', 'Alarm'), @@ -249,40 +231,33 @@ class crm_meeting(osv.osv): if fields and 'date' not in fields: fields.append('date') - res = super(crm_meeting, self).read(cr, uid, ids, fields=fields, context=context, load=load) - read_ids = ",".join([str(x) for x in ids]) - if not read_ids: + if not ids: return [] - cr.execute('select id,rrule,rdates from crm_meeting where id in (%s)' % read_ids) - rrules = filter(lambda x: not x['rrule']==None, cr.dictfetchall()) - rdates = [] - if not rrules: - for ress in res: - strdate = ''.join((re.compile('\d')).findall(ress['date'])) - idval = str(common.caldevIDs2readIDs(ress['id'])) + '-' + strdate - ress['id'] = idval - return res - result = res + [] - for data in rrules: - if data['rrule'] and data['rdates']: - rdates = eval(data['rdates']) - for res_temp in res: - if res_temp['id'] == data['id']: - val = res_temp - if rdates: - result.remove(val) - else: - strdate = ''.join((re.compile('\d')).findall(res_temp['date'])) - idval = str(common.caldevIDs2readIDs(res_temp['id'])) + '-' + strdate - res_temp['id'] = idval - - for rdate in rdates: - idval = (re.compile('\d')).findall(rdate) - val['date'] = rdate - id = str(val['id']).split('-')[0] - val['id'] = id + '-' + ''.join(idval) - val1 = val.copy() - result += [val1] + result = [] + for read_id in ids: + res = super(crm_meeting, self).read(cr, uid, read_id, fields=fields, context=context, load=load) + 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 = %s""" % read_id) + data = cr.dictfetchall()[0] + if not data['rrule']: + strdate = ''.join((re.compile('\d')).findall(data['date'])) + idval = str(common.caldevIDs2readIDs(data['id'])) + '-' + strdate + data['id'] = idval + res.update(data) + result.append(res) + else: + exdate = data['exdate'] and data['exdate'].split(',') or [] + event_obj = self.pool.get('caldav.event') + rdates = event_obj.get_recurrent_dates(str(data['rrule']), exdate, data['date'])[:10] + for rdate in rdates: + val = res.copy() + idval = (re.compile('\d')).findall(rdate) + val['date'] = rdate + id = str(res['id']).split('-')[0] + val['id'] = id + '-' + ''.join(idval) + val1 = val.copy() + result.append(val1) return result def copy(self, cr, uid, id, default=None, context={}): @@ -383,5 +358,4 @@ class crm_meeting_generic_wizard(osv.osv_memory): crm_meeting_generic_wizard() - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/crm/crm_meeting_view.xml b/addons/crm/crm_meeting_view.xml index 9c4e1ba0607..09d307cf465 100644 --- a/addons/crm/crm_meeting_view.xml +++ b/addons/crm/crm_meeting_view.xml @@ -87,9 +87,6 @@ - - - From d0381fa3a3d0f1fdcff3c6a93f38e7421bca0b53 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Wed, 30 Dec 2009 17:06:26 +0530 Subject: [PATCH 6/6] [FIX] caldav: fixed bug on file search bzr revid: hmo@tinyerp.com-20091230113626-f32b1xp76dn6855i --- addons/caldav/common.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/addons/caldav/common.py b/addons/caldav/common.py index 91d90f67653..95c966b5cf9 100644 --- a/addons/caldav/common.py +++ b/addons/caldav/common.py @@ -172,15 +172,12 @@ class ir_attachment(osv.osv): def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): - new_args = [] - if len(args) > 1: - new_args = [args[0]] - if args[1][0] == 'res_id': - new_args.append((args[1][0], args[1][1], caldevIDs2readIDs(args[1][2]))) - if new_args: - args = new_args - return super(ir_attachment, self).search(cr, uid, args, offset=offset, - limit=limit, order=order, + new_args = args + for i, arg in enumerate(new_args): + if arg[0] == 'res_id': + new_args[i] = (arg[0], arg[1], caldevIDs2readIDs(arg[2])) + return super(ir_attachment, self).search(cr, uid, new_args, offset=offset, + limit=limit, order=order, context=context, count=False) ir_attachment()