Merge lp:~vauxoo/addons-vauxoo/jose-delete-followers into lp:addons-vauxoo/7.0

Status: Merged
Merged at revision: 990
Proposed branch: lp:~vauxoo/addons-vauxoo/jose-delete-followers
Merge into: lp:addons-vauxoo/7.0
Diff against target: 77 lines (+35/-3)
2 files modified
add_followers/wizard/add_followers.py (+22/-1)
add_followers/wizard/add_followers_view.xml (+13/-2)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/jose-delete-followers
Reviewer Review Type Date Requested Status
Moisés López - http://www.vauxoo.com Pending
Review via email: mp+211964@code.launchpad.net

Description of the change

Added new method to remove several partner in several project or task

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'add_followers/wizard/add_followers.py'
2--- add_followers/wizard/add_followers.py 2013-05-18 03:21:46 +0000
3+++ add_followers/wizard/add_followers.py 2014-03-20 14:59:10 +0000
4@@ -68,8 +68,9 @@
5 'group from mail group '
6 'and not for Users '
7 'directly'),
8- 'partners': fields.boolean('Partners', help='Used to add a followers '
9+ 'partners': fields.boolean('Partners', help='Used to add a follower '
10 'group by users'),
11+ 'remove': fields.boolean('Remove Partners', help='Used to remove followers'),
12 'p_a_g': fields.boolean('Group and Partner', help='Used to add a '
13 'followers for partner '
14 'and group at the same '
15@@ -148,6 +149,26 @@
16
17 return res
18
19+ def remove_followers(self, cr, uid, ids, context=None):
20+ '''
21+ Overwrite the original model work with many documents at the same time
22+ and add followers in eech.
23+
24+ Each id is get by context field
25+ '''
26+ res = {'type': 'ir.actions.act_window_close'}
27+ for wizard in self.browse(cr, uid, ids, context=context):
28+ for res_id in context.get('active_ids', []):
29+ model_obj = self.pool.get(wizard.res_model)
30+ document = model_obj.browse(cr, uid, res_id,
31+ context=context)
32+ new_follower_ids = [p.id for p in wizard.partner_ids]
33+ follower_ids = [i.id for i in document.message_follower_ids]
34+ remove_ids = list(set(follower_ids) - set(new_follower_ids))
35+ document.write({'message_follower_ids':[(6, 0, remove_ids)]})
36+
37+ return res
38+
39 def load_partners(self, cr, uid, ids, mail_groups, check, check2,
40 context=None):
41 ''' Used to add all partnes in mail.group selected in the view and
42
43=== modified file 'add_followers/wizard/add_followers_view.xml'
44--- add_followers/wizard/add_followers_view.xml 2013-05-18 03:37:41 +0000
45+++ add_followers/wizard/add_followers_view.xml 2014-03-20 14:59:10 +0000
46@@ -10,6 +10,7 @@
47 <field name="arch" type="xml">
48 <form string="Add Followers" version="7.0">
49 <group>
50+ <field name="remove"/>
51 <field name="groups" attrs="{'invisible':['|',('partners','=', True),
52 ('p_a_g','=',True)]}" on_change="load_partners(mail_groups,groups,p_a_g)"/>
53 <field name="partners" attrs="{'invisible':['|',('groups','=', True),
54@@ -29,11 +30,21 @@
55 ('partners','=',False)]}"
56 placeholder="Add contacts to notify..."
57 context="{'force_email':True, 'show_email':True}"/>
58- <field name="message"/>
59+ <field name="message" attrs="{'invisible':[('remove', '=', True)]}"/>
60 </group>
61 <footer>
62 <button string="Add Followers"
63- name="add_followers" context="{'second':True}" type="object" class="oe_highlight" />
64+ name="add_followers"
65+ context="{'second':True}"
66+ attrs="{'invisible':[('remove', '=', True)]}"
67+ type="object"
68+ class="oe_highlight" />
69+ <p attrs="{'invisible':[('remove', '=', False)]}">Be carefull with this </p>
70+ <button string="Remove Followers"
71+ name="remove_followers"
72+ attrs="{'invisible':[('remove', '=', False)]}"
73+ type="object"
74+ class="oe_highlight" />
75 or
76 <button string="Cancel" class="oe_link" special="cancel" />
77 </footer>