diff options
| author | Pierre Rousseau <pro@odoo.com> | 2019-09-30 12:30:01 +0000 |
|---|---|---|
| committer | Pierre Rousseau <pro@odoo.com> | 2019-09-30 12:32:06 +0000 |
| commit | 333f1087cf50efa4e053e5d9fef0b80e421967f1 (patch) | |
| tree | 3316a89fccc5b33b7703230b26ee27d3b2798245 /addons/stock_sms | |
| parent | 3469821b73a1fd697c1d9b6a6be2165d798dc362 (diff) | |
[FIX] stock_sms: do not send mail notifications
The aim of this commit is to remove the mail notifications when there is no more credits on IAP accounts for SMS integration with stock.
Task-ID 2077783
closes odoo/odoo#37559
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Diffstat (limited to 'addons/stock_sms')
| -rw-r--r-- | addons/stock_sms/__manifest__.py | 1 | ||||
| -rw-r--r-- | addons/stock_sms/data/mail_data.xml | 23 | ||||
| -rw-r--r-- | addons/stock_sms/models/stock_picking.py | 31 |
3 files changed, 0 insertions, 55 deletions
diff --git a/addons/stock_sms/__manifest__.py b/addons/stock_sms/__manifest__.py index 2e51b257216..2c10d062d74 100644 --- a/addons/stock_sms/__manifest__.py +++ b/addons/stock_sms/__manifest__.py @@ -10,7 +10,6 @@ 'depends': ['stock', 'sms'], 'data': [ 'data/sms_data.xml', - 'data/mail_data.xml', 'views/res_config_settings_views.xml', 'wizard/confirm_stock_sms_views.xml', 'security/ir.model.access.csv', diff --git a/addons/stock_sms/data/mail_data.xml b/addons/stock_sms/data/mail_data.xml deleted file mode 100644 index 6fe3ced019b..00000000000 --- a/addons/stock_sms/data/mail_data.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<odoo> - <data> - - <record id="mail_template_no_more_credit_sms" model="mail.template"> - <field name="name">IAP SMS Confirmation Notification</field> - <field name="email_from">iap@odoo.com</field> - <field name="subject">IAP SMS Confirmation Notification</field> - <field name="model_id" ref="base.model_res_users"/> - <field name="partner_to">${object.partner_id.id}</field> - <field name="body_html" type="html"> - <p>Dear ${object.name},</p> - <br/> - <p>There are no more credits on your IAP SMS account.<br/> - You can charge your IAP SMS account from the Settings of the Inventory app or from the General Settings.<br/></p> - <br/> - <p>Best regards,</p> - <p>Odoo S.A.</p> - </field> - </record> - - </data> -</odoo> diff --git a/addons/stock_sms/models/stock_picking.py b/addons/stock_sms/models/stock_picking.py index 06cbb0dcf25..c31736cf4e1 100644 --- a/addons/stock_sms/models/stock_picking.py +++ b/addons/stock_sms/models/stock_picking.py @@ -40,7 +40,6 @@ class Picking(models.Model): def _send_confirmation_email(self): super(Picking, self)._send_confirmation_email() if not getattr(threading.currentThread(), 'testing', False) and not self.env.registry.in_test_mode(): - sms_sent = False pickings = self.filtered(lambda p: p.company_id.stock_move_sms_validation and p.picking_type_id.code == 'outgoing' and (p.partner_id.mobile or p.partner_id.phone)) for picking in pickings: @@ -49,33 +48,3 @@ class Picking(models.Model): partner_ids=picking.partner_id.ids, put_in_queue=False ) - sms_sent = True - - if sms_sent: - pickings._check_credit_sms() - - def _check_credit_sms(self): - mail_message_ids = self.env['mail.message'].search([ - ('res_id', 'in', self.ids), - ('model', '=', 'stock.picking')]).ids - if self.env['ir.config_parameter'].sudo().get_param('stock_sms.already_notified', False): - if self.env['sms.sms'].sudo().search_count([ - ('mail_message_id', 'in', mail_message_ids), - ('state', '=', 'sent'), - ('error_code', '=', False)]): - # The SMS is sent, the company has again credits - self.env['ir.config_parameter'].sudo().set_param('stock_sms.already_notified', False) - else: - if self.env['sms.sms'].sudo().search_count([ - ('mail_message_id', 'in', mail_message_ids), - ('error_code', '=', 'sms_credit')]): - # The SMS is sent, the company has no more credits - for admin in self.env.ref('base.group_system').users: - mail_template = self.env.ref('stock_sms.mail_template_no_more_credit_sms') - email_values = { - 'model': 'res.users', - 'res_id': admin.id, - } - mail_template.sudo().send_mail(admin.id, email_values=email_values, notif_layout='mail.mail_notification_light') - - self.env['ir.config_parameter'].sudo().set_param('stock_sms.already_notified', True) |
