From 63bf5925faa2beb1237a14d4b3c7333967fec629 Mon Sep 17 00:00:00 2001 From: Sander Lienaerts Date: Mon, 15 Jan 2024 16:49:34 +0100 Subject: [PATCH] [MIG] sql_export_mail: Migration to 17.0 --- sql_export_mail/README.rst | 1 + sql_export_mail/__manifest__.py | 2 +- .../16.0.1.0.0/noupdate_changes.xml | 19 ------------------- .../migrations/16.0.1.0.0/post-migration.py | 8 -------- sql_export_mail/models/sql_export.py | 2 +- sql_export_mail/readme/CONTRIBUTORS.md | 1 + sql_export_mail/static/description/index.html | 1 + sql_export_mail/tests/test_sql_query_mail.py | 11 ++++++----- sql_export_mail/views/sql_export_view.xml | 8 ++------ 9 files changed, 13 insertions(+), 40 deletions(-) delete mode 100644 sql_export_mail/migrations/16.0.1.0.0/noupdate_changes.xml delete mode 100644 sql_export_mail/migrations/16.0.1.0.0/post-migration.py diff --git a/sql_export_mail/README.rst b/sql_export_mail/README.rst index 96db705ab..ed06fe1f9 100644 --- a/sql_export_mail/README.rst +++ b/sql_export_mail/README.rst @@ -72,6 +72,7 @@ Contributors - Florian da Costa - Helly kapatel +- Sander Lienaerts Maintainers ----------- diff --git a/sql_export_mail/__manifest__.py b/sql_export_mail/__manifest__.py index 371758df0..da30068ae 100644 --- a/sql_export_mail/__manifest__.py +++ b/sql_export_mail/__manifest__.py @@ -1,7 +1,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "SQL Export Mail", - "version": "16.0.2.0.0", + "version": "17.0.1.0.0", "category": "Generic Modules", "summary": "Send csv file generated by sql query by mail.", "author": "Akretion,GRAP,Odoo Community Association (OCA)", diff --git a/sql_export_mail/migrations/16.0.1.0.0/noupdate_changes.xml b/sql_export_mail/migrations/16.0.1.0.0/noupdate_changes.xml deleted file mode 100644 index fe76bd1f4..000000000 --- a/sql_export_mail/migrations/16.0.1.0.0/noupdate_changes.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - {{object.get_email_address_for_template()}} - {{object.name or ''}} - -
- -

You will find the report as an attachment of the mail.

- -
-
-
-
diff --git a/sql_export_mail/migrations/16.0.1.0.0/post-migration.py b/sql_export_mail/migrations/16.0.1.0.0/post-migration.py deleted file mode 100644 index bea37ae39..000000000 --- a/sql_export_mail/migrations/16.0.1.0.0/post-migration.py +++ /dev/null @@ -1,8 +0,0 @@ -from openupgradelib import openupgrade - - -@openupgrade.migrate() -def migrate(env, version): - openupgrade.load_data( - env.cr, "sql_export_mail", "migrations/16.0.1.0.0/noupdate_changes.xml" - ) diff --git a/sql_export_mail/models/sql_export.py b/sql_export_mail/models/sql_export.py index 488b9381d..97959e4d5 100644 --- a/sql_export_mail/models/sql_export.py +++ b/sql_export_mail/models/sql_export.py @@ -99,7 +99,7 @@ class SqlExport(models.Model): companies = self.env["res.company"].search([]) for company in companies: users = export.mail_user_ids.filtered( - lambda u: u.company_id == company + lambda user, company=company: user.company_id == company ) if users: variable_dict["company_id"] = users[0].company_id.id diff --git a/sql_export_mail/readme/CONTRIBUTORS.md b/sql_export_mail/readme/CONTRIBUTORS.md index 17ad1ef72..72fff7d37 100644 --- a/sql_export_mail/readme/CONTRIBUTORS.md +++ b/sql_export_mail/readme/CONTRIBUTORS.md @@ -1,2 +1,3 @@ - Florian da Costa \<\> - Helly kapatel \<\> +- Sander Lienaerts \<\> diff --git a/sql_export_mail/static/description/index.html b/sql_export_mail/static/description/index.html index b35f1f689..2397b726a 100644 --- a/sql_export_mail/static/description/index.html +++ b/sql_export_mail/static/description/index.html @@ -419,6 +419,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
diff --git a/sql_export_mail/tests/test_sql_query_mail.py b/sql_export_mail/tests/test_sql_query_mail.py index 8de0ce9d0..a7543f55f 100644 --- a/sql_export_mail/tests/test_sql_query_mail.py +++ b/sql_export_mail/tests/test_sql_query_mail.py @@ -2,15 +2,16 @@ # @author: Florian da Costa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import SUPERUSER_ID +from odoo import SUPERUSER_ID, Command from odoo.tests.common import TransactionCase class TestExportSqlQueryMail(TransactionCase): - def setUp(self): - super(TestExportSqlQueryMail, self).setUp() - self.sql_report_demo = self.env.ref("sql_export.sql_export_partner") - self.sql_report_demo.write({"mail_user_ids": [(4, SUPERUSER_ID)]}) + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.sql_report_demo = cls.env.ref("sql_export.sql_export_partner") + cls.sql_report_demo.mail_user_ids = [Command.link(SUPERUSER_ID)] def test_sql_query_mail(self): mail_obj = self.env["mail.mail"] diff --git a/sql_export_mail/views/sql_export_view.xml b/sql_export_mail/views/sql_export_view.xml index 9a9b7aea9..67ca01edb 100644 --- a/sql_export_mail/views/sql_export_view.xml +++ b/sql_export_mail/views/sql_export_view.xml @@ -1,7 +1,5 @@ - - sql.export @@ -11,13 +9,13 @@ name="create_cron" string="Create Cron" type="object" - attrs="{'invisible': ['|', ('state', '=', 'draft'), ('mail_user_ids', '=', [(6, False, [])])]}" + invisible="state == 'draft' or not mail_user_ids" /> @@ -39,10 +37,8 @@ domain="[('model_id', '=', 'sql.export')]" /> - -