Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] sms_no_automatic_delete: Migration to 16.0 #323

Open
wants to merge 14 commits into
base: 16.0
Choose a base branch
from
Open
6 changes: 6 additions & 0 deletions setup/sms_no_automatic_delete/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
84 changes: 84 additions & 0 deletions sms_no_automatic_delete/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
============================
No automatic deletion of SMS
============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0a5f4deed06afe5abaef59e4918f990556f36249dba50f5ad45ed26016ca8106
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fconnector--telephony-lightgray.png?logo=github
:target: https://github.com/OCA/connector-telephony/tree/16.0/sms_no_automatic_delete
:alt: OCA/connector-telephony
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/connector-telephony-16-0/connector-telephony-16-0-sms_no_automatic_delete
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/connector-telephony&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to save sent sms and to delete them after a delay (in days).
In addition, the sms state is update as "sent" when they are sent and saved.

**Table of contents**

.. contents::
:local:

Usage
=====

To delete sent sms, the cron "SMS: SMS Purge" is used in order to choice the maximum days a sms will be saved (by default : days = 90).

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/connector-telephony/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/connector-telephony/issues/new?body=module:%20sms_no_automatic_delete%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Akretion

Contributors
~~~~~~~~~~~~

* Kévin Roche <[email protected]>
* Sébastien Beau <[email protected]>
* Bernat Puig <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/connector-telephony <https://github.com/OCA/connector-telephony/tree/16.0/sms_no_automatic_delete>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sms_no_automatic_delete/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions sms_no_automatic_delete/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2021 Akretion (http://www.akretion.com).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "No automatic deletion of SMS",
"summary": "Avoid automatic delete of sended sms",
"author": "Akretion,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/connector-telephony",
"license": "AGPL-3",
"category": "",
"version": "16.0.1.0.0",
"depends": ["sms"],
"data": [
"data/ir_cron_data.xml",
],
"application": False,
"installable": True,
}
14 changes: 14 additions & 0 deletions sms_no_automatic_delete/data/ir_cron_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record forcecreate="True" id="ir_cron_sms_no_automatic_delete" model="ir.cron">
<field name="name">SMS: SMS Purge</field>
<field name="model_id" ref="model_sms_sms" />
<field name="state">code</field>
<field name="code">model._purge(days=90)</field>
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall" />
</record>
</odoo>
44 changes: 44 additions & 0 deletions sms_no_automatic_delete/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sms_no_automatic_delete
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-20 19:33+0000\n"
"Last-Translator: Ivorra78 <[email protected]>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: sms_no_automatic_delete
#: model:ir.model.fields,field_description:sms_no_automatic_delete.field_sms_sms__display_name
msgid "Display Name"
msgstr "Mostrar Nombre"

#. module: sms_no_automatic_delete
#: model:ir.model.fields,field_description:sms_no_automatic_delete.field_sms_sms__id
msgid "ID"
msgstr "ID"

#. module: sms_no_automatic_delete
#: model:ir.model.fields,field_description:sms_no_automatic_delete.field_sms_sms____last_update
msgid "Last Modified on"
msgstr "Última Modificación el"

#. module: sms_no_automatic_delete
#: model:ir.model,name:sms_no_automatic_delete.model_sms_sms
msgid "Outgoing SMS"
msgstr "SMS Salientes"

#. module: sms_no_automatic_delete
#: model:ir.actions.server,name:sms_no_automatic_delete.ir_cron_sms_no_automatic_delete_ir_actions_server
#: model:ir.cron,cron_name:sms_no_automatic_delete.ir_cron_sms_no_automatic_delete
#: model:ir.cron,name:sms_no_automatic_delete.ir_cron_sms_no_automatic_delete
msgid "SMS: SMS Purge"
msgstr "SMS: Purga de SMS"
41 changes: 41 additions & 0 deletions sms_no_automatic_delete/i18n/sms_no_automatic_delete.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sms_no_automatic_delete
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: sms_no_automatic_delete
#: model:ir.model.fields,field_description:sms_no_automatic_delete.field_sms_sms__display_name
msgid "Display Name"
msgstr ""

#. module: sms_no_automatic_delete
#: model:ir.model.fields,field_description:sms_no_automatic_delete.field_sms_sms__id
msgid "ID"
msgstr ""

#. module: sms_no_automatic_delete
#: model:ir.model.fields,field_description:sms_no_automatic_delete.field_sms_sms____last_update
msgid "Last Modified on"
msgstr ""

#. module: sms_no_automatic_delete
#: model:ir.model,name:sms_no_automatic_delete.model_sms_sms
msgid "Outgoing SMS"
msgstr ""

#. module: sms_no_automatic_delete
#: model:ir.actions.server,name:sms_no_automatic_delete.ir_cron_sms_no_automatic_delete_ir_actions_server
#: model:ir.cron,cron_name:sms_no_automatic_delete.ir_cron_sms_no_automatic_delete
#: model:ir.cron,name:sms_no_automatic_delete.ir_cron_sms_no_automatic_delete
msgid "SMS: SMS Purge"
msgstr ""
1 change: 1 addition & 0 deletions sms_no_automatic_delete/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sms_sms
37 changes: 37 additions & 0 deletions sms_no_automatic_delete/models/sms_sms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2021 Akretion (https://www.akretion.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from datetime import datetime, timedelta

from odoo import api, models


class SmsSms(models.Model):
_inherit = "sms.sms"

@api.model
def _postprocess_iap_sent_sms(
self, iap_results, failure_reason=None, unlink_failed=False, unlink_sent=True
):
# Update state of the sms as "sent" when they are sent.
ids = [item["res_id"] for item in iap_results if item["state"] == "success"]
self.browse(ids).write({"state": "sent"})
return super()._postprocess_iap_sent_sms(
iap_results,
failure_reason=failure_reason,
unlink_failed=unlink_failed,
unlink_sent=unlink_sent,
)

@api.model
def _purge(self, days):
sms = self.env["sms.sms"].search(
[("write_date", "<=", datetime.now() - timedelta(days=days))]
)
sms.with_context(force_unlink=True).unlink()

def unlink(self):
if self._context.get("force_unlink"):
return super().unlink()
else:
return True
3 changes: 3 additions & 0 deletions sms_no_automatic_delete/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Kévin Roche <[email protected]>
* Sébastien Beau <[email protected]>
* Bernat Puig <[email protected]>
2 changes: 2 additions & 0 deletions sms_no_automatic_delete/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allows to save sent sms and to delete them after a delay (in days).
In addition, the sms state is update as "sent" when they are sent and saved.
1 change: 1 addition & 0 deletions sms_no_automatic_delete/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
To delete sent sms, the cron "SMS: SMS Purge" is used in order to choice the maximum days a sms will be saved (by default : days = 90).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading