Merge lp:~openerp-dev/openobject-addons/trunk-calendar-import_event-uco into lp:~openerp-dev/openobject-addons/trunk-calendar

Proposed by Ujjvala Collins
Status: Superseded
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-calendar-import_event-uco
Merge into: lp:~openerp-dev/openobject-addons/trunk-calendar
Diff against target: 929 lines (+762/-11)
18 files modified
crm/crm_lead.py (+0/-1)
crm/wizard/crm_lead_to_partner.py (+2/-4)
crm/wizard/crm_merge_opportunities.py (+1/-4)
crm_partner_assign/wizard/crm_forward_to_partner.py (+0/-2)
google_base_account/__init__.py (+26/-0)
google_base_account/__openerp__.py (+41/-0)
google_base_account/google_base_account.py (+33/-0)
google_base_account/google_base_account_view.xml (+20/-0)
google_base_account/wizard/__init__.py (+25/-0)
google_base_account/wizard/google_login.py (+88/-0)
google_base_account/wizard/google_login_view.xml (+29/-0)
sync_google_calendar/__init__.py (+26/-0)
sync_google_calendar/__openerp__.py (+38/-0)
sync_google_calendar/sync_google_calendar.py (+43/-0)
sync_google_calendar/sync_google_calendar_view.xml (+32/-0)
sync_google_calendar/wizard/__init__.py (+24/-0)
sync_google_calendar/wizard/wizard_import_calendar_events.py (+289/-0)
sync_google_calendar/wizard/wizard_import_calendar_events_view.xml (+45/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-calendar-import_event-uco
Reviewer Review Type Date Requested Status
Bhumika Shrimali (community) Needs Fixing
Review via email: mp+53398@code.launchpad.net

This proposal supersedes a proposal from 2011-03-09.

This proposal has been superseded by a proposal from 2011-03-17.

Description of the change

Backlog 3 : Import event
* Wizard near meeting
* For login use the module google_account
* Choose which google calendar synchronize (there is more then one calendar per user)
   Can be all
   Need an option for all calendar (or rename default to all if default is for all calendar)
       Each calendar in google calendar will create a meeting of different type
       the type of the event is the title of the calendar
          Need to create new type if not present
   Map the meeting in openerp with the meeting in google calendar with ir.model.data
       Merge if the meeting already exist :
           the meeting already exist when the mapping in ir.model.data already exist
* Category of meeting : Add user field,
     if user = 0 for all user
     otherwise category is defined just for the user
       When import a google calendar : create a new category for each calendar
* Check Virtual Id
     check reccurent meeting
* Check Virtual Id
   check reccurent meeting

To post a comment you must log in.
Revision history for this message
tfr (Openerp) (tfr) wrote : Posted in a previous version of this proposal

Too early to merge this branch in the project branch, but good job

Revision history for this message
Bhumika Shrimali (sbh-openerp) wrote :

Hello,

1) Need to fix meeting record .

2) I got this error when import event .
deletion: you may be trying to delete a record while other records still reference it
creation/update: a mandatory field is not correctly set.

Thanks

review: Needs Fixing
Revision history for this message
Bhumika Shrimali (sbh-openerp) wrote :

Also check the edit all option of meeting not working well

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'crm/crm_lead.py'
2--- crm/crm_lead.py 2011-03-04 12:53:34 +0000
3+++ crm/crm_lead.py 2011-03-17 08:46:34 +0000
4@@ -248,7 +248,6 @@
5 data_obj = self.pool.get('ir.model.data')
6 value = {}
7
8- view_id = False
9
10 for case in self.browse(cr, uid, ids, context=context):
11 context.update({'active_id': case.id})
12
13=== modified file 'crm/wizard/crm_lead_to_partner.py'
14--- crm/wizard/crm_lead_to_partner.py 2011-03-01 11:34:15 +0000
15+++ crm/wizard/crm_lead_to_partner.py 2011-03-17 08:46:34 +0000
16@@ -153,7 +153,6 @@
17 contact_obj = self.pool.get('res.partner.address')
18 partner_ids = []
19 partner_id = False
20- contact_id = False
21 rec_ids = context and context.get('active_ids', [])
22
23 for data in self.browse(cr, uid, ids, context=context):
24@@ -164,7 +163,7 @@
25 'user_id': lead.user_id.id,
26 'comment': lead.description,
27 })
28- contact_id = contact_obj.create(cr, uid, {
29+ contact_obj.create(cr, uid, {
30 'partner_id': partner_id,
31 'name': lead.contact_name,
32 'phone': lead.phone,
33@@ -184,7 +183,6 @@
34 else:
35 if data.partner_id:
36 partner_id = data.partner_id.id
37- contact_id = partner_obj.address_get(cr, uid, [partner_id])['default']
38 self.assign_partner(cr, uid, lead.id, partner_id)
39 partner_ids.append(partner_id)
40 return partner_ids
41@@ -208,7 +206,7 @@
42 if context is None:
43 context = {}
44
45- partner_ids = self._create_partner(cr, uid, ids, context=context)
46+ self._create_partner(cr, uid, ids, context=context)
47 mod_obj = self.pool.get('ir.model.data')
48 result = mod_obj._get_id(cr, uid, 'base', 'view_res_partner_filter')
49 res = mod_obj.read(cr, uid, result, ['res_id'])
50
51=== modified file 'crm/wizard/crm_merge_opportunities.py'
52--- crm/wizard/crm_merge_opportunities.py 2011-02-24 15:03:09 +0000
53+++ crm/wizard/crm_merge_opportunities.py 2011-03-17 08:46:34 +0000
54@@ -45,7 +45,6 @@
55
56 def get_attachments(self, cr, uid, id, context=None):
57 attach_obj = self.pool.get('ir.attachment')
58- result = []
59 attach_ids = attach_obj.search(cr, uid, [('res_model' , '=', 'crm.lead'), ('res_id', '=', id)])
60 return attach_ids
61
62@@ -116,7 +115,7 @@
63 attach_ids = self.get_attachments(cr, uid, opp, context=context)
64 self.set_attachements_res_id(cr, uid, first_opportunity.id, attach_ids)
65 for history in opp.message_ids:
66- new_history = message_obj.copy(cr, uid, history.id, default={'res_id': opp.id})
67+ message_obj.copy(cr, uid, history.id, default={'res_id': opp.id})
68
69 #Notification about loss of information
70 details = []
71@@ -159,8 +158,6 @@
72
73
74 # Get Opportunity views
75- result = models_data._get_id(
76- cr, uid, 'crm', 'view_crm_case_opportunities_filter')
77 opportunity_view_form = models_data._get_id(
78 cr, uid, 'crm', 'crm_case_form_view_oppor')
79 opportunity_view_tree = models_data._get_id(
80
81=== modified file 'crm_partner_assign/wizard/crm_forward_to_partner.py'
82--- crm_partner_assign/wizard/crm_forward_to_partner.py 2011-02-24 15:03:09 +0000
83+++ crm_partner_assign/wizard/crm_forward_to_partner.py 2011-03-17 08:46:34 +0000
84@@ -20,11 +20,9 @@
85 #
86 ##############################################################################
87
88-import base64
89 import time
90 import re
91 from osv import osv, fields
92-import tools
93 from tools.translate import _
94
95 class crm_lead_forward_to_partner(osv.osv_memory):
96
97=== added directory 'google_base_account'
98=== added file 'google_base_account/__init__.py'
99--- google_base_account/__init__.py 1970-01-01 00:00:00 +0000
100+++ google_base_account/__init__.py 2011-03-17 08:46:34 +0000
101@@ -0,0 +1,26 @@
102+# -*- coding: utf-8 -*-
103+##############################################################################
104+#
105+# OpenERP, Open Source Management Solution
106+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
107+#
108+# This program is free software: you can redistribute it and/or modify
109+# it under the terms of the GNU Affero General Public License as
110+# published by the Free Software Foundation, either version 3 of the
111+# License, or (at your option) any later version.
112+#
113+# This program is distributed in the hope that it will be useful,
114+# but WITHOUT ANY WARRANTY; without even the implied warranty of
115+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
116+# GNU Affero General Public License for more details.
117+#
118+# You should have received a copy of the GNU Affero General Public License
119+# along with this program. If not, see <http://www.gnu.org/licenses/>.
120+#
121+##############################################################################
122+
123+import google_base_account
124+import wizard
125+
126+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
127+
128
129=== added file 'google_base_account/__openerp__.py'
130--- google_base_account/__openerp__.py 1970-01-01 00:00:00 +0000
131+++ google_base_account/__openerp__.py 2011-03-17 08:46:34 +0000
132@@ -0,0 +1,41 @@
133+# -*- coding: utf-8 -*-
134+##############################################################################
135+#
136+# OpenERP, Open Source Management Solution
137+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
138+#
139+# This program is free software: you can redistribute it and/or modify
140+# it under the terms of the GNU Affero General Public License as
141+# published by the Free Software Foundation, either version 3 of the
142+# License, or (at your option) any later version.
143+#
144+# This program is distributed in the hope that it will be useful,
145+# but WITHOUT ANY WARRANTY; without even the implied warranty of
146+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
147+# GNU Affero General Public License for more details.
148+#
149+# You should have received a copy of the GNU Affero General Public License
150+# along with this program. If not, see <http://www.gnu.org/licenses/>.
151+#
152+##############################################################################
153+
154+
155+{
156+ 'name': 'Google user',
157+ 'version': '1.0',
158+ 'category': 'Generic Modules/Others',
159+ 'description': """The module adds google user in res user""",
160+ 'author': 'OpenERP SA',
161+ 'website': 'http://www.openerp.com',
162+ 'depends': ['base'],
163+ 'init_xml': [],
164+ 'update_xml': [
165+ 'google_base_account_view.xml',
166+ 'wizard/google_login_view.xml',
167+ ],
168+ 'demo_xml': [],
169+ 'installable': True,
170+ 'active': False,
171+ 'certificate': '',
172+}
173+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
174
175=== added file 'google_base_account/google_base_account.py'
176--- google_base_account/google_base_account.py 1970-01-01 00:00:00 +0000
177+++ google_base_account/google_base_account.py 2011-03-17 08:46:34 +0000
178@@ -0,0 +1,33 @@
179+# -*- coding: utf-8 -*-
180+##############################################################################
181+#
182+# OpenERP, Open Source Management Solution
183+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
184+#
185+# This program is free software: you can redistribute it and/or modify
186+# it under the terms of the GNU Affero General Public License as
187+# published by the Free Software Foundation, either version 3 of the
188+# License, or (at your option) any later version.
189+#
190+# This program is distributed in the hope that it will be useful,
191+# but WITHOUT ANY WARRANTY; without even the implied warranty of
192+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
193+# GNU Affero General Public License for more details.
194+#
195+# You should have received a copy of the GNU Affero General Public License
196+# along with this program. If not, see <http://www.gnu.org/licenses/>.
197+#
198+##############################################################################
199+
200+from osv import fields,osv
201+
202+class res_users(osv.osv):
203+ _inherit = "res.users"
204+ _columns = {
205+ 'gmail_user': fields.char('Username', size=64,),
206+ 'gmail_password': fields.char('Password', size=64),
207+ }
208+res_users()
209+
210+# vim:expandtab:smartindent:toabstop=4:softtabstop=4:shiftwidth=4:
211+
212
213=== added file 'google_base_account/google_base_account_view.xml'
214--- google_base_account/google_base_account_view.xml 1970-01-01 00:00:00 +0000
215+++ google_base_account/google_base_account_view.xml 2011-03-17 08:46:34 +0000
216@@ -0,0 +1,20 @@
217+<?xml version="1.0"?>
218+<openerp>
219+ <data>
220+ <record id="view_users_gogole_form" model="ir.ui.view">
221+ <field name="name">res.users.google.form1</field>
222+ <field name="model">res.users</field>
223+ <field name="type">form</field>
224+ <field name="inherit_id" ref="base.view_users_form"/>
225+ <field name="arch" type="xml">
226+ <xpath expr="//notebook[last()]" position="inside">
227+ <page string=" Synchronization ">
228+ <separator string="Google Account" colspan="4" />
229+ <field name="gmail_user"/>
230+ <field name="gmail_password" password="True"/>
231+ </page>
232+ </xpath>
233+ </field>
234+ </record>
235+ </data>
236+</openerp>
237
238=== added directory 'google_base_account/wizard'
239=== added file 'google_base_account/wizard/__init__.py'
240--- google_base_account/wizard/__init__.py 1970-01-01 00:00:00 +0000
241+++ google_base_account/wizard/__init__.py 2011-03-17 08:46:34 +0000
242@@ -0,0 +1,25 @@
243+# -*- coding: utf-8 -*-
244+##############################################################################
245+#
246+# OpenERP, Open Source Management Solution
247+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
248+#
249+# This program is free software: you can redistribute it and/or modify
250+# it under the terms of the GNU Affero General Public License as
251+# published by the Free Software Foundation, either version 3 of the
252+# License, or (at your option) any later version.
253+#
254+# This program is distributed in the hope that it will be useful,
255+# but WITHOUT ANY WARRANTY; without even the implied warranty of
256+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
257+# GNU Affero General Public License for more details.
258+#
259+# You should have received a copy of the GNU Affero General Public License
260+# along with this program. If not, see <http://www.gnu.org/licenses/>.
261+#
262+##############################################################################
263+
264+import google_login
265+
266+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
267+
268
269=== added file 'google_base_account/wizard/google_login.py'
270--- google_base_account/wizard/google_login.py 1970-01-01 00:00:00 +0000
271+++ google_base_account/wizard/google_login.py 2011-03-17 08:46:34 +0000
272@@ -0,0 +1,88 @@
273+# -*- coding: utf-8 -*-
274+##############################################################################
275+#
276+# OpenERP, Open Source Management Solution
277+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
278+#
279+# This program is free software: you can redistribute it and/or modify
280+# it under the terms of the GNU Affero General Public License as
281+# published by the Free Software Foundation, either version 3 of the
282+# License, or (at your option) any later version.
283+#
284+# This program is distributed in the hope that it will be useful,
285+# but WITHOUT ANY WARRANTY; without even the implied warranty of
286+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
287+# GNU Affero General Public License for more details.
288+#
289+# You should have received a copy of the GNU Affero General Public License
290+# along with this program. If not, see <http://www.gnu.org/licenses/>.
291+#
292+##############################################################################
293+
294+from osv import fields,osv
295+from tools.translate import _
296+try:
297+ import gdata.contacts.service
298+except ImportError:
299+ raise osv.except_osv(_('Google Contacts Import Error!'), _('Please install gdata-python-client from http://code.google.com/p/gdata-python-client/downloads/list'))
300+
301+class google_login(osv.osv_memory):
302+ _description ='Google Contact'
303+ _name = 'google.login'
304+ _columns = {
305+ 'user': fields.char('Username', size=64, required=True),
306+ 'password': fields.char('Password', size=64),
307+ }
308+
309+ def google_login(self,cr,uid,user,password,type='',context=None):
310+ gd_client=False
311+ if type == 'group':
312+ gd_client = gdata.contacts.client.ContactsClient(source='OpenERP')
313+ if type == 'contact' :
314+ gd_client = gdata.contacts.service.ContactsService()
315+ if type == 'calendar':
316+ gd_client = gdata.calendar.service.CalendarService()
317+ try:
318+ gd_client.ClientLogin(user, password,gd_client.source)
319+ except Exception, e:
320+ raise osv.except_osv(_('Error'), _(e))
321+ return gd_client
322+
323+
324+ def default_get(self, cr, uid, fields, context=None):
325+ res = super(google_login, self).default_get(cr, uid, fields, context=context)
326+ user_obj = self.pool.get('res.users').browse(cr, uid, uid)
327+ if 'user' in fields:
328+ res.update({'user': user_obj.gmail_user})
329+ if 'password' in fields:
330+ res.update({'password': user_obj.gmail_password})
331+ return res
332+
333+ def check_login(self, cr, uid, ids, context=None):
334+ if context == None:
335+ context = {}
336+ data = self.read(cr, uid, ids)[0]
337+ user = data['user']
338+ password = data['password']
339+ gd_client = gdata.contacts.service.ContactsService()
340+ gd_client.email = user
341+ gd_client.password = password
342+ gd_client.source = 'OpenERP'
343+ try:
344+ gd_client.ProgrammaticLogin()
345+ res = {
346+ 'gmail_user': user,
347+ 'gmail_password': password
348+ }
349+ self.pool.get('res.users').write(cr, uid, uid, res, context=context)
350+ except :
351+ raise osv.except_osv(_('Error'), _("Authentication fail check the user and password !"))
352+
353+ return self._get_next_action(cr, uid, context=context)
354+
355+ def _get_next_action(self, cr, uid, context=None):
356+ return {'type': 'ir.actions.act_window_close'}
357+
358+google_login()
359+
360+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
361
362=== added file 'google_base_account/wizard/google_login_view.xml'
363--- google_base_account/wizard/google_login_view.xml 1970-01-01 00:00:00 +0000
364+++ google_base_account/wizard/google_login_view.xml 2011-03-17 08:46:34 +0000
365@@ -0,0 +1,29 @@
366+<?xml version="1.0"?>
367+<openerp>
368+ <data>
369+ <record model="ir.ui.view" id="view_google_login_form">
370+ <field name="name">google.login.form</field>
371+ <field name="model">google.login</field>
372+ <field name="type">form</field>
373+ <field name="arch" type="xml">
374+ <form string="Google login" >
375+ <group colspan="4" col="4" width="300">
376+ <field name="user" />
377+ <newline/>
378+ <label string="ex: user@gmail.com" align="1.0" colspan="2"/>
379+ <newline/>
380+ <field name="password" password="True"/>
381+ </group>
382+ <separator string="" colspan="4"/>
383+ <group colspan="4" col="4">
384+ <group colspan="2"/>
385+ <group colspan="2">
386+ <button special="cancel" string="_Cancel" icon="gtk-cancel"/>
387+ <button name="check_login" string="_Login" type="object" icon="terp-check"/>
388+ </group>
389+ </group>
390+ </form>
391+ </field>
392+ </record>
393+ </data>
394+</openerp>
395
396=== added directory 'sync_google_calendar'
397=== added file 'sync_google_calendar/__init__.py'
398--- sync_google_calendar/__init__.py 1970-01-01 00:00:00 +0000
399+++ sync_google_calendar/__init__.py 2011-03-17 08:46:34 +0000
400@@ -0,0 +1,26 @@
401+# -*- coding: utf-8 -*-
402+##############################################################################
403+#
404+# OpenERP, Open Source Management Solution
405+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
406+#
407+# This program is free software: you can redistribute it and/or modify
408+# it under the terms of the GNU Affero General Public License as
409+# published by the Free Software Foundation, either version 3 of the
410+# License, or (at your option) any later version.
411+#
412+# This program is distributed in the hope that it will be useful,
413+# but WITHOUT ANY WARRANTY; without even the implied warranty of
414+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
415+# GNU Affero General Public License for more details.
416+#
417+# You should have received a copy of the GNU Affero General Public License
418+# along with this program. If not, see <http://www.gnu.org/licenses/>.
419+#
420+##############################################################################
421+
422+import sync_google_calendar
423+import wizard
424+
425+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
426+
427
428=== added file 'sync_google_calendar/__openerp__.py'
429--- sync_google_calendar/__openerp__.py 1970-01-01 00:00:00 +0000
430+++ sync_google_calendar/__openerp__.py 2011-03-17 08:46:34 +0000
431@@ -0,0 +1,38 @@
432+# -*- coding: utf-8 -*-
433+##############################################################################
434+#
435+# OpenERP, Open Source Management Solution
436+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
437+#
438+# This program is free software: you can redistribute it and/or modify
439+# it under the terms of the GNU Affero General Public License as
440+# published by the Free Software Foundation, either version 3 of the
441+# License, or (at your option) any later version.
442+#
443+# This program is distributed in the hope that it will be useful,
444+# but WITHOUT ANY WARRANTY; without even the implied warranty of
445+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
446+# GNU Affero General Public License for more details.
447+#
448+# You should have received a copy of the GNU Affero General Public License
449+# along with this program. If not, see <http://www.gnu.org/licenses/>.
450+#
451+##############################################################################
452+
453+
454+{
455+ 'name': 'Google Calendar',
456+ 'version': '1.0',
457+ 'category': 'Generic Modules/Others',
458+ 'description': """The module adds google calendar events to meetings.""",
459+ 'author': 'OpenERP SA',
460+ 'website': 'http://www.openerp.com',
461+ 'depends': ['base','google_base_account', 'crm'],
462+ 'init_xml': [],
463+ 'update_xml': ['wizard/wizard_import_calendar_events_view.xml', 'sync_google_calendar_view.xml'],
464+ 'demo_xml': [],
465+ 'installable': True,
466+ 'active': False,
467+ 'certificate': '',
468+}
469+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
470
471=== added file 'sync_google_calendar/sync_google_calendar.py'
472--- sync_google_calendar/sync_google_calendar.py 1970-01-01 00:00:00 +0000
473+++ sync_google_calendar/sync_google_calendar.py 2011-03-17 08:46:34 +0000
474@@ -0,0 +1,43 @@
475+# -*- coding: utf-8 -*-
476+##############################################################################
477+#
478+# OpenERP, Open Source Management Solution
479+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
480+#
481+# This program is free software: you can redistribute it and/or modify
482+# it under the terms of the GNU Affero General Public License as
483+# published by the Free Software Foundation, either version 3 of the
484+# License, or (at your option) any later version.
485+#
486+# This program is distributed in the hope that it will be useful,
487+# but WITHOUT ANY WARRANTY; without even the implied warranty of
488+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
489+# GNU Affero General Public License for more details.
490+#
491+# You should have received a copy of the GNU Affero General Public License
492+# along with this program. If not, see <http://www.gnu.org/licenses/>.
493+#
494+##############################################################################
495+
496+from osv import osv, fields
497+
498+class crm_meeting(osv.osv):
499+ _inherit = "crm.meeting"
500+
501+ def unlink(self, cr, uid, ids, context=None):
502+ model_obj = self.pool.get('ir.model.data')
503+ model_ids = model_obj.search(cr, uid, [('res_id','in',ids),('model','=','crm.meeting'),('module','=','sync_google_calendar')], context=context)
504+ model_obj.unlink(cr, uid, model_ids, context=context)
505+ return super(crm_meeting, self).unlink(cr, uid, ids, context=context)
506+
507+crm_meeting()
508+
509+class crm_case_categ(osv.osv):
510+ """ Category of Case """
511+ _inherit = "crm.case.categ"
512+ _columns = {
513+ 'user_id': fields.many2one('res.users', 'User')
514+ }
515+crm_case_categ()
516+
517+# vim:expandtab:smartindent:toabstop=4:softtabstop=4:shiftwidth=4:
518
519=== added file 'sync_google_calendar/sync_google_calendar_view.xml'
520--- sync_google_calendar/sync_google_calendar_view.xml 1970-01-01 00:00:00 +0000
521+++ sync_google_calendar/sync_google_calendar_view.xml 2011-03-17 08:46:34 +0000
522@@ -0,0 +1,32 @@
523+<?xml version="1.0"?>
524+<openerp>
525+ <data>
526+ <record model="ir.ui.view" id="crm_case_form_view_meet_inherit">
527+ <field name="name">CRM - Meetings Form (Inherited)</field>
528+ <field name="model">crm.meeting</field>
529+ <field name="type">form</field>
530+ <field name="inherit_id" ref="crm.crm_case_form_view_meet"/>
531+ <field name="arch" type="xml">
532+ <field name="categ_id" position="replace">
533+ <field name="categ_id" widget="selection"
534+ string="Meeting Type" groups="base.group_extended"
535+ domain="[('object_id.model', '=', 'crm.meeting'),('user_id','in',[uid, False])]" />
536+ </field>
537+ </field>
538+ </record>
539+
540+ <record model="ir.ui.view" id="crm_case_tree_view_meet_inherit">
541+ <field name="name">CRM - Meetings Tree (Inherited)</field>
542+ <field name="model">crm.meeting</field>
543+ <field name="type">tree</field>
544+ <field name="inherit_id" ref="crm.crm_case_tree_view_meet"/>
545+ <field name="arch" type="xml">
546+ <field name="categ_id" position="replace">
547+ <field name="categ_id" widget="selection"
548+ string="Meeting Type" groups="base.group_extended"
549+ domain="[('object_id.model', '=', 'crm.meeting'),('user_id','in',[uid, False])]" />
550+ </field>
551+ </field>
552+ </record>
553+ </data>
554+</openerp>
555\ No newline at end of file
556
557=== added directory 'sync_google_calendar/wizard'
558=== added file 'sync_google_calendar/wizard/__init__.py'
559--- sync_google_calendar/wizard/__init__.py 1970-01-01 00:00:00 +0000
560+++ sync_google_calendar/wizard/__init__.py 2011-03-17 08:46:34 +0000
561@@ -0,0 +1,24 @@
562+# -*- coding: utf-8 -*-
563+##############################################################################
564+#
565+# OpenERP, Open Source Management Solution
566+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
567+#
568+# This program is free software: you can redistribute it and/or modify
569+# it under the terms of the GNU Affero General Public License as
570+# published by the Free Software Foundation, either version 3 of the
571+# License, or (at your option) any later version.
572+#
573+# This program is distributed in the hope that it will be useful,
574+# but WITHOUT ANY WARRANTY; without even the implied warranty of
575+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
576+# GNU Affero General Public License for more details.
577+#
578+# You should have received a copy of the GNU Affero General Public License
579+# along with this program. If not, see <http://www.gnu.org/licenses/>.
580+#
581+##############################################################################
582+
583+import wizard_import_calendar_events
584+
585+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
586
587=== added file 'sync_google_calendar/wizard/wizard_import_calendar_events.py'
588--- sync_google_calendar/wizard/wizard_import_calendar_events.py 1970-01-01 00:00:00 +0000
589+++ sync_google_calendar/wizard/wizard_import_calendar_events.py 2011-03-17 08:46:34 +0000
590@@ -0,0 +1,289 @@
591+# -*- coding: utf-8 -*-
592+##############################################################################
593+#
594+# OpenERP, Open Source Management Solution
595+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
596+#
597+# This program is free software: you can redistribute it and/or modify
598+# it under the terms of the GNU Affero General Public License as
599+# published by the Free Software Foundation, either version 3 of the
600+# License, or (at your option) any later version.
601+#
602+# This program is distributed in the hope that it will be useful,
603+# but WITHOUT ANY WARRANTY; without even the implied warranty of
604+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
605+# GNU Affero General Public License for more details.
606+#
607+# You should have received a copy of the GNU Affero General Public License
608+# along with this program. If not, see <http://www.gnu.org/licenses/>.
609+#
610+##############################################################################
611+
612+from osv import fields,osv
613+from tools.translate import _
614+import tools
615+
616+import time
617+import datetime
618+import dateutil
619+from dateutil.tz import *
620+from dateutil.parser import *
621+from dateutil import parser
622+import re
623+
624+import urllib
625+
626+try:
627+ import gdata
628+ import gdata.calendar.service
629+ import gdata.calendar
630+except ImportError:
631+ raise osv.except_osv(_('Google Contacts Import Error!'), _('Please install gdata-python-client from http://code.google.com/p/gdata-python-client/downloads/list'))
632+
633+def _get_tinydates(self, stime, etime):
634+ stime = dateutil.parser.parse(stime)
635+ etime = dateutil.parser.parse(etime)
636+ try:
637+ au_dt = au_tz.normalize(stime.astimezone(au_tz))
638+ timestring = datetime.datetime(*au_dt.timetuple()[:6]).strftime('%Y-%m-%d %H:%M:%S')
639+ au_dt = au_tz.normalize(etime.astimezone(au_tz))
640+ timestring_end = datetime.datetime(*au_dt.timetuple()[:6]).strftime('%Y-%m-%d %H:%M:%S')
641+ except:
642+ timestring = datetime.datetime(*stime.timetuple()[:6]).strftime('%Y-%m-%d %H:%M:%S')
643+ timestring_end = datetime.datetime(*etime.timetuple()[:6]).strftime('%Y-%m-%d %H:%M:%S')
644+ return (timestring, timestring_end)
645+
646+def _get_rules(self, datas):
647+ new_val = {}
648+ if datas['FREQ'] == 'WEEKLY' and datas.get('BYDAY'):
649+ for day in datas['BYDAY'].split(','):
650+ new_val[day.lower()] = True
651+ datas.pop('BYDAY')
652+
653+ if datas.get('UNTIL'):
654+ until = parser.parse(''.join((re.compile('\d')).findall(datas.get('UNTIL'))))
655+ new_val['end_date'] = until.strftime('%Y-%m-%d')
656+ new_val['end_type'] = 'end_date'
657+ datas.pop('UNTIL')
658+
659+ if datas.get('COUNT'):
660+ new_val['count'] = datas.get('COUNT')
661+ new_val['end_type'] = 'count'
662+ datas.pop('COUNT')
663+
664+ if datas.get('INTERVAL'):
665+ new_val['interval'] = datas.get('INTERVAL')
666+ datas.pop('INTERVAL')
667+
668+ if datas.get('BYMONTHDAY'):
669+ new_val['day'] = datas.get('BYMONTHDAY')
670+ datas.pop('BYMONTHDAY')
671+ new_val['select1'] = 'date'
672+
673+ if datas.get('BYDAY'):
674+ d = datas.get('BYDAY')
675+ if '-' in d:
676+ new_val['byday'] = d[:2]
677+ new_val['week_list'] = d[2:4].upper()
678+ else:
679+ new_val['byday'] = d[:1]
680+ new_val['week_list'] = d[1:3].upper()
681+ new_val['select1'] = 'day'
682+
683+ if datas.get('BYMONTH'):
684+ new_val['month_list'] = datas.get('BYMONTH')
685+ datas.pop('bymonth')
686+ return new_val
687+
688+def _get_repeat_status(self, str_google):
689+ rrule = str_google[str_google.find('FREQ'):str_google.find('\nBEGIN')]
690+ status = {}
691+ for rule in rrule.split(';'):
692+ status[rule.split('=')[0]] = rule.split('=')[-1:] and rule.split('=')[-1:][0] or ''
693+ rules = _get_rules(self, status)
694+ if status.get('FREQ') == 'WEEKLY':
695+ status.update({'rrule_type': 'weekly'})
696+ status.pop('FREQ')
697+ elif status.get('FREQ') == 'DAILY':
698+ status.update({'rrule_type': 'daily'})
699+ status.pop('FREQ')
700+ elif status.get('FREQ') == 'MONTHLY':
701+ status.update({'rrule_type': 'monthly'})
702+ status.pop('FREQ')
703+ elif status.get('FREQ') == 'YEARLY':
704+ status.update({'rrule_type': 'yearly'})
705+ status.pop('FREQ')
706+ status.update(rules)
707+ return status
708+
709+def _get_repeat_dates(self, x):
710+ if x[3].startswith('BY'):
711+ zone_time = x[4].split('+')[-1:][0].split(':')[0][:4]
712+ else:
713+ zone_time = x[3].split('+')[-1:][0].split(':')[0][:4]
714+ tz_format = zone_time[:2]+':'+zone_time[2:]
715+ repeat_start = x[1].split('\n')[0].split(':')[1]
716+ repeat_end = x[2].split('\n')[0].split(':')[1]
717+ o = repeat_start.split('T')
718+ repeat_start = str(o[0][:4]) + '-' + str(o[0][4:6]) + '-' + str(o[0][6:8])
719+ if len(o) == 2:
720+ repeat_start += ' ' + str(o[1][:2]) + ':' + str(o[1][2:4]) + ':' + str(o[1][4:6])
721+ else:
722+ repeat_start += ' ' + '00' + ':' + '00' + ':' + '00'
723+ p = repeat_end.split('T')
724+ repeat_end = str(p[0][:4]) + '-' + str(p[0][4:6]) + '-' + str(p[0][6:8])
725+ if len(p) == 2:
726+ repeat_end += ' ' + str(p[1][:2]) + ':' + str(p[1][2:4]) + ':' + str(p[1][4:6])
727+ else:
728+ repeat_end += ' ' + '00' + ':' + '00' + ':' + '00'
729+ return (repeat_start, repeat_end, tz_format)
730+
731+class google_login(osv.osv_memory):
732+ _inherit = 'google.login'
733+ _name = 'google.login'
734+
735+ def _get_next_action(self, cr, uid, context=None):
736+ data_obj = self.pool.get('ir.model.data')
737+ data_id = data_obj._get_id(cr, uid, 'sync_google_calendar', 'view_synchronize_google_calendar_import_form')
738+ view_id = False
739+ if data_id:
740+ view_id = data_obj.browse(cr, uid, data_id, context=context).res_id
741+ value = {
742+ 'name': _('Import Events'),
743+ 'view_type': 'form',
744+ 'view_mode': 'form,tree',
745+ 'res_model': 'synchronize.google.calendar',
746+ 'view_id': False,
747+ 'context': context,
748+ 'views': [(view_id, 'form')],
749+ 'type': 'ir.actions.act_window',
750+ 'target': 'new',
751+ }
752+ return value
753+
754+google_login()
755+
756+class synchronize_google_calendar_events(osv.osv_memory):
757+ _name = 'synchronize.google.calendar'
758+
759+ def _get_calendars(self, cr, uid, context=None):
760+ user_obj = self.pool.get('res.users').browse(cr, uid, uid)
761+ google = self.pool.get('google.login')
762+ res = []
763+ try:
764+ gd_client = google.google_login(cr, uid, user_obj.gmail_user, user_obj.gmail_password, type='calendar')
765+ calendars = gd_client.GetAllCalendarsFeed()
766+ for cal in calendars.entry:
767+ res.append((cal.id.text, cal.title.text))
768+ except Exception, e:
769+ raise osv.except_osv('Error !', e)
770+ res.append(('all','All Calendars'))
771+ return res
772+
773+ _columns = {
774+ 'calendar_name': fields.selection(_get_calendars, "Calendar Name", size=32),
775+ }
776+
777+ _defaults = {
778+ 'calendar_name': 'all',
779+ }
780+
781+ def get_events(self, cr, uid, event_feed, context=None):
782+ meeting_obj = self.pool.get('crm.meeting')
783+ categ_obj = self.pool.get('crm.case.categ')
784+ model_obj = self.pool.get('ir.model.data')
785+ object_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'crm.meeting')])
786+ meeting_ids = []
787+ categ_id = categ_obj.search(cr, uid, [('name','=',event_feed.title.text),('object_id','=',object_id and object_id[0]),('user_id','=',uid)])
788+ if not categ_id:
789+ categ_id.append(categ_obj.create(cr, uid, {'name': event_feed.title.text,
790+ 'object_id': object_id and object_id[0],
791+ 'user_id': uid }))
792+ for feed in event_feed.entry:
793+ google_id = feed.id.text
794+ model_data = {
795+ 'name': google_id,
796+ 'model': 'crm.meeting',
797+ 'module': 'sync_google_calendar',
798+ 'noupdate': True
799+ }
800+ vals = {
801+ 'name': feed.title.text or '(No title)',
802+ 'description': feed.content.text,
803+ 'categ_id': categ_id and categ_id[0]
804+ }
805+ if feed.when:
806+ timestring, timestring_end = _get_tinydates(self, feed.when[0].start_time, feed.when[0].end_time)
807+ else:
808+ x = feed.recurrence.text.split(';')
809+ repeat_status = _get_repeat_status(self, feed.recurrence.text)
810+ repeat_start, repeat_end, zone_time = _get_repeat_dates(self, x)
811+ timestring = time.strftime('%Y-%m-%d %H:%M:%S', time.strptime(repeat_start, "%Y-%m-%d %H:%M:%S"))
812+ timestring_end = time.strftime('%Y-%m-%d %H:%M:%S', time.strptime(repeat_end, "%Y-%m-%d %H:%M:%S"))
813+ if repeat_status:
814+ repeat_status.update({'recurrency': True})
815+ vals.update(repeat_status)
816+
817+ vals.update({'date': timestring, 'date_deadline': timestring_end})
818+ data_ids = model_obj.search(cr, uid, [('model','=','crm.meeting'), ('name','=',google_id)])
819+ if data_ids:
820+ res_id = model_obj.browse(cr, uid, data_ids[0], context=context).res_id
821+ meeting_ids.append(res_id)
822+ meeting_obj.write(cr, uid, [res_id], vals, context=context)
823+ else:
824+ res_id = meeting_obj.create(cr, uid, vals, context=context)
825+ meeting_ids.append(res_id)
826+ model_data.update({'res_id': res_id})
827+ model_obj.create(cr, uid, model_data, context=context)
828+ return meeting_ids
829+
830+ def import_calendar_events(self, cr, uid, ids, context=None):
831+ obj = self.browse(cr, uid, ids, context=context)[0]
832+ if not ids:
833+ return { 'type': 'ir.actions.act_window_close' }
834+
835+ user_obj = self.pool.get('res.users').browse(cr, uid, uid)
836+ gmail_user = user_obj.gmail_user
837+ gamil_pwd = user_obj.gmail_password
838+
839+ google = self.pool.get('google.login')
840+ gd_client = google.google_login(cr, uid, gmail_user, gamil_pwd, type='calendar')
841+
842+ if not gmail_user or not gamil_pwd:
843+ raise osv.except_osv(_('Error'), _("Please specify the user and password !"))
844+
845+ meetings = []
846+ if obj.calendar_name != 'all':
847+ events_query = gdata.calendar.service.CalendarEventQuery(user=urllib.unquote(obj.calendar_name.split('/')[~0]))
848+ events_query.start_index = 1
849+ events_query.max_results = 1000
850+ event_feed = gd_client.GetCalendarEventFeed(events_query.ToUri())
851+ meetings.append(self.get_events(cr, uid, event_feed, context=context))
852+ else:
853+ calendars = map(lambda x:x[0], [cal for cal in self._get_calendars(cr, uid, context) if cal[0] != 'all'])
854+ for cal in calendars:
855+ events_query = gdata.calendar.service.CalendarEventQuery(user=urllib.unquote(cal.split('/')[~0]))
856+ events_query.start_index = 1
857+ events_query.max_results = 1000
858+ event_feed = gd_client.GetCalendarEventFeed(events_query.ToUri())
859+ meetings.append(self.get_events(cr, uid, event_feed, context=context))
860+
861+ meeting_ids = []
862+ for meeting in meetings:
863+ meeting_ids += meeting
864+
865+ return {
866+ 'name': _('Meetings'),
867+ 'domain': "[('id','in', ["+','.join(map(str,meeting_ids))+"])]",
868+ 'view_type': 'form',
869+ 'view_mode': 'tree,form',
870+ 'res_model': 'crm.meeting',
871+ 'context': context,
872+ 'views': [(False, 'calendar'),(False, 'tree'),(False, 'form')],
873+ 'type': 'ir.actions.act_window',
874+ }
875+
876+synchronize_google_calendar_events()
877+
878+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
879+
880
881=== added file 'sync_google_calendar/wizard/wizard_import_calendar_events_view.xml'
882--- sync_google_calendar/wizard/wizard_import_calendar_events_view.xml 1970-01-01 00:00:00 +0000
883+++ sync_google_calendar/wizard/wizard_import_calendar_events_view.xml 2011-03-17 08:46:34 +0000
884@@ -0,0 +1,45 @@
885+<?xml version="1.0"?>
886+<openerp>
887+ <data>
888+ <record model="ir.ui.view" id="view_synchronize_google_calendar_import_form">
889+ <field name="name">synchronize.google.calendar.form</field>
890+ <field name="model">synchronize.google.calendar</field>
891+ <field name="type">form</field>
892+ <field name="arch" type="xml">
893+ <form string="Import Google Calendar Events">
894+ <group colspan="4" col="4">
895+ <field name="calendar_name" />
896+ </group>
897+ <separator string="" colspan="4"/>
898+ <group colspan="4" col="4">
899+ <group colspan="2" col="2"/>
900+ <group colspan="2" col="2">
901+ <button special="cancel" string="_Cancel" icon="gtk-cancel"/>
902+ <button name="import_calendar_events" string="_Import Events" type="object" icon="terp-calendar"/>
903+ </group>
904+ </group>
905+ </form>
906+ </field>
907+ </record>
908+
909+
910+ <!--
911+ Login Action
912+ -->
913+ <record model="ir.actions.act_window" id="act_google_login_form">
914+ <field name="name">Import google calendar events</field>
915+ <field name="type">ir.actions.act_window</field>
916+ <field name="res_model">google.login</field>
917+ <field name="view_type">form</field>
918+ <field name="view_mode">form</field>
919+ <field name="target">new</field>
920+ <field name="view_id" ref="google_base_account.view_google_login_form" />
921+ </record>
922+
923+
924+ <menuitem id="menu_sync_contact"
925+ parent="crm.menu_meeting_sale"
926+ action="act_google_login_form"
927+ sequence="20" />
928+ </data>
929+</openerp>

Subscribers

People subscribed via source and target branches

to all changes: