[IMP]project: set one selection field and and some methods for followers or members

bzr revid: dbr@tinyerp.com-20120528070157-8lo7c1d3owzbmhaq
This commit is contained in:
DBR (OpenERP)
2012-05-28 12:31:57 +05:30
parent 099c4e574a
commit b805979e92
3 changed files with 45 additions and 1 deletions
+39 -1
View File
@@ -67,6 +67,35 @@ class project(osv.osv):
return super(project, self).search(cr, user, args, offset=offset, limit=limit, order=order,
context=context, count=count)
def write(self, cr, uid, ids, vals, context=None):
if context is None:
context = {}
list = []
project_ids = self.browse(cr, uid, ids)
groups = self.pool.get('res.groups')
group_id = groups.search(cr, uid, [('name', '=', 'Followers')], context=context)
groups_users = groups.browse(cr, uid, group_id)[0].users
for project_id in project_ids:
select = vals.get('privacy_visility') or project_id.privacy_visility or False
members = vals.get('members') or project_id.members or False
if select=='follower':
if members:
for member in members:
list.append(member.id)
followers = self.find_followers(cr, uid, ids, context)
for member_id in list:
if not member_id in followers:
self.message_subscribe(cr, uid, ids, [member_id], context=context)
return super(project, self).write(cr, uid, ids, vals, context=context)
def find_followers(self, cr, uid, ids, context=None):
user=[]
sub_obj = self.pool.get('mail.subscription')
sub_id = sub_obj.search(cr, uid, [('res_model','=','project.project'),('res_id','in',ids)], context=context)
for follower_id in sub_obj.browse(cr, uid, sub_id):
user.append(follower_id.user_id.id)
return user
def _complete_name(self, cr, uid, ids, name, args, context=None):
res = {}
for m in self.browse(cr, uid, ids, context=context):
@@ -202,11 +231,20 @@ class project(osv.osv):
'task_count': fields.function(_task_count, type='integer', string="Open Tasks"),
'color': fields.integer('Color Index'),
'company_uom_id': fields.related('company_id', 'project_time_mode_id', type='many2one', relation='product.uom'),
'privacy_visility': fields.selection([('public','Public'), ('follower','Followers Only')], 'Privacy / Visility', select=True),
}
def dummy(self, cr, uid, ids, context):
return True
def message_thread_followers(self, cr, uid, ids, context=None):
followers = super(project,self).message_thread_followers(cr, uid, ids, context=context)
for project in self.browse(cr, uid, followers.keys(), context=context):
project_followers = set(followers[project.id])
project_followers.add(project.user_id.user_email)
followers[project.id] = filter(None, project_followers)
return followers
def _get_type_common(self, cr, uid, context):
ids = self.pool.get('project.task.type').search(cr, uid, [('project_default','=',1)], context=context)
return ids
+1
View File
@@ -41,6 +41,7 @@
<field name="date_start" string="Start Date" attrs="{'readonly':[('state','in',['close', 'cancelled'])]}"/>
<field name="date" string="End Date" attrs="{'readonly':[('state','in',['close', 'cancelled'])]}"/>
<field name="progress_rate" widget="progressbar"/>
<field name="privacy_visility"/>
</group>
<notebook colspan="4">
<page string="Administration">
@@ -14,6 +14,11 @@
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
<record id="group_project_followers" model="res.groups">
<field name="name">Followers</field>
<field name="category_id" ref="base.module_category_project_management"/>
</record>
<record model="ir.ui.menu" id="menu_definitions">
<field name="groups_id" eval="[(6,0,[ref('group_project_manager')])]"/>
</record>