Merge lp:~therp-nl/eficent-openerp-project-management/6.1-mig_project_communications_mailgate into lp:eficent-openerp-project-management/6.1

Proposed by Stefan Rijnhart (Opener)
Status: Work in progress
Proposed branch: lp:~therp-nl/eficent-openerp-project-management/6.1-mig_project_communications_mailgate
Merge into: lp:eficent-openerp-project-management/6.1
Diff against target: 490 lines (+84/-168)
14 files modified
project_category/analytic_account_category.py (+2/-2)
project_communications_mailgate/__init__.py (+2/-2)
project_communications_mailgate/__openerp__.py (+1/-1)
project_communications_mailgate/project.py (+31/-36)
project_communications_mailgate/project_communications_mailgate.py (+20/-100)
project_communications_mailgate/security/ir.model.access.csv (+0/-3)
project_cost/account_analytic_account.py (+8/-4)
project_cost_plan_purchase/account_analytic_line_plan.py (+4/-4)
project_cost_plan_sale/account_analytic_line_plan.py (+4/-4)
project_hr_stakeholder/project_hr_stakeholder.py (+1/-1)
project_invoice/invoice.py (+1/-1)
project_procurement/purchase_requisition.py (+2/-2)
project_scope_wbs/project_scope_wbs.py (+7/-7)
project_time_sequence/project_time_sequence.py (+1/-1)
To merge this branch: bzr merge lp:~therp-nl/eficent-openerp-project-management/6.1-mig_project_communications_mailgate
Reviewer Review Type Date Requested Status
Eficent Pending
Review via email: mp+141932@code.launchpad.net

Description of the change

Work in progress, not yet tested.

To post a comment you must log in.

Unmerged revisions

10. By Stefan Rijnhart (Opener)

[MIG] Adapt project_communications_mailgate to new mail module

9. By Stefan Rijnhart (Opener)

[FIX] Remove mutable defaults from function arguments

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'project_category/analytic_account_category.py'
2--- project_category/analytic_account_category.py 2012-10-18 23:30:03 +0000
3+++ project_category/analytic_account_category.py 2013-01-04 15:10:41 +0000
4@@ -40,7 +40,7 @@
5 def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):
6 if not args:
7 args=[]
8- if not context:
9+ if context is None:
10 context={}
11 if name:
12 # Be sure name_search is symetric to name_get
13@@ -77,4 +77,4 @@
14 _parent_order = 'name'
15 _order = 'parent_left'
16
17-analytic_account_category()
18\ No newline at end of file
19+analytic_account_category()
20
21=== modified file 'project_communications_mailgate/__init__.py'
22--- project_communications_mailgate/__init__.py 2012-10-02 20:55:15 +0000
23+++ project_communications_mailgate/__init__.py 2013-01-04 15:10:41 +0000
24@@ -1,8 +1,8 @@
25 # -*- coding: utf-8 -*-
26 ##############################################################################
27 #
28-# OpenERP, Open Source Management Solution
29-# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
30+# Copyright (C) 2011 Eficent (<http://www.eficent.com/>)
31+# Jordi Ballester Alomar <jordi.ballester@eficent.com>
32 #
33 # This program is free software: you can redistribute it and/or modify
34 # it under the terms of the GNU Affero General Public License as
35
36=== modified file 'project_communications_mailgate/__openerp__.py'
37--- project_communications_mailgate/__openerp__.py 2012-10-02 20:55:15 +0000
38+++ project_communications_mailgate/__openerp__.py 2013-01-04 15:10:41 +0000
39@@ -26,7 +26,7 @@
40 "author": "Jordi Ballester (Eficent)",
41 "website": "http://www.eficent.com",
42 "category": "Generic Modules/Projects & Services",
43- "depends": ["project", "mail_gateway"],
44+ "depends": ["project", "mail"],
45 "description": """This module is an interface that synchronises mails with OpenERP Project.
46
47 It allows updating projects as soon as a new mail arrives in our configured mail server.
48
49=== modified file 'project_communications_mailgate/project.py'
50--- project_communications_mailgate/project.py 2012-10-02 20:55:15 +0000
51+++ project_communications_mailgate/project.py 2013-01-04 15:10:41 +0000
52@@ -19,45 +19,40 @@
53 #
54 ##############################################################################
55
56-import tools
57-from osv import fields, osv
58-from tools.translate import _
59+from openerp.osv import orm
60+from openerp.tools.translate import _
61
62
63-class project(osv.osv):
64+class project(orm.Model):
65
66 _inherit = "project.project"
67
68- def set_draft(self, cr, uid, ids, *args, **kwargs):
69- res = super(project, self).set_draft(cr, uid, ids, *args, **kwargs)
70- projects = self.browse(cr, uid, ids)
71- self._history(cr, uid, projects, _('Draft'))
72- return res
73-
74- def set_open(self, cr, uid, ids, *args, **kwargs):
75- res = super(project, self).set_open(cr, uid, ids, *args, **kwargs)
76- projects = self.browse(cr, uid, ids)
77- self._history(cr, uid, projects, _('Open'))
78- return res
79-
80- def set_pending(self, cr, uid, ids, *args, **kwargs):
81- res = super(project, self).set_pending(cr, uid, ids, *args, **kwargs)
82- projects = self.browse(cr, uid, ids)
83- self._history(cr, uid, projects, _('Pending'))
84- return res
85-
86- def set_done(self, cr, uid, ids, *args, **kwargs):
87- res = super(project, self).set_done(cr, uid, ids, *args, **kwargs)
88- projects = self.browse(cr, uid, ids)
89- self._history(cr, uid, projects, _('Done'))
90- return res
91-
92- def set_cancel(self, cr, uid, ids, *args, **kwargs):
93- res = super(project, self).set_cancel(cr, uid, ids, *args, **kwargs)
94- projects = self.browse(cr, uid, ids)
95- self._history(cr, uid, projects, _('Cancel'))
96+ def set_draft(self, cr, uid, ids, context=None):
97+ res = super(project, self).set_draft(cr, uid, ids, context=context)
98+ projects = self.browse(cr, uid, ids, context=context)
99+ self.message_append(cr, uid, projects, _('Draft'), context=context)
100+ return res
101+
102+ def set_open(self, cr, uid, ids, context=None):
103+ res = super(project, self).set_open(cr, uid, ids, context=context)
104+ projects = self.browse(cr, uid, ids, context=context)
105+ self.message_append(cr, uid, projects, _('Open'), context=context)
106+ return res
107+
108+ def set_pending(self, cr, uid, ids, context=None):
109+ res = super(project, self).set_pending(cr, uid, ids, context=context)
110+ projects = self.browse(cr, uid, ids, context=context)
111+ self.message_append(cr, uid, projects, _('Pending'), context=context)
112+ return res
113+
114+ def set_done(self, cr, uid, ids, context=None):
115+ res = super(project, self).set_done(cr, uid, ids, context=context)
116+ projects = self.browse(cr, uid, ids, context=context)
117+ self.message_append(cr, uid, projects, _('Done'), context=context)
118+ return res
119+
120+ def set_cancel(self, cr, uid, ids, context=None):
121+ res = super(project, self).set_cancel(cr, uid, ids, context=context)
122+ projects = self.browse(cr, uid, ids, context=context)
123+ self.message_append(cr, uid, projects, _('Cancel'), context=context)
124 return res
125-
126-
127-project()
128-
129
130=== modified file 'project_communications_mailgate/project_communications_mailgate.py'
131--- project_communications_mailgate/project_communications_mailgate.py 2012-10-02 20:55:15 +0000
132+++ project_communications_mailgate/project_communications_mailgate.py 2013-01-04 15:10:41 +0000
133@@ -19,110 +19,30 @@
134 #
135 ##############################################################################
136
137-from osv import fields,osv
138-from tools.translate import _
139-import binascii
140-
141-
142-class project_communications_mailgate(osv.osv):
143+from openerp.osv import fields, orm
144+
145+
146+class project_communications_mailgate(orm.Model):
147 _name = "project.project"
148- _inherit = ['mailgate.thread','project.project']
149+ _inherit = ['mail.thread','project.project']
150
151 _columns={
152- 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)], readonly=True),
153- }
154-
155- def message_new(self, cr, uid, msg, context=None):
156-# """
157-# Automatically calls when new email message arrives
158-#
159-# @param self: The object pointer
160-# @param cr: the current row, from the database cursor,
161-# @param uid: the current user’s ID for security checks
162-# """
163+ 'message_ids': fields.one2many(
164+ 'mail.message', 'res_id', 'Messages',
165+ domain=[('model','=',_name)], readonly=True),
166+ }
167+
168+ def message_thread_followers(self, cr, uid, ids, context=None):
169+ if not ids:
170+ return {}
171+ if isinstance(ids, (int, long)):
172+ ids = [ids]
173 res = {}
174-# mailgate_obj = self.pool.get('email.server.tools')
175-# subject = msg.get('subject')
176-# body = msg.get('body')
177-# msg_from = msg.get('from')
178-# priority = msg.get('priority')
179-
180-# data = {
181-# 'name': subject,
182-# 'description': body,
183-# }
184-# res = mailgate_obj.get_partner(cr, uid, msg_from)
185-# if res:
186-# data.update(res)
187-# res = self.create(cr, uid, data)
188-
189-# attachments = msg.get('attachments', [])
190-# for attachment in attachments or []:
191-# data_attach = {
192-# 'name': attachment,
193-# 'datas':binascii.b2a_base64(str(attachments.get(attachment))),
194-# 'datas_fname': attachment,
195-# 'description': 'Mail attachment',
196-# 'res_model': self._name,
197-# 'res_id': res,
198-# }
199-# self.pool.get('ir.attachment').create(cr, uid, data_attach)
200-#
201- return res
202-
203- def message_update(self, cr, uid, id, msg, data={}, context=None):
204- mailgate_obj = self.pool.get('email.server.tools')
205- subject = data.get('subject')
206- body = data.get('body')
207- msg_from = data.get('from')
208- msg_to = data.get('to')
209- priority = data.get('priority')
210- attachments = data.get('attachments', [])
211-
212-# msg_actions, body_data = mailgate_obj.msg_act_get(msg)
213-# data.update({
214-# 'description': body_data,
215-# })
216-# act = 'do_'+default_act
217-# if 'state' in msg_actions:
218-# if msg_actions['state'] in ['draft','close','cancel','open','pending']:
219-# act = 'do_' + msg_actions['state']
220-
221-# if 'priority' in msg_actions:
222-# if msg_actions['priority'] in ('1','2','3','4','5'):
223-# data['priority'] = msg_actions['priority']
224-#
225-# self.write(cr, uid, [id], data)
226- msg_dict = {'new': 'Send', 'reply': 'Reply', 'forward': 'Forward'}
227- self._history(cr, uid, id, _(msg_dict['new']), history=True, subject=subject, email=msg_to, details=body, email_from=msg_from, message_id=None, attach=attachments)
228-# getattr(self,act)(cr, uid, [id])
229- return {}
230-
231- def message_followers(self, cr, uid, ids, context=None):
232- res = []
233- if isinstance(ids, (str, int, long)):
234- select = [ids]
235- else:
236- select = ids
237- for project in self.browse(cr, uid, select, context=context):
238- user_email = (project.user_id and project.user_id.address_id and project.user_id.address_id.email) or False
239- res += [(user_email, False, False, project.priority)]
240- if isinstance(ids, (str, int, long)):
241- return len(res) and res[0] or False
242+ for project in self.browse(cr, uid, ids, context=context):
243+ user_email = (project.user_id and project.user_id.address_id
244+ and project.user_id.address_id.email) or False
245+ if user_email:
246+ res.setdefault(project.id, []).append(user_email)
247 return res
248
249- def msg_send(self, cr, uid, id, *args, **argv):
250- return True
251-
252- def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, email_from=False, message_id=False, attach=[], context=None):
253- mailgate_pool = self.pool.get('mailgate.thread')
254- return mailgate_pool.history(cr, uid, cases, keyword, history=history,\
255- subject=subject, email=email, \
256- details=details, email_from=email_from,\
257- message_id=message_id, attach=attach, \
258- context=context)
259-
260-
261-project_communications_mailgate()
262-
263 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
264
265=== removed directory 'project_communications_mailgate/security'
266=== removed file 'project_communications_mailgate/security/ir.model.access.csv'
267--- project_communications_mailgate/security/ir.model.access.csv 2012-10-02 20:55:15 +0000
268+++ project_communications_mailgate/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
269@@ -1,3 +0,0 @@
270-"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
271-"access_project_communications_mailgate_message_project_manager","project.mailgate.message.manager","mail_gateway.model_mailgate_message","project.group_project_manager",1,1,1,1
272-"access_project_communications_mailgate_message_project_user","project.mailgate.message.user","mail_gateway.model_mailgate_message","project.group_project_user",1,1,1,1
273
274=== modified file 'project_cost/account_analytic_account.py'
275--- project_cost/account_analytic_account.py 2012-10-02 20:55:15 +0000
276+++ project_cost/account_analytic_account.py 2013-01-04 15:10:41 +0000
277@@ -33,7 +33,9 @@
278 _inherit = 'account.analytic.account'
279
280 def _compute_level_tree_plan(self, cr, uid, ids, child_ids, res, field_names, context=None):
281- def recursive_computation(account_id, res, repeated_account_ids=[]):
282+ def recursive_computation(account_id, res, repeated_account_ids=None):
283+ if repeated_account_ids is None:
284+ repeated_account_ids = []
285 currency_obj = self.pool.get('res.currency')
286 account = self.browse(cr, uid, account_id)
287 for son in account.child_ids:
288@@ -54,7 +56,9 @@
289 return res
290
291 def _compute_level_tree_commit(self, cr, uid, ids, child_ids, res, field_names, context=None):
292- def recursive_computation(account_id, res, repeated_account_ids=[]):
293+ def recursive_computation(account_id, res, repeated_account_ids=None):
294+ if repeated_account_ids is None:
295+ repeated_account_ids = []
296 currency_obj = self.pool.get('res.currency')
297 account = self.browse(cr, uid, account_id)
298 for son in account.child_ids:
299@@ -200,11 +204,11 @@
300 return True
301
302 def copy(self, cr, uid, id, default=None, context=None):
303- if not default:
304+ if default is None:
305 default = {}
306 default['plan_line_ids'] = []
307 default['commit_line_ids'] = []
308 return super(account_analytic_account, self).copy(cr, uid, id, default, context=context)
309
310
311-account_analytic_account()
312\ No newline at end of file
313+account_analytic_account()
314
315=== modified file 'project_cost_plan_purchase/account_analytic_line_plan.py'
316--- project_cost_plan_purchase/account_analytic_line_plan.py 2012-10-02 20:55:15 +0000
317+++ project_cost_plan_purchase/account_analytic_line_plan.py 2013-01-04 15:10:41 +0000
318@@ -43,23 +43,23 @@
319 }
320
321
322- def copy(self, cr, uid, id, default={}, context=None):
323+ def copy(self, cr, uid, id, default=None, context=None):
324 if context is None:
325 context = {}
326
327- if not default:
328+ if default is None:
329 default = {}
330
331 default['purchase_line_id'] = False
332
333 return super(account_analytic_line_plan, self).copy(cr, uid, id, default, context)
334
335- def copy_data(self, cr, uid, id, default={}, context=None):
336+ def copy_data(self, cr, uid, id, default=None, context=None):
337
338 if context is None:
339 context = {}
340
341- if not default:
342+ if default is None:
343 default = {}
344
345 default['purchase_line_id'] = False
346
347=== modified file 'project_cost_plan_sale/account_analytic_line_plan.py'
348--- project_cost_plan_sale/account_analytic_line_plan.py 2012-10-02 20:55:15 +0000
349+++ project_cost_plan_sale/account_analytic_line_plan.py 2013-01-04 15:10:41 +0000
350@@ -43,11 +43,11 @@
351 }
352
353
354- def copy(self, cr, uid, id, default={}, context=None):
355+ def copy(self, cr, uid, id, default=None, context=None):
356 if context is None:
357 context = {}
358
359- if not default:
360+ if default is None:
361 default = {}
362
363 default['sale_line_id'] = False
364@@ -55,11 +55,11 @@
365 res = super(account_analytic_line_plan, self).copy(cr, uid, id, default, context)
366 return res
367
368- def copy_data(self, cr, uid, id, default={}, context=None):
369+ def copy_data(self, cr, uid, id, default=None, context=None):
370
371 if context is None:
372 context = {}
373- if not default:
374+ if default is None:
375 default = {}
376
377 default['sale_line_id'] = False
378
379=== modified file 'project_hr_stakeholder/project_hr_stakeholder.py'
380--- project_hr_stakeholder/project_hr_stakeholder.py 2012-10-02 20:55:15 +0000
381+++ project_hr_stakeholder/project_hr_stakeholder.py 2013-01-04 15:10:41 +0000
382@@ -106,7 +106,7 @@
383
384 }
385
386- def name_get(self, cr, uid, ids, context={}):
387+ def name_get(self, cr, uid, ids, context=None):
388 if not ids:
389 return []
390 res = []
391
392=== modified file 'project_invoice/invoice.py'
393--- project_invoice/invoice.py 2012-10-02 20:55:15 +0000
394+++ project_invoice/invoice.py 2013-01-04 15:10:41 +0000
395@@ -32,7 +32,7 @@
396 class account_invoice(osv.osv):
397 _inherit = "account.invoice"
398
399- def _line_analytic_accounts_get(self, cr, uid, ids, field_name, arg, context={}):
400+ def _line_analytic_accounts_get(self, cr, uid, ids, field_name, arg, context=None):
401 result = {}
402 for inv in self.browse(cr, uid, ids, context):
403 str_data = ''
404
405=== modified file 'project_procurement/purchase_requisition.py'
406--- project_procurement/purchase_requisition.py 2012-10-02 20:55:15 +0000
407+++ project_procurement/purchase_requisition.py 2013-01-04 15:10:41 +0000
408@@ -25,8 +25,8 @@
409 class purchase_requisition(osv.osv):
410 _inherit = "purchase.requisition"
411
412- def copy_data(self, cr, uid, id, default={}, context=None):
413- if not default:
414+ def copy_data(self, cr, uid, id, default=None, context=None):
415+ if default is None:
416 default = {}
417 default.update({
418 'state':'draft',
419
420=== modified file 'project_scope_wbs/project_scope_wbs.py'
421--- project_scope_wbs/project_scope_wbs.py 2012-12-13 04:18:54 +0000
422+++ project_scope_wbs/project_scope_wbs.py 2013-01-04 15:10:41 +0000
423@@ -29,7 +29,7 @@
424 class task(osv.osv):
425 _inherit = 'project.task'
426
427- def _project_complete_wbs_name(self, cr, uid, ids, prop, unknow_none, unknow_dict):
428+ def _project_complete_wbs_name(self, cr, uid, ids, prop, unknow_none, context=None):
429
430 if not ids:
431 return []
432@@ -45,14 +45,14 @@
433 for task in tasks:
434 if task.project_id:
435 task_project_id = task.project_id.id
436- data_project = project_obj.read(cr, uid, task_project_id, ['complete_wbs_name'], context=[])
437+ data_project = project_obj.read(cr, uid, task_project_id, ['complete_wbs_name'], context=context)
438 if data_project:
439 res.append((task.id, data_project['complete_wbs_name']))
440 else:
441 res.append((task.id, ''))
442 return dict(res)
443
444- def _project_complete_wbs_code(self, cr, uid, ids, prop, unknow_none, unknow_dict):
445+ def _project_complete_wbs_code(self, cr, uid, ids, prop, unknow_none, context=None):
446
447 if not ids:
448 return []
449@@ -68,7 +68,7 @@
450 for task in tasks:
451 if task.project_id:
452 task_project_id = task.project_id.id
453- data_project = project_obj.read(cr, uid, task_project_id, ['complete_wbs_code'], context=[])
454+ data_project = project_obj.read(cr, uid, task_project_id, ['complete_wbs_code'], context=context)
455 if data_project:
456 res.append((task.id, data_project['complete_wbs_code']))
457 else:
458@@ -81,11 +81,11 @@
459 _columns = {
460 'project_complete_wbs_name': fields.function(_project_complete_wbs_name, method=True, type='char', string='WBS path name', size=250, help='Project Complete WBS path name',
461 store={
462- 'project.task': (lambda self, cr, uid, ids, c={}: ids, ['project_id'], 10),
463+ 'project.task': (lambda self, cr, uid, ids, c=None: ids, ['project_id'], 10),
464 }),
465 'project_complete_wbs_code': fields.function(_project_complete_wbs_code, method=True, type='char', string='WBS path code', size=250, help='Project Complete WBS path code',
466 store={
467- 'project.task': (lambda self, cr, uid, ids, c={}: ids, ['project_id'], 10),
468+ 'project.task': (lambda self, cr, uid, ids, c=None: ids, ['project_id'], 10),
469 }),
470
471 }
472@@ -327,4 +327,4 @@
473
474 project()
475
476-
477\ No newline at end of file
478+
479
480=== modified file 'project_time_sequence/project_time_sequence.py'
481--- project_time_sequence/project_time_sequence.py 2012-10-02 20:55:15 +0000
482+++ project_time_sequence/project_time_sequence.py 2013-01-04 15:10:41 +0000
483@@ -112,7 +112,7 @@
484
485 }
486
487- def do_link_predecessors(self, cr, uid, task_id, link_predecessors_data={}, context=None):
488+ def do_link_predecessors(self, cr, uid, task_id, link_predecessors_data, context=None):
489
490 task_br = self.browse(cr, uid, task_id, context=context)
491

Subscribers

People subscribed via source and target branches

to all changes: