summaryrefslogtreecommitdiff
path: root/addons/stock_sms
diff options
context:
space:
mode:
Diffstat (limited to 'addons/stock_sms')
-rw-r--r--addons/stock_sms/models/stock_picking.py6
-rw-r--r--addons/stock_sms/wizard/confirm_stock_sms.py26
-rw-r--r--addons/stock_sms/wizard/confirm_stock_sms_views.xml7
3 files changed, 9 insertions, 30 deletions
diff --git a/addons/stock_sms/models/stock_picking.py b/addons/stock_sms/models/stock_picking.py
index 4813824bf35..06cbb0dcf25 100644
--- a/addons/stock_sms/models/stock_picking.py
+++ b/addons/stock_sms/models/stock_picking.py
@@ -59,14 +59,14 @@ class Picking(models.Model):
('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'].search_count([
+ 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'].search_count([
+ 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
@@ -76,6 +76,6 @@ class Picking(models.Model):
'model': 'res.users',
'res_id': admin.id,
}
- mail_template.send_mail(admin.id, email_values=email_values, notif_layout='mail.mail_notification_light')
+ 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)
diff --git a/addons/stock_sms/wizard/confirm_stock_sms.py b/addons/stock_sms/wizard/confirm_stock_sms.py
index 591a6972e74..b89a9e613f0 100644
--- a/addons/stock_sms/wizard/confirm_stock_sms.py
+++ b/addons/stock_sms/wizard/confirm_stock_sms.py
@@ -1,9 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from odoo import fields, models, exceptions
-
-import requests
+from odoo import fields, models
class ConfirmStockSms(models.TransientModel):
@@ -12,30 +10,18 @@ class ConfirmStockSms(models.TransientModel):
picking_id = fields.Many2one('stock.picking', required=True)
company_id = fields.Many2one('res.company', string='Company', required=True, related='picking_id.company_id')
- iap_account = fields.Boolean(compute='_compute_iap_account')
-
- def _compute_iap_account(self):
- self.iap_account = self.env['iap.account'].get('sms', force_create=False)
def send_sms(self):
self.ensure_one()
if not self.company_id.has_received_warning_stock_sms:
- IAP = self.env['iap.account']
- if not IAP.get('sms', force_create=False):
- IAP.get('sms')
- url = IAP.get_credits_url(service_name='sms', trial=True)
- try:
- req = requests.get(url)
- req.raise_for_status()
- except (ValueError, requests.exceptions.ConnectionError, requests.exceptions.MissingSchema, requests.exceptions.Timeout, requests.exceptions.HTTPError):
- raise exceptions.AccessError('The url that this service requested returned an error. Please contact the author of the app. The url it tried to contact was ' + url)
-
- self.company_id.has_received_warning_stock_sms = True
+ self.company_id.sudo().write({'has_received_warning_stock_sms': True})
return self.picking_id.button_validate()
def dont_send_sms(self):
self.ensure_one()
if not self.company_id.has_received_warning_stock_sms:
- self.company_id.has_received_warning_stock_sms = True
- self.company_id.stock_move_sms_validation = False
+ self.company_id.sudo().write({
+ 'has_received_warning_stock_sms': True,
+ 'stock_move_sms_validation': False,
+ })
return self.picking_id.button_validate()
diff --git a/addons/stock_sms/wizard/confirm_stock_sms_views.xml b/addons/stock_sms/wizard/confirm_stock_sms_views.xml
index 6796d64851b..2751934daf0 100644
--- a/addons/stock_sms/wizard/confirm_stock_sms_views.xml
+++ b/addons/stock_sms/wizard/confirm_stock_sms_views.xml
@@ -5,15 +5,8 @@
<field name="model">confirm.stock.sms</field>
<field name="arch" type="xml">
<form string="SMS">
- <field name="iap_account" invisible="1"/>
You are about to confirm this Delivery Order by SMS Text Message.<br/>
This feature can easily be disabled from the Settings of Inventory or by clicking on "Disable SMS".<br/>
- <br/>
- <p attrs="{'invisible': [('iap_account', '=', True)]}">
- When confirming the sending of the SMS Text Message, you will be granted free trial credits.<br/>
- By buying a pack and using the IAP service, you accept the <a href="https://iap.odoo.com/privacy#sms" target="_blank">Privacy Policy</a> of the service provider
- and the <a href="https://www.odoo.com/privacy" target="_blank">Odoo Privacy Policy</a>.
- </p>
<group invisible="1">
<field name="picking_id" invisible="1"/>
<field name="company_id" invisible="1"/>