Browse Source

update js

pull/182/head
Jordi Ballester Alomar 6 years ago
parent
commit
96e4a3cc5a
  1. 6
      base_sms_client/__manifest__.py
  2. 40
      base_sms_client/static/src/js/override_chatter.js
  3. 13
      base_sms_client/static/src/xml/inherit_chatter.xml
  4. 8
      base_sms_client/static/src/xml/templates.xml
  5. 29
      base_sms_client/wizard/mass_sms.py
  6. 3
      clicksend_sms_client/models/sms_gateway.py

6
base_sms_client/__manifest__.py

@ -33,7 +33,11 @@
"views/server_action_view.xml",
"data/sms_gateway_data.xml",
"wizard/mass_sms_view.xml",
"views/smstemplate_view.xml"
"views/smstemplate_view.xml",
"static/src/xml/templates.xml",
],
'qweb': [
'static/src/xml/inherit_chatter.xml',
],
"installable": True,
}

40
base_sms_client/static/src/js/override_chatter.js

@ -0,0 +1,40 @@
odoo.define('mail.Chatter.sms', function (require) {
"use strict";
var chatter = require('mail.Chatter');
chatter.include({
events: _.extend({}, chatter.prototype.events, {
'click .o_chatter_button_send_sms': '_onSendSMS',
}),
/**
* Performs the action to open the SMS window.
*
* @private
*/
_onSendSMS: function () {
var self = this
this._rpc({
model: 'wizard.mass.sms',
method: 'redirect_to_sms_wizard',
args: [[]],
kwargs: {
'id':this.record.res_id,
'model':this.record.model,
},
context: this.record.getContext(),
}).then(function (result) {
self.do_action(result, {
additional_context: {
'active_ids': [self.record.res_id],
'active_id': [self.record.res_id],
'active_model': self.record.model,
},
})
});
},
});
});

13
base_sms_client/static/src/xml/inherit_chatter.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-extend="mail.Chatter.Buttons">
<t t-jquery="button.o_chatter_button_schedule_activity" t-operation="after">
<button class="btn btn-sm btn-link o_chatter_button_send_sms"
title="Send SMS" type="button">
<i class="fa fa-clock"/> Send SMS
</button>
</t>
</t>
</templates>

8
base_sms_client/static/src/xml/templates.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets_backend" name="base_sms_client assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/base_sms_client/static/src/js/override_chatter.js"></script>
</xpath>
</template>
</odoo>

29
base_sms_client/wizard/mass_sms.py

@ -18,6 +18,11 @@ class WizardMassSms(models.TransientModel):
def _default_get_partner(self):
if self._context.get('active_model') == 'res.partner':
return self._context.get('active_ids')
else:
rec = self.env[self._context.get('active_model')].browse(
self._context.get('active_id'))
if hasattr(rec, 'message_follower_ids'):
rec.message_follower_ids.mapped('partner_id')
gateway_id = fields.Many2one(
'sms.gateway',
@ -76,7 +81,27 @@ class WizardMassSms(models.TransientModel):
@api.multi
def send(self):
sms_obj = self.env['sms.sms']
partner_obj = self.env['res.partner']
for partner in partner_obj.browse(self._context.get('active_ids')):
for partner in self.partner_ids:
vals = self._prepare_sms_vals(partner)
sms_obj.create(vals)
src_model = self.env[self._context.get('active_model')]
if hasattr(src_model, 'message_follower_ids'):
rec = src_model.browse(self._context.get('active_id'))
rec.message_post(body=self.message)
self.env['bus.bus'].sendone(
'refresh', [self.env.cr.dbname, self._name, self._uid])
return {'type': 'ir.actions.act_window_close'}
def redirect_to_sms_wizard(self, **kwargs):
id = kwargs.get("id")
model = kwargs.get("model")
action = self.env['wizard.mass.sms'].action_wizard_mass_sms()
action['src_model'] = model
action['domain'] = [('res_id', '=', id)]
return action
@api.model
def action_wizard_mass_sms(self):
action = self.env.ref(
'base_sms_client.action_wizard_mass_sms').read()[0]
return action

3
clicksend_sms_client/models/sms_gateway.py

@ -63,8 +63,7 @@ class SmsSms(models.Model):
params.update({
'password': '*****',
'to': '*****',
'smsAccount': '*****',
'login': '*****',
'username': '*****',
})
_logger.debug("Call ClickSend API : %s params %s",
params['url'], params)

Loading…
Cancel
Save