From 31028bc1dd88ee9ee10d0ae8c8c66ca19af3eb6c Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 28 Oct 2008 09:38:03 +0100 Subject: improved_document bzr revid: fp@tinyerp.com-20081028083803-muzp8gr3l2er3sqf --- addons/document_ics/document.py | 76 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 addons/document_ics/document.py (limited to 'addons/document_ics/document.py') diff --git a/addons/document_ics/document.py b/addons/document_ics/document.py new file mode 100644 index 00000000000..e7874945194 --- /dev/null +++ b/addons/document_ics/document.py @@ -0,0 +1,76 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# $Id$ +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +from osv import osv, fields +from osv.orm import except_orm +import os +import StringIO +import base64 + +ICS_TAGS = [ + 'summary' +] + +class document_directory_ics_fields(osv.osv): + _name = 'document.directory.ics.fields' + _columns = { + 'field_ids': fields.many2one('ir.model.fields', 'Open ERP Field', required=True), + 'name': fields.selection(map(lambda x: (x,x), ICS_TAGS),'ICS Value', required=True), + } +document_directory_ics_fields() + +class document_directory_content(osv.osv): + _inherit = 'document.directory.content' + _columns = { + 'ics_object_id': fields.many2one('ir.model', 'Object'), + 'ics_domain': fields.char('Domain', size=64), + 'ics_field_ids': fields.one2many('document.directory.ics.fields', 'content_id', 'Fields Mapping') + } + _defaults = { + 'ics_domain': lambda *args: '[]' + } + def process_read_ics(self, cr, uid, node, context={}): + print 'READ ICS' + import vobject + obj_class = self.pool.get(node.content.ics_object_id.model) + # Can be improved to use context and active_id ! + domain = eval(node.content.ics_domain) + ids = obj_class.search(cr, uid, domain, context) + cal = vobject.iCalendar() + for obj in obj_class.browse(cr, uid, ids, context): + cal.add('vevent') + cal.vevent.add('summary').value = "This is a note" + break + s= StringIO.StringIO(cal.serialize()) + s.name = node + return s + +document_directory_content() + -- cgit v1.2.3 From 14a44892d1cdc93864e508cb325b98b5de8c7f99 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 28 Oct 2008 11:07:10 +0100 Subject: bugfixes bzr revid: fp@tinyerp.com-20081028100710-q3q7z5wrlwz0mgp9 --- addons/document_ics/document.py | 42 ++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) (limited to 'addons/document_ics/document.py') diff --git a/addons/document_ics/document.py b/addons/document_ics/document.py index e7874945194..843cf12e2eb 100644 --- a/addons/document_ics/document.py +++ b/addons/document_ics/document.py @@ -33,16 +33,30 @@ from osv.orm import except_orm import os import StringIO import base64 +import datetime +import time -ICS_TAGS = [ - 'summary' -] +ICS_TAGS = { + 'summary':'normal', + 'uid':'normal' , + 'dtstart':'date' , + 'dtend':'date' , + 'created':'date' , + 'dt-stamp':'date' , + 'last-modified':'normal' , + 'url':'normal' , + 'attendee':'multiple', + 'location':'normal', + 'categories': 'normal', + 'description':'normal' +} class document_directory_ics_fields(osv.osv): _name = 'document.directory.ics.fields' _columns = { - 'field_ids': fields.many2one('ir.model.fields', 'Open ERP Field', required=True), - 'name': fields.selection(map(lambda x: (x,x), ICS_TAGS),'ICS Value', required=True), + 'field_id': fields.many2one('ir.model.fields', 'Open ERP Field', required=True), + 'name': fields.selection(map(lambda x: (x,x), ICS_TAGS.keys()),'ICS Value', required=True), + 'content_id': fields.many2one('document.directory.content', 'Content', required=True, ondelete='cascade') } document_directory_ics_fields() @@ -65,12 +79,22 @@ class document_directory_content(osv.osv): ids = obj_class.search(cr, uid, domain, context) cal = vobject.iCalendar() for obj in obj_class.browse(cr, uid, ids, context): - cal.add('vevent') - cal.vevent.add('summary').value = "This is a note" - break + event = cal.add('vevent') + for field in node.content.ics_field_ids: + if ICS_TAGS[field.name]=='normal': + value = getattr(obj, field.field_id.name) or '' + event.add(field.name).value = value + elif ICS_TAGS[field.name]=='date': + dt = getattr(obj, field.field_id.name) or time.strftime('%Y-%m-%d %H:%M:%S') + if len(dt)==10: + if field.name=='dtend': + dt = dt+' 10:00:00' + else: + dt = dt+' 09:00:00' + value = datetime.datetime.strptime(dt, '%Y-%m-%d %H:%M:%S') + event.add(field.name).value = value s= StringIO.StringIO(cal.serialize()) s.name = node return s - document_directory_content() -- cgit v1.2.3 From c66a31dd1a43dd7dc04753d26ecf6682b4d25d56 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Wed, 29 Oct 2008 09:07:48 +0100 Subject: improvement bzr revid: fp@tinyerp.com-20081029080748-r536dvnrs360dwmh --- addons/document_ics/document.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'addons/document_ics/document.py') diff --git a/addons/document_ics/document.py b/addons/document_ics/document.py index 4999cc1bbfb..d45966c8b54 100644 --- a/addons/document_ics/document.py +++ b/addons/document_ics/document.py @@ -78,6 +78,9 @@ class document_directory_content(osv.osv): fobj = self.pool.get('document.directory.content') content = fobj.browse(cr, uid, node.content.id, context) + idomain = {} + for d in eval(content.ics_domain): + idomain[d[0]]=d[2] for n in content.ics_field_ids: fields[n.name] = n.field_id.name if 'uid' not in fields: @@ -101,7 +104,9 @@ class document_directory_content(osv.osv): if id: fobj.write(cr, uid, id, result, context=context) else: - fobj.create(cr, uid, result, context=context) + r = idomain.copy() + r.update(result) + fobj.create(cr, uid, r, context=context) return True -- cgit v1.2.3 From 17b7f3962eb03952581f4f3a3898aa4aa4b4c0bf Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Sat, 1 Nov 2008 09:55:47 +0100 Subject: improvement bzr revid: fp@tinyerp.com-20081101085547-rfs4k33snoir66sq --- addons/document_ics/document.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'addons/document_ics/document.py') diff --git a/addons/document_ics/document.py b/addons/document_ics/document.py index d45966c8b54..37cb45d58a0 100644 --- a/addons/document_ics/document.py +++ b/addons/document_ics/document.py @@ -125,7 +125,10 @@ class document_directory_content(osv.osv): value = 'OpenERP-'+str(random.randint(1999999999, 9999999999)) obj_class.write(cr, uid, [obj.id], {field.field_id.name: value}) if ICS_TAGS[field.name]=='normal': + if type(value)==type(obj): + value=value.name value = value or '' + print value event.add(field.name).value = value and value.decode('utf8') or '' elif ICS_TAGS[field.name]=='date': dt = value or time.strftime('%Y-%m-%d %H:%M:%S') @@ -141,3 +144,10 @@ class document_directory_content(osv.osv): return s document_directory_content() +class crm_case(osv.osv): + _inherit = 'crm.case' + _columns = { + 'code': fields.char('Calendar Code', size=64) + } +crm_case() + -- cgit v1.2.3 From f5fad0ba30336128c690838cd882a622644bf097 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 3 Nov 2008 20:18:56 +0100 Subject: passing modules in GPL-3 bzr revid: christophe@tinyerp.com-20081103191856-jhcivvwb16fvz2os --- addons/document_ics/document.py | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'addons/document_ics/document.py') diff --git a/addons/document_ics/document.py b/addons/document_ics/document.py index 37cb45d58a0..e131ecaa9a4 100644 --- a/addons/document_ics/document.py +++ b/addons/document_ics/document.py @@ -1,30 +1,22 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved. +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved +# $Id$ # -# $Id$ +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company +# 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 General Public License for more details. # -# This program is Free Software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . # ############################################################################## -- cgit v1.2.3