diff options
| author | Jérome Maes <jem@openerp.com> | 2015-09-03 13:52:57 +0200 |
|---|---|---|
| committer | Jérome Maes <jem@openerp.com> | 2015-09-04 15:55:46 +0200 |
| commit | 4bdfa3b6caefc6621d7043738708a766b4f80f69 (patch) | |
| tree | afb6edf03b57ac7dcc34ae84bb1d7266e6c93eb2 /addons/mail | |
| parent | 7674536713aaa3721ddb55e43ddf50585a4f20a0 (diff) | |
[IMP] mail : invite follower wizard have 2 appearances
The wizard is the same object, but to add channel as follower, some fields was not required. Via the 'mail_invite_follower_channel_only' context key, the unrelevant fields are hidden.
Diffstat (limited to 'addons/mail')
| -rw-r--r-- | addons/mail/static/src/js/mail_followers.js | 13 | ||||
| -rw-r--r-- | addons/mail/static/src/xml/mail_followers.xml | 3 | ||||
| -rw-r--r-- | addons/mail/wizard/invite.py | 4 | ||||
| -rw-r--r-- | addons/mail/wizard/invite_view.xml | 10 |
4 files changed, 22 insertions, 8 deletions
diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 630e033de0f..3e83831b478 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -94,7 +94,14 @@ var Followers = form_common.AbstractField.extend({ }); // event: click on 'invite' button, that opens the invite wizard - this.$el.on('click', '.o_add_follower', self.on_invite_follower); + this.$el.on('click', '.o_add_follower', function(e){ + e.preventDefault(); + self.on_invite_follower(false); + }); + this.$el.on('click', '.o_add_follower_channel', function(e){ + e.preventDefault(); + self.on_invite_follower(true); + }); // event: click on 'edit_subtype(pencil)' button to edit subscription this.$el.on('click', '.o_edit_subtype', self.on_edit_subtype); @@ -126,9 +133,8 @@ var Followers = form_common.AbstractField.extend({ return self.fetch_subtypes(user_pid); }, - on_invite_follower: function (event) { + on_invite_follower: function (channel_only) { var self = this; - event.preventDefault(); var action = { type: 'ir.actions.act_window', res_model: 'mail.wizard.invite', @@ -140,6 +146,7 @@ var Followers = form_common.AbstractField.extend({ context: { 'default_res_model': this.view.dataset.model, 'default_res_id': this.view.datarecord.id, + 'mail_invite_follower_channel_only': channel_only, }, }; this.do_action(action, { diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 059f67797bf..6370715695a 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -54,6 +54,9 @@ <li t-if="widget.view_is_editable" class="o_add_follower"> <a href="#"> Add followers </a> </li> + <li t-if="widget.view_is_editable" class="o_add_follower_channel"> + <a href="#"> Add Channels </a> + </li> <li t-if="widget.view_is_editable and (widget.followers.length > 0)" class="divider"/> </t> diff --git a/addons/mail/wizard/invite.py b/addons/mail/wizard/invite.py index 8ad772a04cc..36736cb355d 100644 --- a/addons/mail/wizard/invite.py +++ b/addons/mail/wizard/invite.py @@ -5,7 +5,7 @@ from openerp import tools class Invite(models.TransientModel): - """ Wizard to invite partners and make them followers. """ + """ Wizard to invite partners (or channels) and make them followers. """ _name = 'mail.wizard.invite' _description = 'Invite wizard' @@ -15,6 +15,8 @@ class Invite(models.TransientModel): user_name = self.env.user.name_get()[0][1] model = result.get('res_model') res_id = result.get('res_id') + if self._context.get('mail_invite_follower_channel_only'): + result['send_mail'] = False if 'message' in fields and model and res_id: model_name = self.env['ir.model'].search([('model', '=', self.pool[model]._name)]).name_get()[0][1] document_name = self.env[model].browse(res_id).name_get()[0][1] diff --git a/addons/mail/wizard/invite_view.xml b/addons/mail/wizard/invite_view.xml index 0e1767b2d71..34d8c545b2b 100644 --- a/addons/mail/wizard/invite_view.xml +++ b/addons/mail/wizard/invite_view.xml @@ -13,16 +13,18 @@ <field name="res_id" invisible="1"/> <field name="partner_ids" widget="many2many_tags_email" placeholder="Add contacts to notify..." - context="{'force_email':True, 'show_email':True}"/> + context="{'force_email':True, 'show_email':True}" + invisible="context.get('mail_invite_follower_channel_only')"/> <field name="channel_ids" widget="many2many_tags" - placeholder="Add channels to notify..."/> - <field name="send_mail"/> + placeholder="Add channels to notify..." + invisible="not context.get('mail_invite_follower_channel_only')"/> + <field name="send_mail" invisible="context.get('mail_invite_follower_channel_only')"/> <field name="message" attrs="{'invisible': [('send_mail','!=',True)]}" options="{'style-inline': true}" class="test_message"/> </group> <footer> <button string="Add Followers" name="add_followers" type="object" class="btn-primary"/> - <button string="Cancel" class="btn-default" special="cancel" /> + <button string="Cancel" class="btn-default" special="cancel" /> </footer> </form> </field> |
