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 diff --git a/addons/caldav/common.py b/addons/caldav/common.py index 2654c51caa9..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() @@ -319,7 +316,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 336d38018d0..ea2c52c5d51 100644 --- a/addons/crm/crm_meeting.py +++ b/addons/crm/crm_meeting.py @@ -70,17 +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 - _columns = { 'inherit_case_id': fields.many2one('crm.case','Case',ondelete='cascade'), 'class' : fields.selection([('PUBLIC', 'PUBLIC'), ('PRIVATE', 'PRIVATE'), \ @@ -95,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, string='Recurrent Dates', \ - 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'), @@ -184,6 +171,9 @@ class crm_meeting(osv.osv): alarm_obj.__attribute__.update(crm_alarm.__attribute__) vals = event_obj.import_ical(cr, uid, file_content) for val in vals: + section_id = self.pool.get('crm.case.section').search(cr, uid, \ + [('name', 'like', 'Meeting%')])[0] + val.update({'section_id' : section_id}) is_exists = common.uid2openobjectid(cr, val['id'], self._name ) val.pop('id') if val.has_key('create_date'): val.pop('create_date') @@ -241,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={}): @@ -375,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 @@ - - - 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) diff --git a/addons/document_ftp/doc_conf_wizard.py b/addons/document_ftp/doc_conf_wizard.py index ea0d0ab1487..fe967e107d5 100644 --- a/addons/document_ftp/doc_conf_wizard.py +++ b/addons/document_ftp/doc_conf_wizard.py @@ -149,7 +149,7 @@ class document_configuration_wizard(osv.osv_memory): }) # Update the action for FTP browse. - aid = objid._get_id(cr, uid, 'document', 'action_document_browse') + aid = objid._get_id(cr, uid, 'document_ftp', 'action_document_browse') aid = objid.browse(cr, uid, aid, context=context).res_id self.pool.get('ir.actions.url').write(cr, uid, [aid], {'url': 'ftp://'+(conf.host or 'localhost')+':8021/'}) 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 - + + - + 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 diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 31041ebe810..2f79f8a2a08 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -776,8 +776,8 @@ class sale_order_line(osv.osv): 'notes': fields.text('Notes'), 'th_weight': fields.float('Weight'), 'state': fields.selection([('draft', 'Draft'),('confirmed', 'Confirmed'),('done', 'Done'),('cancel', 'Cancelled'),('exception', 'Exception')], 'State', required=True, readonly=True, - help=' * The \'Draft\' state is set automatically when sale order in draft state.. \ - \n* The \'Confirmed\' state is set automatically as confirm when sale order in confirm state. \ + help=' * The \'Draft\' state is set automatically when sale order in draft state. \ + \n* The \'Confirmed\' state is set automatically when sale order in confirm state. \ \n* The \'Exception\' state is set automatically when sale order is set as exception. \ \n* The \'Done\' state is set automatically when sale order is set as done. \ \n* The \'Cancelled\' state is set automatically when user cancel sale order.'), diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 3eee8f369ce..f18038172c6 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -901,71 +901,6 @@ class stock_production_lot(osv.osv): stock_production_lot() -class stock_split_production_lots(osv.osv_memory): - _name = "stock.split.production.lots" - _description = "Split Production Lots" - - def _quantity_default_get(self, cr, uid, object=False, field=False, context=None): - cr.execute("select %s from %s where id=%s" %(field,object,context.get('active_id'))) - res = cr.fetchone()[0] - return res - - _columns = { - 'name': fields.char('Lot Number/Prefix', size=64, required=True), - 'qty': fields.float('Total Quantity'), - 'action': fields.selection([('split','Split'),('keepinone','Keep in one lot')],'Action'), - } - _defaults = { - 'qty': lambda self,cr,uid,c: self.pool.get('stock.split.production.lots')._quantity_default_get(cr, uid, 'stock_move', 'product_qty',context=c) or 1, - } - - def split_lines(self, cr, uid, ids, context={}): - data = self.read(cr, uid, ids[0]) - prodlot_obj = self.pool.get('stock.production.lot') - move_obj = self.pool.get('stock.move') - move_browse = move_obj.browse(cr, uid, context['active_id']) - - quantity = data['qty'] - if quantity <= 0 or move_browse.product_qty == 0: - return {} - uos_qty = quantity/move_browse.product_qty*move_browse.product_uos_qty - - quantity_rest = move_browse.product_qty%quantity - uos_qty_rest = quantity_rest/move_browse.product_qty*move_browse.product_uos_qty - - update_val = { - 'product_qty': quantity, - 'product_uos_qty': uos_qty, - } - - new_move = [] - for idx in range(int(move_browse.product_qty//quantity)): - if idx: - current_move = move_obj.copy(cr, uid, move_browse.id, {'state': move_browse.state}) - new_move.append(current_move) - else: - current_move = move_browse.id - new_prodlot = prodlot_obj.create(cr, uid, {'name': data['name'], 'ref': '%d'%idx}, {'product_id': move_browse.product_id.id}) - update_val['prodlot_id'] = new_prodlot - move_obj.write(cr, uid, [current_move], update_val) - - if quantity_rest > 0: - idx = int(move_browse.product_qty//quantity) - update_val['product_qty'] = quantity_rest - update_val['product_uos_qty'] = uos_qty_rest - if idx: - current_move = move_obj.copy(cr, uid, move_browse.id, {'state': move_browse.state}) - new_move.append(current_move) - else: - current_move = move_browse.id - new_prodlot = prodlot_obj.create(cr, uid, {'name': data['name'], 'ref': '%d'%idx}, {'product_id': move_browse.product_id.id}) - update_val['prodlot_id'] = new_prodlot - move_obj.write(cr, uid, [current_move], update_val) - - return {} - -stock_split_production_lots() - class stock_production_lot_revision(osv.osv): _name = 'stock.production.lot.revision' diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 7b6cf1cce3f..b2fdd20c635 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -481,32 +481,6 @@ ============================= Picking ============================= - - Split Production Lots - stock.split.production.lots - form - -
- - - - - - -