[IMP] mail.group: added a groups field to model, linking mail.group to res.groups. Uding the push_to_group flag, it allows to push message to certain groups. Updated view with a temp ugly form view.

bzr revid: tde@openerp.com-20120503125722-veegdrmmnowuwdtd
This commit is contained in:
Thibault Delavallée 2012-05-03 14:57:22 +02:00
parent 5479127fba
commit 64d1f25f60
2 changed files with 39 additions and 6 deletions

View File

@ -114,9 +114,16 @@ class mail_group(osv.osv):
help="Responsible of the group that has all rights on the record."),
'public': fields.boolean('Public', help='This group is visible by non members. \
Invisible groups can add members through the invite button.'),
'models': fields.many2many('ir.model', rel='mail_group_models_rel',
'models': fields.many2many('ir.model', rel='mail_group_ir_model_rel',
id1='mail_group_id', id2='model_id',
string='Linked models', help='Linked models'),
'groups': fields.many2many('res.groups', rel='mail_group_res_group_rel',
id1='mail_group_id', id2='groups_id',
string='Linked groups', help='Linked groups'),
'push_to_groups': fields.boolean('Push to groups',
help="When posting a comment on this mail_group, \
the message is pushed to the users beloging to \
the linked user groups."),
'photo_big': fields.binary('Full-size photo', help='Field holding \
the full-sized PIL-supported and base64 encoded \
version of the group image. The photo field is \
@ -142,6 +149,22 @@ class mail_group(osv.osv):
'photo': _get_default_photo,
}
def message_create_get_notification_user_ids(self, cr, uid, thread_ids, new_msg_vals, context=None):
""" Overrider OpenChatter message_create_get_notification_user_ids
method. The purpose is to add to the subscribers users that
belong to the res.groups linked to the mail.group through the
groups field. The fields push_to_groups allows to control this
feature.
"""
notif_user_ids = super(mail_group, self).message_create_get_notification_user_ids(cr, uid, thread_ids, new_msg_vals, context=context)
for thread in self.browse(cr, uid, thread_ids, context=context):
if not thread.push_to_groups or not thread.groups:
continue
for group in thread.groups:
for user in group.users:
notif_user_ids.append(user.id)
return list(set(notif_user_ids))
def message_load(self, cr, uid, ids, fetch_ancestors=False, ancestor_ids=None,
limit=100, offset=0, domain=None, count=False, context=None):
""" Override OpenChatter message_load method.

View File

@ -58,11 +58,6 @@
<field name="responsible_id" colspan="2"/>
<newline/>
<field name="description" colspan="4"/>
<field name="models" colspan="4">
<tree string="Document models">
<field name="name"/>
</tree>
</field>
</group>
<group colspan="1" col="2">
<separator string="Group image" colspan="2"/>
@ -74,6 +69,21 @@
<label string="This group is visible by non members" colspan="2"/>
</group>
</group>
<notebook colspan="4">
<page string="Links">
<field name="models" colspan="4">
<tree string="Document models">
<field name="name"/>
</tree>
</field>
<field name="groups" colspan="4">
<tree string="Document groups">
<field name="name"/>
</tree>
</field>
<field name="push_to_groups"/>
</page>
</notebook>
<field name="message_ids_social" colspan="4" widget="ThreadView" nolabel="1"/>
</form>
</field>