[MIG] sql_export_mail from OCA/server-tools 14.0 to OCA/reporting-engine 16.0 branch

- Update views, regarding changes in sql_export module
- Add prepare function for cron vals

[UPD] Update sql_export_mail.pot

[UPD] README.rst
This commit is contained in:
Sylvain LE GAL
2022-10-26 16:24:25 +02:00
committed by Sander Lienaerts
parent d06052ca5c
commit 5d3e9ed19e
7 changed files with 75 additions and 89 deletions

View File

@@ -13,14 +13,14 @@ SQL Export Mail
.. |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%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/14.0/sql_export_mail
:alt: OCA/server-tools
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
:target: https://github.com/OCA/reporting-engine/tree/16.0/sql_export_mail
:alt: OCA/reporting-engine
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-sql_export_mail
:target: https://translation.odoo-community.org/projects/reporting-engine-16-0/reporting-engine-16-0-sql_export_mail
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/149/14.0
:target: https://runbot.odoo-community.org/runbot/143/16.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -46,10 +46,10 @@ To configure this module, you need to:
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20sql_export_mail%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20sql_export_mail%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.
@@ -60,6 +60,7 @@ Authors
~~~~~~~
* Akretion
* GRAP
Contributors
~~~~~~~~~~~~
@@ -80,6 +81,14 @@ 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/server-tools <https://github.com/OCA/server-tools/tree/14.0/sql_export_mail>`_ project on GitHub.
.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px
:target: https://github.com/legalsylvain
:alt: legalsylvain
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-legalsylvain|
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/16.0/sql_export_mail>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -1,16 +1,20 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "SQL Export Mail",
"version": "14.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Generic Modules",
"summary": "Send csv file generated by sql query by mail.",
"author": "Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/server-tools",
"depends": ["sql_export", "mail"],
"author": "Akretion,GRAP,Odoo Community Association (OCA)",
"maintainers": ["legalsylvain"],
"website": "https://github.com/OCA/reporting-engine",
"depends": [
"mail",
"sql_export",
],
"license": "AGPL-3",
"data": [
"views/sql_export_view.xml",
"mail_template.xml",
"data/mail_template.xml",
],
"installable": True,
}

View File

@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -37,31 +37,6 @@ msgid ""
" sql query with a cron to send mail automatically"
msgstr ""
#. module: sql_export_mail
#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__assigned_attachment_ids
msgid "Assigned Attachments"
msgstr ""
#. module: sql_export_mail
#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__changeset_change_ids
msgid "Changeset Changes"
msgstr ""
#. module: sql_export_mail
#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__changeset_ids
msgid "Changesets"
msgstr ""
#. module: sql_export_mail
#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__count_pending_changeset_changes
msgid "Count Pending Changeset Changes"
msgstr ""
#. module: sql_export_mail
#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__count_pending_changesets
msgid "Count Pending Changesets"
msgstr ""
#. module: sql_export_mail
#: model_terms:ir.ui.view,arch_db:sql_export_mail.sql_export_mail_view_form
msgid "Create Cron"
@@ -73,22 +48,13 @@ msgstr ""
msgid "Crons"
msgstr ""
#. module: sql_export_mail
#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__display_name
msgid "Display Name"
msgstr ""
#. module: sql_export_mail
#: model:ir.model.fields.selection,name:sql_export_mail.selection__sql_export__mail_condition__not_empty
msgid "File Not Empty"
msgstr ""
#. module: sql_export_mail
#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__id
msgid "ID"
msgstr ""
#. module: sql_export_mail
#. odoo-python
#: code:addons/sql_export_mail/models/sql_export.py:0
#, python-format
msgid ""
@@ -97,8 +63,8 @@ msgid ""
msgstr ""
#. module: sql_export_mail
#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export____last_update
msgid "Last Modified on"
#: model_terms:ir.ui.view,arch_db:sql_export_mail.sql_export_mail_view_form
msgid "Mail"
msgstr ""
#. module: sql_export_mail
@@ -106,27 +72,23 @@ msgstr ""
msgid "Mail Condition"
msgstr ""
#. module: sql_export_mail
#: model:mail.template,name:sql_export_mail.sql_export_mailer
msgid "SQL Export"
msgstr ""
#. module: sql_export_mail
#: model:ir.model,name:sql_export_mail.model_sql_export
msgid "SQL export"
msgstr ""
#. module: sql_export_mail
#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__smart_search
msgid "Smart Search"
msgstr ""
#. module: sql_export_mail
#. odoo-python
#: code:addons/sql_export_mail/models/sql_export.py:0
#, python-format
msgid "The user does not have any e-mail address."
msgstr ""
#. module: sql_export_mail
#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__user_can_see_changeset
msgid "User Can See Changeset"
msgstr ""
#. module: sql_export_mail
#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__mail_user_ids
msgid "User to notify"

View File

@@ -27,21 +27,23 @@ class SqlExport(models.Model):
[("not_empty", "File Not Empty")], default="not_empty"
)
def create_cron(self):
def _prepare_cron_mail(self):
self.ensure_one()
nextcall = datetime.now() + timedelta(hours=2)
cron_vals = {
return {
"active": True,
"model_id": self.env.ref("sql_export.model_sql_export").id,
"state": "code",
"code": "model._run_all_sql_export_for_cron()",
"name": "SQL Export : %s" % self.name,
"nextcall": nextcall,
"nextcall": datetime.now() + timedelta(hours=2),
"doall": False,
"numbercall": -1,
"user_id": SUPERUSER_ID,
}
cron = self.env["ir.cron"].create(cron_vals)
def create_cron(self):
self.ensure_one()
cron = self.env["ir.cron"].create(self._prepare_cron_mail())
# We need to pass cron_id in the cron args because a cron is not
# aware of itself in the end method and we need it to find all
# linked sql exports
@@ -51,24 +53,25 @@ class SqlExport(models.Model):
def send_mail(self, params=None):
self.ensure_one()
params = params or {}
mail_template = self.env.ref("sql_export_mail.sql_export_mailer")
attach_obj = self.env["ir.attachment"]
if self.mail_condition == "not_empty":
res = self._execute_sql_request(params=params, mode="fetchone")
if not res:
return
ctx = self.env.context.copy()
if params:
if "user_id" in params:
ctx["force_user"] = params["user_id"]
if "company_id" in params:
ctx["force_company"] = params["company_id"]
wizard = self.env["sql.file.wizard"].create(
{
"sql_export_id": self.id,
}
)
wizard.with_context(ctx).export_sql()
if "user_id" in params:
wizard = wizard.with_context(force_user=params["user_id"])
if "company_id" in params:
wizard = wizard.with_context(force_company=params["company_id"])
wizard.export_sql()
binary = wizard.binary_file
filename = wizard.file_name
msg_id = mail_template.send_mail(self.id, force_send=False)

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/14.0/sql_export_mail"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-sql_export_mail"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/16.0/sql_export_mail"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/reporting-engine-16-0/reporting-engine-16-0-sql_export_mail"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/143/16.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Allow to send the result of a query (made with the module sql_export) by mail.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
@@ -395,10 +395,10 @@ use it again for other queries</li>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>.
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20sql_export_mail%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20sql_export_mail%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@@ -407,6 +407,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
<ul class="simple">
<li>Akretion</li>
<li>GRAP</li>
</ul>
</div>
<div class="section" id="contributors">
@@ -423,7 +424,9 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/14.0/sql_export_mail">OCA/server-tools</a> project on GitHub.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/legalsylvain"><img alt="legalsylvain" src="https://github.com/legalsylvain.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/16.0/sql_export_mail">OCA/reporting-engine</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@@ -11,7 +11,6 @@
name="create_cron"
string="Create Cron"
type="object"
groups="base.group_system"
attrs="{'invisible': ['|', ('state', '=', 'draft'), ('mail_user_ids', '=', [(6, False, [])])]}"
/>
</button>
@@ -21,21 +20,27 @@
attrs="{'invisible': [('cron_ids', '=', [(6, False, [])])]}"
/>
</field>
<group name="parameters" position="after">
<group groups="sql_request_abstract.group_sql_request_user">
<group string="Users Notified by e-mail">
<field name="mail_user_ids" nolabel="1" />
</group>
<group string="Crons" groups="base.group_system">
<field
<page name="page_sql" position="after">
<page name="page_mail" string="Mail">
<group string="Users Notified by e-mail">
<field
name="mail_user_ids"
nolabel="1"
widget="many2many_tags"
colspan="2"
/>
</group>
<group string="Crons">
<field
name="cron_ids"
nolabel="1"
colspan="2"
domain="[('model_id', '=', 'sql.export')]"
groups="base.group_system"
/>
</group>
</group>
</group>
</group>
</page>
</page>
</field>
</record>