Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/16.0' into 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dhongu committed Feb 5, 2025
2 parents 60db8d5 + 6c134f7 commit 4864d75
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ addon | version | maintainers | summary | price
[deltatech_stock_analytic](deltatech_stock_analytic/) | 16.0.1.0.1 | [![danila12](https://github.com/danila12.png?size=30px)](https://github.com/danila12) | Create analytic lines from stock moves | Free
[deltatech_stock_date](deltatech_stock_date/) | 16.0.1.0.9 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Set posting date for stock move | Free
[deltatech_stock_delivery](deltatech_stock_delivery/) | 16.0.1.0.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Adding button in invoice for display reception or delivery | Free
[deltatech_stock_inventory](deltatech_stock_inventory/) | 16.0.2.2.8 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Inventory Old Method | Free
[deltatech_stock_inventory](deltatech_stock_inventory/) | 16.0.2.2.9 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Inventory Old Method | Free
[deltatech_stock_location](deltatech_stock_location/) | 16.0.1.0.3 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Generate route, picking operation for location | Free
[deltatech_stock_negative](deltatech_stock_negative/) | 16.0.2.0.2 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Negative stocks are not allowed | Free
[deltatech_stock_report](deltatech_stock_report/) | 16.0.1.0.3 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Report with positions from picking lists | Free
Expand Down
43 changes: 17 additions & 26 deletions deltatech_sms/models/iap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,32 @@
# Dorin Hongu <dhongu(@)gmail(.)com
# See README.rst file on addons root folder for license details

from odoo import fields, models
import logging

import requests

from odoo import fields, models

_logger = logging.getLogger(__name__)


class IapAccount(models.Model):
_inherit = "iap.account"

endpoint = fields.Char()

sms_provider = fields.Selection([('4pay', 'SMS 4Pay'), ('wapi', 'SMS Wapi')], string="SMS Provider", required=True,
default="4pay")
sms_provider = fields.Selection(
[("4pay", "SMS 4Pay"), ("wapi", "SMS Wapi")], string="SMS Provider", required=True, default="4pay"
)
sms_secret = fields.Char(string="SMS Secret")
sms_gateway = fields.Char(string="SMS Gateway")

def send_sms(self, phone_number, message):
"""Send SMS using IAP """
"""Send SMS using IAP"""
response = {}
if self.sms_provider == '4pay':
if self.sms_provider == "4pay":
response = self._send_sms_4pay(phone_number, message)
if self.sms_provider == 'wapi':
if self.sms_provider == "wapi":
response = self._send_sms_wapi(phone_number, message)
return response

Expand All @@ -34,24 +38,16 @@ def _send_sms_4pay(self, phone_number, message):
"msg_text": message,
"API": "",
"password": self.sms_secret,
"external_messageID": 1
"external_messageID": 1,
}
result = requests.get('https://sms.4pay.ro/smscust/api.send_sms', params=params, timeout=60)
result = requests.get("https://sms.4pay.ro/smscust/api.send_sms", params=params, timeout=60)
response = result.content.decode("utf-8")

if "OK" not in response:
_logger.error(f"SMS: {response}")
res = {
"status": 500,
"message": response,
"data": False
}
res = {"status": 500, "message": response, "data": False}
else:
res = {
"status": 200,
"message": "Message has been queued for sending!",
"data": False
}
res = {"status": 200, "message": "Message has been queued for sending!", "data": False}

return res

Expand All @@ -64,8 +60,8 @@ def _send_sms_wapi(self, phone_number, message):
"mode": "devices",
"phone": phone_number,
"message": message,
'device': self.sms_gateway,
"sim": 1
"device": self.sms_gateway,
"sim": 1,
}

# Make the POST request
Expand All @@ -77,11 +73,6 @@ def _send_sms_wapi(self, phone_number, message):
if response.status_code == 200:
res = response.json()
else:
res = {
"status": 500,
"message": response.content,
"data": False
}
res = {"status": 500, "message": response.content, "data": False}

return res

7 changes: 2 additions & 5 deletions deltatech_sms/models/sms_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

import logging

import requests

from odoo import api, models

_logger = logging.getLogger(__name__)
Expand All @@ -19,17 +17,16 @@ class SmsApi(models.AbstractModel):
def _contact_iap(self, local_endpoint, params):
account = self.env["iap.account"].get("sms")


res = []

for message in params["messages"]:
res_value = {"state": "success", "res_id": message["res_id"]}

response = account.send_sms(message["number"], message["content"])

if response['status'] != 200:
if response["status"] != 200:
res_value["state"] = "server_error"
res_value["error"] = response['message']
res_value["error"] = response["message"]

res += [res_value]

Expand Down
2 changes: 1 addition & 1 deletion deltatech_stock_inventory/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Stock Inventory
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5dc7221f8ace26039991405b8679f92c00fe1366ef52667eb040ac6b71d4620d
!! source digest: sha256:9e91fe1c7a7774ccf566e7f6bd351b5fd542187a037f051887d99d91b224c738
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
Expand Down
2 changes: 1 addition & 1 deletion deltatech_stock_inventory/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Stock Inventory",
"summary": "Inventory Old Method",
"version": "16.0.2.2.8",
"version": "16.0.2.2.9",
"author": "Terrabit, Dorin Hongu",
"website": "https://www.terrabit.ro",
"category": "Warehouse",
Expand Down
2 changes: 1 addition & 1 deletion deltatech_stock_inventory/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def action_view_stock_valuation_layers(self):
(
"id",
"in",
(self.with_context(active_test=False).move_lines + scraps.move_id).stock_valuation_layer_ids.ids,
(self.with_context(active_test=False).move_ids + scraps.move_id).stock_valuation_layer_ids.ids,
)
]
res["domain"] = domain
Expand Down
2 changes: 1 addition & 1 deletion deltatech_stock_inventory/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1 class="title">Stock Inventory</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5dc7221f8ace26039991405b8679f92c00fe1366ef52667eb040ac6b71d4620d
!! source digest: sha256:9e91fe1c7a7774ccf566e7f6bd351b5fd542187a037f051887d99d91b224c738
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="https://www.odoo.com/documentation/master/legal/licenses.html"><img alt="License: OPL-1" src="https://img.shields.io/badge/licence-OPL--1-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/dhongu/deltatech/tree/16.0/deltatech_stock_inventory"><img alt="dhongu/deltatech" src="https://img.shields.io/badge/github-dhongu%2Fdeltatech-lightgray.png?logo=github" /></a></p>
<dl class="docutils">
Expand Down

0 comments on commit 4864d75

Please sign in to comment.