Skip to content

Commit

Permalink
Merge branch 'OCA:16.0' into 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BT-ssteiner authored Mar 14, 2024
2 parents 6c8a6f1 + 571bc0e commit cc5b605
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ addon | version | maintainers | summary
[report_xml](report_xml/) | 16.0.1.1.1 | | Allow to generate XML reports
[sql_export](sql_export/) | 16.0.2.1.0 | [![legalsylvain](https://github.com/legalsylvain.png?size=30px)](https://github.com/legalsylvain) | Export data in csv file with SQL requests
[sql_export_excel](sql_export_excel/) | 16.0.1.0.1 | | Allow to export a sql query to an excel file.
[sql_export_mail](sql_export_mail/) | 16.0.2.0.0 | [![legalsylvain](https://github.com/legalsylvain.png?size=30px)](https://github.com/legalsylvain) | Send csv file generated by sql query by mail.
[sql_export_mail](sql_export_mail/) | 16.0.2.0.1 | [![legalsylvain](https://github.com/legalsylvain.png?size=30px)](https://github.com/legalsylvain) | Send csv file generated by sql query by mail.
[sql_request_abstract](sql_request_abstract/) | 16.0.1.0.0 | [![legalsylvain](https://github.com/legalsylvain.png?size=30px)](https://github.com/legalsylvain) | Abstract Model to manage SQL Requests

[//]: # (end addons)
Expand Down
2 changes: 1 addition & 1 deletion sql_export_mail/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SQL Export Mail
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7545ca6358f23ee0f98d8fa0d2610030bdce7d1dc9a2b1e241be5443612fcf1e
!! source digest: sha256:4c0240a987c3a30a7b125286d9656111d9b2d2744838a58a88c4ae05f4b75e9c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion sql_export_mail/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": "16.0.2.0.1",
"category": "Generic Modules",
"summary": "Send csv file generated by sql query by mail.",
"author": "Akretion,GRAP,Odoo Community Association (OCA)",
Expand Down
3 changes: 1 addition & 2 deletions sql_export_mail/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -367,7 +366,7 @@ <h1 class="title">SQL Export Mail</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7545ca6358f23ee0f98d8fa0d2610030bdce7d1dc9a2b1e241be5443612fcf1e
!! source digest: sha256:4c0240a987c3a30a7b125286d9656111d9b2d2744838a58a88c4ae05f4b75e9c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" 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 image-reference" 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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Allow to send the result of a query (made with the module sql_export) by mail.</p>
Expand Down
50 changes: 47 additions & 3 deletions sql_export_mail/tests/test_sql_query_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import SUPERUSER_ID
from odoo.exceptions import UserError
from odoo.tests.common import TransactionCase


Expand All @@ -13,15 +14,58 @@ def setUp(self):
self.sql_report_demo.write({"mail_user_ids": [(4, SUPERUSER_ID)]})

def test_sql_query_mail(self):
mail_obj = self.env["mail.mail"]
mails = mail_obj.search(
"""Check the general execution"""
self.check_before_change()
self.check_execution()

def test_not_able_add_user(self):
"""if there are field_ids, mail_user_ids can not be set"""
sql_report_demo_with_partner = self.env.ref(
"sql_export.sql_export_partner_with_variables"
)
with self.assertRaises(UserError):
sql_report_demo_with_partner.write(
{"mail_user_ids": [(4, self.env.ref("base.user_demo").id)]}
)

def test_sql_query_mail_company(self):
"""Check the general execution with %(company_id)s"""
self.check_before_change()
self.sql_report_demo.write(
{
"mail_user_ids": [(4, self.env.ref("base.user_demo").id)],
"query": """SELECT name, street
FROM res_partner where company_id = %(company_id)s""",
}
)
self.check_execution()

def test_sql_query_mail_company_user(self):
"""Check the general execution with %(company_id)s and %(user_id)s)"""
self.check_before_change()
self.sql_report_demo.write(
{
"mail_user_ids": [(4, self.env.ref("base.user_demo").id)],
"query": """SELECT name, street FROM res_partner
where company_id = %(company_id)s and id in (
select partner_id from res_users where id = %(user_id)s)""",
}
)
self.check_execution()

def check_before_change(self):
"""Check if there are no mails before changing the sql report"""
mails = self.env["mail.mail"].search(
[("model", "=", "sql.export"), ("res_id", "=", self.sql_report_demo.id)]
)
self.assertFalse(mails)

def check_execution(self):
"""Check if the cron could be created and the mail sending is working"""
self.sql_report_demo.create_cron()
self.assertTrue(self.sql_report_demo.cron_ids)
self.sql_report_demo.cron_ids.method_direct_trigger()
mails = mail_obj.search(
mails = self.env["mail.mail"].search(
[("model", "=", "sql.export"), ("res_id", "=", self.sql_report_demo.id)]
)
self.assertTrue(mails)
Expand Down

0 comments on commit cc5b605

Please sign in to comment.