~openerp-dev/openobject-addons/7.0-mail_issues-adh-1251130

« back to all changes in this revision

Viewing changes to mail/mail_group.py

  • Committer: Anand Dharampuriya(OpenERP)
  • Date: 2014-06-04 09:00:08 UTC
  • Revision ID: adh@tinyerp.com-20140604090008-z5kadds3ypt2puw9
[FIX] Mail: Solve how to restrict user to delete existing groups Whole Company, Company Jobs and Company News

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from openerp.osv import osv
25
25
from openerp.osv import fields
26
26
from openerp import SUPERUSER_ID
27
 
 
 
27
from openerp.tools.translate import _
28
28
 
29
29
class mail_group(osv.Model):
30
30
    """ A mail_group is a collection of users sharing messages in a discussion
172
172
        mail_alias = self.pool.get('mail.alias')
173
173
        alias_ids = [group.alias_id.id for group in groups if group.alias_id]
174
174
        # Delete mail_group
 
175
        ir_model_data = self.pool.get('ir.model.data')
 
176
        group_ids = []
 
177
        group_ids.append(ir_model_data.get_object_reference(cr, uid, 'mail', 'group_all_employees')[1])
 
178
        group_ids.append(ir_model_data.get_object_reference(cr, uid, 'portal', 'company_news_feed')[1])
 
179
        group_ids.append(ir_model_data.get_object_reference(cr, uid, 'portal', 'company_jobs')[1])
 
180
        group_ids = [group_id for group_id in group_ids if group_id in ids]        
 
181
        if group_ids:
 
182
                raise osv.except_osv(_('Warning!'), _('You can not delete this group because some other modules are depend on it'))
175
183
        res = super(mail_group, self).unlink(cr, uid, ids, context=context)
176
184
        # Delete alias
177
185
        mail_alias.unlink(cr, SUPERUSER_ID, alias_ids, context=context)