You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.7 KiB

10 years ago
  1. # -*- coding: utf-8 -*-
  2. ###############################################################################
  3. #
  4. # Module for OpenERP
  5. # Copyright (C) 2015 Akretion (http://www.akretion.com).
  6. # @author Valentin CHEMIERE <valentin.chemiere@akretion.com>
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU Affero General Public License as
  10. # published by the Free Software Foundation, either version 3 of the
  11. # License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU Affero General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU Affero General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. ###############################################################################
  22. from openerp import api, models, _
  23. from openerp.exceptions import Warning
  24. import urllib
  25. import logging
  26. _logger = logging.getLogger(__name__)
  27. class SmsClient(models.Model):
  28. _inherit = "sms.smsclient"
  29. @api.model
  30. def get_method(self):
  31. method = super(smsclient, self).get_method()
  32. method.append(('ovh_http', 'OVH HTTP'), )
  33. return method
  34. @api.onchange('method')
  35. def onchange_method(self):
  36. super(smsclient, self).onchange_method()
  37. if self.method == 'ovh http':
  38. self.url_visible = True
  39. self.sms_account_visible = True
  40. self.login_provider_visible = True
  41. self.password_provider_visible = True
  42. self.from_provider_visible = True
  43. self.validity_visible = True
  44. self.classes_visible = True
  45. self.deferred_visible = True
  46. self.nostop_visible = True
  47. self.priority_visible = True
  48. self.coding_visible = True
  49. self.tag_visible = True
  50. self.char_limit_visible = True
  51. class SmsSms(models.Model):
  52. _inherit = "sms.sms"
  53. @api.model
  54. def _prepare_ovh_http(self):
  55. params = {
  56. 'smsAccount': gateway.sms_account,
  57. 'login': gateway.login_provider,
  58. 'password': gateway.password_provider,
  59. 'from': gateway.from_provider,
  60. 'to': self.mobile_to,
  61. 'message': self.text,
  62. }
  63. if self.nostop:
  64. params['noStop'] = 1
  65. if self.deferred:
  66. params['deferred'] = self.deferred
  67. if self.classes:
  68. params['class'] = self.classes
  69. if self.tag:
  70. params['tag'] = self.tag
  71. if self.coding:
  72. params['smsCoding'] = self.coding
  73. return params