Thibault Delavallée (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-mail_subtype-atp into
lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-mail_subtype-atp/+merge/132707
Message subtypes: project and project_issue improvements.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-mail_subtype-atp/+merge/132707
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-mail_subtype-atp.
=== modified file 'mail/mail_message_subtype.py'
--- mail/mail_message_subtype.py 2012-10-02 20:40:23 +0000
+++ mail/mail_message_subtype.py 2012-11-02 15:13:24 +0000
@@ -31,14 +31,15 @@
_description = 'mail_message_subtype'
_columns = {
'name': fields.char('Message Type', required=True, translate=True,
- help='Message subtype, gives a more precise type on the message, '\
+ help='Message subtype gives a more precise type on the message, '\
'especially for system notifications. For example, it can be '\
'a notification related to a new record (New), or to a stage '\
'change in a process (Stage change). Message subtypes allow to '\
'precisely tune the notifications the user want to receive on its wall.'),
- 'res_model': fields.char('Model', help="link subtype to model"),
+ 'res_model': fields.char('Model',
+ help="Related model of the subtype. If False, this subtype exists for all models."),
'default': fields.boolean('Default',
- help="When subscribing to the document, this subtype will be checked by default."),
+ help="Checked by default when subscribing."),
}
_defaults = {
'default': True,
=== modified file 'project/project.py'
--- project/project.py 2012-11-02 08:08:36 +0000
+++ project/project.py 2012-11-02 15:13:24 +0000
@@ -1132,9 +1132,17 @@
def create(self, cr, uid, vals, context=None):
task_id = super(task, self).create(cr, uid, vals, context=context)
task_record = self.browse(cr, uid, task_id, context=context)
+ project_obj = self.pool.get("project.project")
+ subtype_obj = self.pool.get('mail.message.subtype')
+ subtype_ids = []
if task_record.project_id:
+ project_subtype = task_record.project_id.message_subtype_data
+ for key in project_subtype:
+ subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', 'ilike', key)], context=context)
+ if subtype_ids:
+ subtype_obj.write(cr,uid, subtype_ids, {'default': project_subtype[key]['default']},context=context)
project_follower_ids = [follower.id for follower in task_record.project_id.message_follower_ids]
- self.message_subscribe(cr, uid, [task_id], project_follower_ids,
+ self.message_subscribe(cr, uid, [task_id], project_follower_ids, subtype_ids = subtype_ids,
context=context)
self._store_history(cr, uid, [task_id], context=context)
self.create_send_note(cr, uid, [task_id], context=context)
@@ -1145,9 +1153,15 @@
def write(self, cr, uid, ids, vals, context=None):
if isinstance(ids, (int, long)):
ids = [ids]
+ project_obj = self.pool.get("project.project")
+ subtype_obj = self.pool.get('mail.message.subtype')
if vals.get('project_id'):
- project_id = self.pool.get('project.project').browse(cr, uid, vals.get('project_id'), context=context)
+ project_id = project_obj.browse(cr, uid, vals.get('project_id'), context=context)
vals['message_follower_ids'] = [(4, follower.id) for follower in project_id.message_follower_ids]
+ for key in project_id.message_subtype_data:
+ subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', '=', key)], context=context)
+ if subtype_ids:
+ subtype_obj.write(cr,uid, subtype_ids, {'default': project_id.message_subtype_data[key]['default']},context=context)
if vals and not 'kanban_state' in vals and 'stage_id' in vals:
new_stage = vals.get('stage_id')
vals_reset_kstate = dict(vals, kanban_state='normal')
=== modified file 'project_issue/project_issue.py'
--- project_issue/project_issue.py 2012-10-30 12:44:05 +0000
+++ project_issue/project_issue.py 2012-11-02 15:13:24 +0000
@@ -362,10 +362,19 @@
def write(self, cr, uid, ids, vals, context=None):
#Update last action date every time the user change the stage, the state or send a new email
logged_fields = ['stage_id', 'state', 'message_ids']
+ subtype_obj = self.pool.get('mail.message.subtype')
+ name = False
if any([field in vals for field in logged_fields]):
vals['date_action_last'] = time.strftime('%Y-%m-%d %H:%M:%S')
if vals.get('project_id'):
project_id = self.pool.get('project.project').browse(cr, uid, vals.get('project_id'), context=context)
+ for key in project_id.message_subtype_data:
+ if key == 'New Task' and project_id.message_subtype_data[key]['default'] == True:
+ name = 'created'
+ if key == 'Task Closed' and project_id.message_subtype_data[key]['default'] == True:
+ name = 'closed'
+ subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', 'ilike', name)], context=context)
+ subtype_obj.write(cr,uid, subtype_ids, {'default': project_id.message_subtype_data[key]['default']},context=context)
vals['message_follower_ids'] = [(4, follower.id) for follower in project_id.message_follower_ids]
return super(project_issue, self).write(cr, uid, ids, vals, context)
@@ -384,11 +393,20 @@
return res
def create(self, cr, uid, vals, context=None):
+ subtype_obj = self.pool.get('mail.message.subtype')
obj_id = super(project_issue, self).create(cr, uid, vals, context=context)
project_id = self.browse(cr, uid, obj_id, context=context).project_id
+ name = False
if project_id:
+ for key in project_id.message_subtype_data:
+ if key == 'New Task' and project_id.message_subtype_data[key]['default'] == True:
+ name = 'created'
+ if key == 'Task Closed' and project_id.message_subtype_data[key]['default'] == True:
+ name = 'closed'
+ subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', 'ilike', name)], context=context)
+ subtype_obj.write(cr,uid, subtype_ids, {'default': project_id.message_subtype_data[key]['default']},context=context)
followers = [follower.id for follower in project_id.message_follower_ids]
- self.message_subscribe(cr, uid, [obj_id], followers, context=context)
+ self.message_subscribe(cr, uid, [obj_id], followers, subtype_ids= subtype_ids, context=context)
self.create_send_note(cr, uid, [obj_id], context=context)
return obj_id
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp