From ae9d35081e7f0d02d3c09951b1c44cfa9d80f7a3 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Mon, 17 Jul 2017 17:44:13 +0200 Subject: [PATCH 01/18] Add module sql_export_mail --- sql_export_mail/README.rst | 65 ++++++++ sql_export_mail/__init__.py | 1 + sql_export_mail/__openerp__.py | 39 +++++ sql_export_mail/i18n/fr.po | 94 +++++++++++ sql_export_mail/i18n/sql_export_mail.pot | 89 +++++++++++ sql_export_mail/mail_template.xml | 28 ++++ sql_export_mail/models/__init__.py | 1 + sql_export_mail/models/sql_export.py | 155 +++++++++++++++++++ sql_export_mail/tests/__init__.py | 2 + sql_export_mail/tests/test_sql_query_mail.py | 33 ++++ sql_export_mail/views/sql_export_view.xml | 31 ++++ sql_export_mail/wizard/__init__.py | 1 + sql_export_mail/wizard/wizard_file.py | 106 +++++++++++++ sql_export_mail/wizard/wizard_file_view.xml | 27 ++++ 14 files changed, 672 insertions(+) create mode 100644 sql_export_mail/README.rst create mode 100644 sql_export_mail/__init__.py create mode 100644 sql_export_mail/__openerp__.py create mode 100644 sql_export_mail/i18n/fr.po create mode 100644 sql_export_mail/i18n/sql_export_mail.pot create mode 100644 sql_export_mail/mail_template.xml create mode 100644 sql_export_mail/models/__init__.py create mode 100644 sql_export_mail/models/sql_export.py create mode 100644 sql_export_mail/tests/__init__.py create mode 100644 sql_export_mail/tests/test_sql_query_mail.py create mode 100644 sql_export_mail/views/sql_export_view.xml create mode 100644 sql_export_mail/wizard/__init__.py create mode 100644 sql_export_mail/wizard/wizard_file.py create mode 100644 sql_export_mail/wizard/wizard_file_view.xml diff --git a/sql_export_mail/README.rst b/sql_export_mail/README.rst new file mode 100644 index 000000000..c575b0034 --- /dev/null +++ b/sql_export_mail/README.rst @@ -0,0 +1,65 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +SQL Export Mail +=============== + +Allow to send the result of a query (made with the module sql_export) by mail. + + +Configuration +============= + +To configure this module, you need to: + +#. Go to the sql query for which you want users to be notified by e-mail. +#. Add users to be notified in the field Users Notified by e-mail. +#. Click on the button create a cron and then configure the cron to run when + you want to. If you already have created a cron for another query, you can + use it again for other queries + +Usage +===== + +To use this module, you need to: + +#. Go to ... + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/149/10.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Florian da Costa + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + diff --git a/sql_export_mail/__init__.py b/sql_export_mail/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/sql_export_mail/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sql_export_mail/__openerp__.py b/sql_export_mail/__openerp__.py new file mode 100644 index 000000000..58b11ef5a --- /dev/null +++ b/sql_export_mail/__openerp__.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2015 Akretion (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': 'SQL Export Mail', + 'version': '8.0.1.0.0', + 'author': 'Akretion,Odoo Community Association (OCA)', + 'website': 'http://www.akretion.com', + 'license': 'AGPL-3', + 'category': 'Generic Modules/Others', + 'summary': 'Export data in csv file with SQL requests', + 'depends': [ + 'sql_export', + 'mail', + ], + 'data': [ + 'views/sql_export_view.xml', + 'mail_template.xml', + ], + 'installable': True, + } diff --git a/sql_export_mail/i18n/fr.po b/sql_export_mail/i18n/fr.po new file mode 100644 index 000000000..9bbd26c72 --- /dev/null +++ b/sql_export_mail/i18n/fr.po @@ -0,0 +1,94 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sql_export_mail +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-18 13:15+0000\n" +"PO-Revision-Date: 2017-07-18 13:15+0000\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: sql_export_mail +#: model:email.template,body_html:sql_export_mail.sql_export_mailer +msgid "\n" +"
\n" +"\n" +"

You will find the report ${object.name or ''} as an attachment of the mail.

\n" +"\n" +"
\n" +" " +msgstr "\n" +"
\n" +"\n" +"

Vous trouverez le rapport ${object.name or ''} en pièce jointe de ce mail.

\n" +"\n" +"
\n" +" " + +#. module: sql_export_mail +#: model:email.template,subject:sql_export_mail.sql_export_mailer +msgid "${object.name or ''}" +msgstr "${object.name or ''}" + +#. module: sql_export_mail +#: help:sql.export,mail_user_ids:0 +msgid "Add the users who want to receive the report by e-mail. You need to link the sql query with a cron to send mail automatically" +msgstr "Ajoutez les utilisateurs voulant recevoir le rapport par mail. Vous devez ensuite créer une tâche planifiée pour envoyer le mail automatiquement." + +#. module: sql_export_mail +#: view:sql.export:sql_export_mail.sql_export_mail_view_form +msgid "Create Cron" +msgstr "Créer une tâche planfiée" + +#. module: sql_export_mail +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export_cron_ids +#: view:sql.export:sql_export_mail.sql_export_mail_view_form +#: field:sql.export,cron_ids:0 +msgid "Crons" +msgstr "Tâches planifiées" + +#. module: sql_export_mail +#: selection:sql.export,mail_condition:0 +msgid "File Not Empty" +msgstr "Fichier non vide." + +#. module: sql_export_mail +#: code:addons/sql_export_mail/models/sql_export.py:126 +#, python-format +msgid "It is not possible to execute and send a query automatically by e-mail if there are parameters to fill" +msgstr "Il n'est pas possible d'exécuter en envoyer le résultat d'une requête par mail si celle-ci contient des paramètres." + +#. module: sql_export_mail +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export_mail_condition +#: field:sql.export,mail_condition:0 +msgid "Mail condition" +msgstr "Condition d'envoi par mail" + +#. module: sql_export_mail +#: model:ir.model,name:sql_export_mail.model_sql_export +msgid "SQL export" +msgstr "Export SQL" + +#. module: sql_export_mail +#: code:addons/sql_export_mail/models/sql_export.py:135 +#, python-format +msgid "The user does not have any e-mail address." +msgstr "L'utilisateur selectionné n'a pas d'addresse mail." + +#. module: sql_export_mail +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export_mail_user_ids +#: field:sql.export,mail_user_ids:0 +msgid "User to notify" +msgstr "Utilisateurs à notifier par mail" + +#. module: sql_export_mail +#: view:sql.export:sql_export_mail.sql_export_mail_view_form +msgid "Users Notified by e-mail" +msgstr "Utilisateurs notifiés par mail" diff --git a/sql_export_mail/i18n/sql_export_mail.pot b/sql_export_mail/i18n/sql_export_mail.pot new file mode 100644 index 000000000..a27de68f6 --- /dev/null +++ b/sql_export_mail/i18n/sql_export_mail.pot @@ -0,0 +1,89 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sql_export_mail +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-18 13:24+0000\n" +"PO-Revision-Date: 2017-07-18 13:24+0000\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: sql_export_mail +#: model:email.template,body_html:sql_export_mail.sql_export_mailer +msgid "\n" +"
\n" +"\n" +"

You will find the report ${object.name or ''} as an attachment of the mail.

\n" +"\n" +"
\n" +" " +msgstr "" + +#. module: sql_export_mail +#: model:email.template,subject:sql_export_mail.sql_export_mailer +msgid "${object.name or ''}" +msgstr "" + +#. module: sql_export_mail +#: help:sql.export,mail_user_ids:0 +msgid "Add the users who want to receive the report by e-mail. You need to link the sql query with a cron to send mail automatically" +msgstr "" + +#. module: sql_export_mail +#: view:sql.export:sql_export_mail.sql_export_mail_view_form +msgid "Create Cron" +msgstr "" + +#. module: sql_export_mail +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export_cron_ids +#: view:sql.export:sql_export_mail.sql_export_mail_view_form +#: field:sql.export,cron_ids:0 +msgid "Crons" +msgstr "" + +#. module: sql_export_mail +#: selection:sql.export,mail_condition:0 +msgid "File Not Empty" +msgstr "" + +#. module: sql_export_mail +#: code:addons/sql_export_mail/models/sql_export.py:126 +#, python-format +msgid "It is not possible to execute and send a query automatically by e-mail if there are parameters to fill" +msgstr "" + +#. module: sql_export_mail +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export_mail_condition +#: field:sql.export,mail_condition:0 +msgid "Mail condition" +msgstr "" + +#. module: sql_export_mail +#: model:ir.model,name:sql_export_mail.model_sql_export +msgid "SQL export" +msgstr "" + +#. module: sql_export_mail +#: code:addons/sql_export_mail/models/sql_export.py:135 +#, 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_mail_user_ids +#: field:sql.export,mail_user_ids:0 +msgid "User to notify" +msgstr "" + +#. module: sql_export_mail +#: view:sql.export:sql_export_mail.sql_export_mail_view_form +msgid "Users Notified by e-mail" +msgstr "" + diff --git a/sql_export_mail/mail_template.xml b/sql_export_mail/mail_template.xml new file mode 100644 index 000000000..db5599c6a --- /dev/null +++ b/sql_export_mail/mail_template.xml @@ -0,0 +1,28 @@ + + + + + + + + + SQL Export + admin@example.com + ${object.get_email_address_for_template()} + ${object.name or ''} + + + + +

You will find the report ${object.name or ''} as an attachment of the mail.

+ + + ]]>
+
+ +
+
diff --git a/sql_export_mail/models/__init__.py b/sql_export_mail/models/__init__.py new file mode 100644 index 000000000..014462062 --- /dev/null +++ b/sql_export_mail/models/__init__.py @@ -0,0 +1 @@ +from . import sql_export diff --git a/sql_export_mail/models/sql_export.py b/sql_export_mail/models/sql_export.py new file mode 100644 index 000000000..ca84a47ab --- /dev/null +++ b/sql_export_mail/models/sql_export.py @@ -0,0 +1,155 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2017 Akretion (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, fields, api, _ +from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT +from openerp.exceptions import Warning as UserError +from datetime import datetime, timedelta +from openerp import SUPERUSER_ID + + +class SqlExport(models.Model): + _inherit = 'sql.export' + + mail_user_ids = fields.Many2many( + 'res.users', + 'mail_user_sqlquery_rel', + 'sql_id', + 'user_id', + 'User to notify', + help='Add the users who want to receive the report by e-mail. You ' + 'need to link the sql query with a cron to send mail automatically') + cron_ids = fields.Many2many( + 'ir.cron', + 'cron_sqlquery_rel', + 'sql_id', + 'cron_id', + 'Crons') + # We could implement other conditions, that is why it is a selection field + mail_condition = fields.Selection( + [('not_empty', 'File Not Empty')], default='not_empty') + + @api.multi + def create_cron(self): + self.ensure_one() + nextcall = datetime.now() + timedelta(hours=2) + nextcall_fmt = datetime.strftime(nextcall, + DEFAULT_SERVER_DATETIME_FORMAT) + cron_vals = { + 'active': True, + 'model': 'sql.export', + 'function': '_run_all_sql_export_for_cron', + 'name': 'SQL Export : %s' % self.name, + 'nextcall': nextcall_fmt, + 'doall': False, + 'numbercall': -1, + 'user_id': SUPERUSER_ID, + } + cron = self.env['ir.cron'].create(cron_vals) + write_vals = {'args': '[[%s]]' % cron.id} + cron.write(write_vals) + + self.write({'cron_ids': [(4, cron.id)]}) + + @api.one + def send_mail(self, params=None): + mail_template = self.env.ref('sql_export_mail.sql_export_mailer') + now_time = datetime.strftime(datetime.now(), + DEFAULT_SERVER_DATETIME_FORMAT) + 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 + + binary = self._execute_sql_request( + params=params, mode='stdout', copy_options=self.copy_options) + attach_vals = { + 'name': now_time + ' - ' + self.name, + 'datas_fname': now_time + ' - ' + self.name + '.csv', + 'datas': binary, + } + attachment = attach_obj.create(attach_vals) + msg_id = mail_template.send_mail(self.id, force_send=False) + mail = self.env['mail.mail'].browse(msg_id) + mail.write({'attachment_ids': [(4, attachment.id)]}) + + @api.model + def _run_all_sql_export_for_cron(self, cron_ids): + exports = self.search([('cron_ids', 'in', cron_ids)]) + for export in exports: + if "%(company_id)s" in export.query and \ + "%(user_id)s" not in export.query: + variable_dict = {} + companies = self.env['res.company'].search([]) + for company in companies: + users = export.mail_user_ids.filtered( + lambda u: u.company_id == company) + if users: + variable_dict['company_id'] = users[0].company_id.id + export.with_context(mail_to=users.ids).send_mail( + params=variable_dict) + elif "%(user_id)s" in export.query: + variable_dict = {} + for user in export.mail_user_ids: + variable_dict['user_id'] = user.id + if "%(company_id)s" in export.query: + variable_dict['company_id'] = user.company_id.id + export.with_context(mail_to=[user.id]).send_mail( + params=variable_dict) + else: + export.send_mail() + + @api.one + @api.constrains('field_ids', 'mail_user_ids') + def check_no_parameter_if_sent_by_mail(self): + if self.field_ids and self.mail_user_ids: + raise UserError(_( + "It is not possible to execute and send a query automatically" + " by e-mail if there are parameters to fill")) + + @api.one + @api.constrains('mail_user_ids') + def check_mail_user(self): + for user in self.mail_user_ids: + if not user.email: + raise UserError(_( + "The user does not have any e-mail address.")) + + @api.multi + def get_email_address_for_template(self): + """ + Called from mail template + """ + self.ensure_one() + if self.env.context.get('mail_to'): + mail_users = self.env['res.users'].browse( + self.env.context.get('mail_to')) + else: + mail_users = self.mail_user_ids + emails = '' + for user in mail_users: + if emails and user.email: + emails += ',' + user.email + elif user.email: + emails += user.email + return emails diff --git a/sql_export_mail/tests/__init__.py b/sql_export_mail/tests/__init__.py new file mode 100644 index 000000000..1d119c788 --- /dev/null +++ b/sql_export_mail/tests/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import test_sql_query_mail diff --git a/sql_export_mail/tests/test_sql_query_mail.py b/sql_export_mail/tests/test_sql_query_mail.py new file mode 100644 index 000000000..45bc2d2d3 --- /dev/null +++ b/sql_export_mail/tests/test_sql_query_mail.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2017 Akretion () +# @author: Florian da Costa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp.tests.common import TransactionCase +from openerp import SUPERUSER_ID + + +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)]}) + + def test_sql_query_create_cron(self): + self.sql_report_demo.create_cron() + self.assertTrue(self.sql_report_demo.cron_ids) + cron = self.sql_report_demo.cron_ids + self.assertEqual(cron.function, '_run_all_sql_export_for_cron') + + def test_sql_query_mail(self): + mail_obj = self.env['mail.mail'] + mails = mail_obj.search( + [('model', '=', 'sql.export'), + ('res_id', '=', self.sql_report_demo.id)]) + self.assertFalse(mails) + self.sql_report_demo.send_mail() + mails = mail_obj.search( + [('model', '=', 'sql.export'), + ('res_id', '=', self.sql_report_demo.id)]) + self.assertTrue(mails) diff --git a/sql_export_mail/views/sql_export_view.xml b/sql_export_mail/views/sql_export_view.xml new file mode 100644 index 000000000..a2f0fe781 --- /dev/null +++ b/sql_export_mail/views/sql_export_view.xml @@ -0,0 +1,31 @@ + + + + + + + sql.export + + + + + + + + + + + + + + + + + + + + + diff --git a/sql_export_mail/wizard/__init__.py b/sql_export_mail/wizard/__init__.py new file mode 100644 index 000000000..ddf406aa1 --- /dev/null +++ b/sql_export_mail/wizard/__init__.py @@ -0,0 +1 @@ +from . import wizard_file diff --git a/sql_export_mail/wizard/wizard_file.py b/sql_export_mail/wizard/wizard_file.py new file mode 100644 index 000000000..3f62198a7 --- /dev/null +++ b/sql_export_mail/wizard/wizard_file.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2015 Akretion (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import datetime +from lxml import etree + +from openerp import models, fields, api, osv +from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT + + +class SqlFileWizard(models.TransientModel): + _name = "sql.file.wizard" + _description = "Allow the user to save the file with sql request's data" + + binary_file = fields.Binary('File', readonly=True) + file_name = fields.Char('File Name', readonly=True) + sql_export_id = fields.Many2one(comodel_name='sql.export', required=True) + + @api.model + def fields_view_get(self, view_id=None, view_type='form', + toolbar=False, submenu=False): + """ + Display dinamicaly parameter fields depending on the sql_export. + """ + res = super(SqlFileWizard, self).fields_view_get( + view_id=view_id, view_type=view_type, toolbar=toolbar, + submenu=submenu) + export_obj = self.env['sql.export'] + if view_type == 'form': + sql_export = export_obj.browse(self._context.get('active_id')) + if sql_export.field_ids: + eview = etree.fromstring(res['arch']) + group = etree.Element( + 'group', name="variables_group", colspan="4") + toupdate_fields = [] + for field in sql_export.field_ids: + kwargs = {'name': "%s" % field.name} + toupdate_fields.append(field.name) + view_field = etree.SubElement(group, 'field', **kwargs) + osv.orm.setup_modifiers( + view_field, self.fields_get(field.name)) + + res['fields'].update(self.fields_get(toupdate_fields)) + placeholder = eview.xpath( + "//separator[@string='variables_placeholder']")[0] + placeholder.getparent().replace( + placeholder, group) + res['arch'] = etree.tostring(eview, pretty_print=True) + return res + + @api.multi + def export_sql(self): + self.ensure_one() + sql_export = self.sql_export_id + + # Manage Params + variable_dict = {} + today = datetime.datetime.now() + today_tz = fields.Datetime.context_timestamp( + sql_export, today) + date = today_tz.strftime(DEFAULT_SERVER_DATETIME_FORMAT) + if sql_export.field_ids: + for field in sql_export.field_ids: + variable_dict[field.name] = self[field.name] + if "%(company_id)s" in sql_export.query: + variable_dict['company_id'] = self.env.user.company_id.id + if "%(user_id)s" in sql_export.query: + variable_dict['user_id'] = self._uid + + # Execute Request + res = sql_export._execute_sql_request( + params=variable_dict, mode='stdout', + copy_options=sql_export.copy_options) + + self.write({ + 'binary_file': res, + 'file_name': sql_export.name + '_' + date + '.csv' + }) + return { + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'sql.file.wizard', + 'res_id': self.id, + 'type': 'ir.actions.act_window', + 'target': 'new', + 'context': self._context, + 'nodestroy': True, + } diff --git a/sql_export_mail/wizard/wizard_file_view.xml b/sql_export_mail/wizard/wizard_file_view.xml new file mode 100644 index 000000000..162bcccb5 --- /dev/null +++ b/sql_export_mail/wizard/wizard_file_view.xml @@ -0,0 +1,27 @@ + + + + + + sql.file.wizard.view.form + sql.file.wizard + +
+ + + + +
+
+ +
+
+ +
+
From e7d8b244b80556634008987f96e9e06253a31ef2 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Thu, 23 Nov 2017 11:55:13 +0100 Subject: [PATCH 02/18] Remove useless files --- sql_export_mail/README.rst | 13 ++- sql_export_mail/wizard/__init__.py | 1 - sql_export_mail/wizard/wizard_file.py | 106 -------------------- sql_export_mail/wizard/wizard_file_view.xml | 27 ----- 4 files changed, 6 insertions(+), 141 deletions(-) delete mode 100644 sql_export_mail/wizard/__init__.py delete mode 100644 sql_export_mail/wizard/wizard_file.py delete mode 100644 sql_export_mail/wizard/wizard_file_view.xml diff --git a/sql_export_mail/README.rst b/sql_export_mail/README.rst index c575b0034..31233db35 100644 --- a/sql_export_mail/README.rst +++ b/sql_export_mail/README.rst @@ -1,6 +1,8 @@ .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :alt: License: AGPL-3 + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +=============== SQL Export Mail =============== @@ -21,13 +23,9 @@ To configure this module, you need to: Usage ===== -To use this module, you need to: - -#. Go to ... - .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/149/10.0 + :target: https://runbot.odoo-community.org/runbot/149/8.0 Bug Tracker =========== @@ -35,7 +33,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, -help us smash it by providing detailed and welcomed feedback. +help us smashing it by providing a detailed and welcomed feedback. Credits ======= @@ -63,3 +61,4 @@ 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. +To contribute to this module, please visit https://odoo-community.org. diff --git a/sql_export_mail/wizard/__init__.py b/sql_export_mail/wizard/__init__.py deleted file mode 100644 index ddf406aa1..000000000 --- a/sql_export_mail/wizard/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import wizard_file diff --git a/sql_export_mail/wizard/wizard_file.py b/sql_export_mail/wizard/wizard_file.py deleted file mode 100644 index 3f62198a7..000000000 --- a/sql_export_mail/wizard/wizard_file.py +++ /dev/null @@ -1,106 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2015 Akretion (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -import datetime -from lxml import etree - -from openerp import models, fields, api, osv -from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT - - -class SqlFileWizard(models.TransientModel): - _name = "sql.file.wizard" - _description = "Allow the user to save the file with sql request's data" - - binary_file = fields.Binary('File', readonly=True) - file_name = fields.Char('File Name', readonly=True) - sql_export_id = fields.Many2one(comodel_name='sql.export', required=True) - - @api.model - def fields_view_get(self, view_id=None, view_type='form', - toolbar=False, submenu=False): - """ - Display dinamicaly parameter fields depending on the sql_export. - """ - res = super(SqlFileWizard, self).fields_view_get( - view_id=view_id, view_type=view_type, toolbar=toolbar, - submenu=submenu) - export_obj = self.env['sql.export'] - if view_type == 'form': - sql_export = export_obj.browse(self._context.get('active_id')) - if sql_export.field_ids: - eview = etree.fromstring(res['arch']) - group = etree.Element( - 'group', name="variables_group", colspan="4") - toupdate_fields = [] - for field in sql_export.field_ids: - kwargs = {'name': "%s" % field.name} - toupdate_fields.append(field.name) - view_field = etree.SubElement(group, 'field', **kwargs) - osv.orm.setup_modifiers( - view_field, self.fields_get(field.name)) - - res['fields'].update(self.fields_get(toupdate_fields)) - placeholder = eview.xpath( - "//separator[@string='variables_placeholder']")[0] - placeholder.getparent().replace( - placeholder, group) - res['arch'] = etree.tostring(eview, pretty_print=True) - return res - - @api.multi - def export_sql(self): - self.ensure_one() - sql_export = self.sql_export_id - - # Manage Params - variable_dict = {} - today = datetime.datetime.now() - today_tz = fields.Datetime.context_timestamp( - sql_export, today) - date = today_tz.strftime(DEFAULT_SERVER_DATETIME_FORMAT) - if sql_export.field_ids: - for field in sql_export.field_ids: - variable_dict[field.name] = self[field.name] - if "%(company_id)s" in sql_export.query: - variable_dict['company_id'] = self.env.user.company_id.id - if "%(user_id)s" in sql_export.query: - variable_dict['user_id'] = self._uid - - # Execute Request - res = sql_export._execute_sql_request( - params=variable_dict, mode='stdout', - copy_options=sql_export.copy_options) - - self.write({ - 'binary_file': res, - 'file_name': sql_export.name + '_' + date + '.csv' - }) - return { - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'sql.file.wizard', - 'res_id': self.id, - 'type': 'ir.actions.act_window', - 'target': 'new', - 'context': self._context, - 'nodestroy': True, - } diff --git a/sql_export_mail/wizard/wizard_file_view.xml b/sql_export_mail/wizard/wizard_file_view.xml deleted file mode 100644 index 162bcccb5..000000000 --- a/sql_export_mail/wizard/wizard_file_view.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - sql.file.wizard.view.form - sql.file.wizard - -
- - - - -
-
- -
-
- -
-
From 172b2a99b98212c016db93f719f8084b28351388 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Thu, 23 Nov 2017 23:39:16 +0100 Subject: [PATCH 03/18] styles and decorator fixes --- sql_export_mail/__openerp__.py | 21 ++----------- sql_export_mail/i18n/fr.po | 2 +- sql_export_mail/models/sql_export.py | 46 ++++++++++------------------ 3 files changed, 19 insertions(+), 50 deletions(-) diff --git a/sql_export_mail/__openerp__.py b/sql_export_mail/__openerp__.py index 58b11ef5a..992b0814b 100644 --- a/sql_export_mail/__openerp__.py +++ b/sql_export_mail/__openerp__.py @@ -1,23 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2015 Akretion (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# Copyright 2017 Akretion +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { 'name': 'SQL Export Mail', diff --git a/sql_export_mail/i18n/fr.po b/sql_export_mail/i18n/fr.po index 9bbd26c72..483f13599 100644 --- a/sql_export_mail/i18n/fr.po +++ b/sql_export_mail/i18n/fr.po @@ -62,7 +62,7 @@ msgstr "Fichier non vide." #. module: sql_export_mail #: code:addons/sql_export_mail/models/sql_export.py:126 #, python-format -msgid "It is not possible to execute and send a query automatically by e-mail if there are parameters to fill" +msgid "It is not possible to execute and send a query automatically by mail if there are parameters to fill" msgstr "Il n'est pas possible d'exécuter en envoyer le résultat d'une requête par mail si celle-ci contient des paramètres." #. module: sql_export_mail diff --git a/sql_export_mail/models/sql_export.py b/sql_export_mail/models/sql_export.py index ca84a47ab..6ee4d04bf 100644 --- a/sql_export_mail/models/sql_export.py +++ b/sql_export_mail/models/sql_export.py @@ -1,23 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2017 Akretion (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# Copyright 2017 Akretion +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from openerp import models, fields, api, _ from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT @@ -69,8 +52,9 @@ class SqlExport(models.Model): self.write({'cron_ids': [(4, cron.id)]}) - @api.one + @api.multi def send_mail(self, params=None): + self.ensure_one() mail_template = self.env.ref('sql_export_mail.sql_export_mailer') now_time = datetime.strftime(datetime.now(), DEFAULT_SERVER_DATETIME_FORMAT) @@ -119,21 +103,23 @@ class SqlExport(models.Model): else: export.send_mail() - @api.one + @api.multi @api.constrains('field_ids', 'mail_user_ids') def check_no_parameter_if_sent_by_mail(self): - if self.field_ids and self.mail_user_ids: - raise UserError(_( - "It is not possible to execute and send a query automatically" - " by e-mail if there are parameters to fill")) + for export in self: + if export.field_ids and export.mail_user_ids: + raise UserError(_( + "It is not possible to execute and send a query " + "automatically by mail if there are parameters to fill")) - @api.one + @api.multi @api.constrains('mail_user_ids') def check_mail_user(self): - for user in self.mail_user_ids: - if not user.email: - raise UserError(_( - "The user does not have any e-mail address.")) + for export in self: + for user in export.mail_user_ids: + if not user.email: + raise UserError(_( + "The user does not have any e-mail address.")) @api.multi def get_email_address_for_template(self): From 5ab9082d1e39a64368a4aaf6c9a6249db4c73da0 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Wed, 12 Jun 2019 19:01:16 +0200 Subject: [PATCH 04/18] Migrate sql_export_mail to v9 --- sql_export_mail/README.rst | 64 -------------------- sql_export_mail/__openerp__.py | 8 +-- sql_export_mail/mail_template.xml | 34 +++++------ sql_export_mail/models/sql_export.py | 13 ++-- sql_export_mail/readme/CONFIGURE.rst | 7 +++ sql_export_mail/readme/CONTRIBUTORS.rst | 1 + sql_export_mail/readme/DESCRIPTION.rst | 1 + sql_export_mail/tests/test_sql_query_mail.py | 2 +- 8 files changed, 37 insertions(+), 93 deletions(-) delete mode 100644 sql_export_mail/README.rst create mode 100644 sql_export_mail/readme/CONFIGURE.rst create mode 100644 sql_export_mail/readme/CONTRIBUTORS.rst create mode 100644 sql_export_mail/readme/DESCRIPTION.rst diff --git a/sql_export_mail/README.rst b/sql_export_mail/README.rst deleted file mode 100644 index 31233db35..000000000 --- a/sql_export_mail/README.rst +++ /dev/null @@ -1,64 +0,0 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 - -=============== -SQL Export Mail -=============== - -Allow to send the result of a query (made with the module sql_export) by mail. - - -Configuration -============= - -To configure this module, you need to: - -#. Go to the sql query for which you want users to be notified by e-mail. -#. Add users to be notified in the field Users Notified by e-mail. -#. Click on the button create a cron and then configure the cron to run when - you want to. If you already have created a cron for another query, you can - use it again for other queries - -Usage -===== - -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/149/8.0 - -Bug Tracker -=========== - -Bugs are tracked on `GitHub 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. - -Credits -======= - -Images ------- - -* Odoo Community Association: `Icon `_. - -Contributors ------------- - -* Florian da Costa - -Maintainer ----------- - -.. image:: https://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: https://odoo-community.org - -This module is maintained by the OCA. - -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. - -To contribute to this module, please visit https://odoo-community.org. diff --git a/sql_export_mail/__openerp__.py b/sql_export_mail/__openerp__.py index 992b0814b..d2b84f565 100644 --- a/sql_export_mail/__openerp__.py +++ b/sql_export_mail/__openerp__.py @@ -1,15 +1,15 @@ # -*- coding: utf-8 -*- -# Copyright 2017 Akretion +# Copyright 2019 Akretion # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { 'name': 'SQL Export Mail', - 'version': '8.0.1.0.0', + 'version': '9.0.1.0.0', 'author': 'Akretion,Odoo Community Association (OCA)', - 'website': 'http://www.akretion.com', + 'website': 'http://github/oca/server-tools', 'license': 'AGPL-3', 'category': 'Generic Modules/Others', - 'summary': 'Export data in csv file with SQL requests', + 'summary': 'Send csv file generated by sql query by mail.', 'depends': [ 'sql_export', 'mail', diff --git a/sql_export_mail/mail_template.xml b/sql_export_mail/mail_template.xml index db5599c6a..0bb497d32 100644 --- a/sql_export_mail/mail_template.xml +++ b/sql_export_mail/mail_template.xml @@ -1,28 +1,24 @@ - - - + + - - - SQL Export - admin@example.com - ${object.get_email_address_for_template()} - ${object.name or ''} - - - + + SQL Export + admin@example.com + ${object.get_email_address_for_template()} + ${object.name or ''} + + +

You will find the report ${object.name or ''} as an attachment of the mail.

- ]]>
-
+ ]]>
+
-
-
+ + diff --git a/sql_export_mail/models/sql_export.py b/sql_export_mail/models/sql_export.py index 6ee4d04bf..6b0b5a74c 100644 --- a/sql_export_mail/models/sql_export.py +++ b/sql_export_mail/models/sql_export.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2017 Akretion +# Copyright 2019 Akretion # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from openerp import models, fields, api, _ @@ -47,9 +47,11 @@ class SqlExport(models.Model): 'user_id': SUPERUSER_ID, } cron = self.env['ir.cron'].create(cron_vals) + # 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 write_vals = {'args': '[[%s]]' % cron.id} cron.write(write_vals) - self.write({'cron_ids': [(4, cron.id)]}) @api.multi @@ -64,17 +66,18 @@ class SqlExport(models.Model): params=params, mode='fetchone') if not res: return - binary = self._execute_sql_request( params=params, mode='stdout', copy_options=self.copy_options) + msg_id = mail_template.send_mail(self.id, force_send=False) + mail = self.env['mail.mail'].browse(msg_id) attach_vals = { 'name': now_time + ' - ' + self.name, 'datas_fname': now_time + ' - ' + self.name + '.csv', 'datas': binary, + 'res_model': 'mail.mail', + 'res_id': mail.id, } attachment = attach_obj.create(attach_vals) - msg_id = mail_template.send_mail(self.id, force_send=False) - mail = self.env['mail.mail'].browse(msg_id) mail.write({'attachment_ids': [(4, attachment.id)]}) @api.model diff --git a/sql_export_mail/readme/CONFIGURE.rst b/sql_export_mail/readme/CONFIGURE.rst new file mode 100644 index 000000000..17ed7c873 --- /dev/null +++ b/sql_export_mail/readme/CONFIGURE.rst @@ -0,0 +1,7 @@ +To configure this module, you need to: + +#. Go to the sql query for which you want users to be notified by e-mail. +#. Add users to be notified in the field Users Notified by e-mail. +#. Click on the button create a cron and then configure the cron to run when + you want to. If you already have created a cron for another query, you can + use it again for other queries diff --git a/sql_export_mail/readme/CONTRIBUTORS.rst b/sql_export_mail/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..0bddb053a --- /dev/null +++ b/sql_export_mail/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Florian da Costa diff --git a/sql_export_mail/readme/DESCRIPTION.rst b/sql_export_mail/readme/DESCRIPTION.rst new file mode 100644 index 000000000..21dae9d88 --- /dev/null +++ b/sql_export_mail/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Allow to send the result of a query (made with the module sql_export) by mail. diff --git a/sql_export_mail/tests/test_sql_query_mail.py b/sql_export_mail/tests/test_sql_query_mail.py index 45bc2d2d3..0a021e2d6 100644 --- a/sql_export_mail/tests/test_sql_query_mail.py +++ b/sql_export_mail/tests/test_sql_query_mail.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2017 Akretion () +# Copyright (C) 2019 Akretion () # @author: Florian da Costa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). From e7fde1a9bbf963663954ac26b01812ceb88f19d3 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Wed, 12 Jun 2019 19:54:44 +0200 Subject: [PATCH 05/18] Migrate to v12 [UPD] Update sql_export_mail.pot [UPD] README.rst Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: server-tools-12.0/server-tools-12.0-sql_export_mail Translate-URL: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-sql_export_mail/ [ADD] icon.png --- sql_export_mail/README.rst | 84 ++++ .../{__openerp__.py => __manifest__.py} | 16 +- sql_export_mail/i18n/fr.po | 80 ++-- sql_export_mail/i18n/sql_export_mail.pot | 35 +- sql_export_mail/mail_template.xml | 26 +- sql_export_mail/models/sql_export.py | 30 +- sql_export_mail/static/description/icon.png | Bin 0 -> 9455 bytes sql_export_mail/static/description/index.html | 431 ++++++++++++++++++ sql_export_mail/tests/__init__.py | 1 - sql_export_mail/tests/test_sql_query_mail.py | 16 +- sql_export_mail/views/sql_export_view.xml | 6 +- 11 files changed, 622 insertions(+), 103 deletions(-) create mode 100644 sql_export_mail/README.rst rename sql_export_mail/{__openerp__.py => __manifest__.py} (60%) create mode 100644 sql_export_mail/static/description/icon.png create mode 100644 sql_export_mail/static/description/index.html diff --git a/sql_export_mail/README.rst b/sql_export_mail/README.rst new file mode 100644 index 000000000..d00fbc453 --- /dev/null +++ b/sql_export_mail/README.rst @@ -0,0 +1,84 @@ +=============== +SQL Export Mail +=============== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fserver--tools-lightgray.png?logo=github + :target: https://github.com/OCA/server-tools/tree/12.0/sql_export_mail + :alt: OCA/server-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-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/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Allow to send the result of a query (made with the module sql_export) by mail. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module, you need to: + +#. Go to the sql query for which you want users to be notified by e-mail. +#. Add users to be notified in the field Users Notified by e-mail. +#. Click on the button create a cron and then configure the cron to run when + you want to. If you already have created a cron for another query, you can + use it again for other queries + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Akretion + +Contributors +~~~~~~~~~~~~ + +* Florian da Costa + +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/server-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sql_export_mail/__openerp__.py b/sql_export_mail/__manifest__.py similarity index 60% rename from sql_export_mail/__openerp__.py rename to sql_export_mail/__manifest__.py index d2b84f565..323a031dd 100644 --- a/sql_export_mail/__openerp__.py +++ b/sql_export_mail/__manifest__.py @@ -1,22 +1,20 @@ -# -*- coding: utf-8 -*- -# Copyright 2019 Akretion # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - { 'name': 'SQL Export Mail', - 'version': '9.0.1.0.0', - 'author': 'Akretion,Odoo Community Association (OCA)', - 'website': 'http://github/oca/server-tools', - 'license': 'AGPL-3', - 'category': 'Generic Modules/Others', + 'version': '12.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', ], + 'license': 'AGPL-3', 'data': [ 'views/sql_export_view.xml', 'mail_template.xml', ], 'installable': True, - } +} diff --git a/sql_export_mail/i18n/fr.po b/sql_export_mail/i18n/fr.po index 483f13599..b308c401e 100644 --- a/sql_export_mail/i18n/fr.po +++ b/sql_export_mail/i18n/fr.po @@ -1,6 +1,6 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * sql_export_mail +# * sql_export_mail # msgid "" msgstr "" @@ -10,47 +10,69 @@ msgstr "" "PO-Revision-Date: 2017-07-18 13:15+0000\n" "Last-Translator: <>\n" "Language-Team: \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" #. module: sql_export_mail -#: model:email.template,body_html:sql_export_mail.sql_export_mailer -msgid "\n" -"
\n" +#: model:mail.template,body_html:sql_export_mail.sql_export_mailer +#, fuzzy +#| msgid "" +#| "\n" +#| "
\n" +#| "\n" +#| "

You will find the report ${object.name or ''} as an attachment of the " +#| "mail.

\n" +#| "\n" +#| "
\n" +#| " " +msgid "" "\n" -"

You will find the report ${object.name or ''} as an attachment of the mail.

\n" +"
\n" +"\n" +"

You will find the report ${object.name or ''} as an attachment of the " +"mail.

\n" "\n" "
\n" -" " -msgstr "\n" -"
\n" +" " +msgstr "" "\n" -"

Vous trouverez le rapport ${object.name or ''} en pièce jointe de ce mail.

\n" +"
\n" +"\n" +"

Vous trouverez le rapport ${object.name or ''} en pièce jointe de ce mail." +"

\n" "\n" "
\n" " " #. module: sql_export_mail -#: model:email.template,subject:sql_export_mail.sql_export_mailer +#: model:mail.template,subject:sql_export_mail.sql_export_mailer msgid "${object.name or ''}" msgstr "${object.name or ''}" #. module: sql_export_mail -#: help:sql.export,mail_user_ids:0 -msgid "Add the users who want to receive the report by e-mail. You need to link the sql query with a cron to send mail automatically" -msgstr "Ajoutez les utilisateurs voulant recevoir le rapport par mail. Vous devez ensuite créer une tâche planifiée pour envoyer le mail automatiquement." +#: model:ir.model.fields,help:sql_export_mail.field_sql_export__mail_user_ids +msgid "" +"Add the users who want to receive the report by e-mail. You need to link the " +"sql query with a cron to send mail automatically" +msgstr "" +"Ajoutez les utilisateurs voulant recevoir le rapport par mail. Vous devez " +"ensuite créer une tâche planifiée pour envoyer le mail automatiquement." #. module: sql_export_mail -#: view:sql.export:sql_export_mail.sql_export_mail_view_form +#: model_terms:ir.ui.view,arch_db:sql_export_mail.sql_export_mail_view_form msgid "Create Cron" msgstr "Créer une tâche planfiée" #. module: sql_export_mail -#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export_cron_ids -#: view:sql.export:sql_export_mail.sql_export_mail_view_form -#: field:sql.export,cron_ids:0 +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__cron_ids +#: model_terms:ir.ui.view,arch_db:sql_export_mail.sql_export_mail_view_form msgid "Crons" msgstr "Tâches planifiées" @@ -60,15 +82,20 @@ msgid "File Not Empty" msgstr "Fichier non vide." #. module: sql_export_mail -#: code:addons/sql_export_mail/models/sql_export.py:126 +#: code:addons/sql_export_mail/models/sql_export.py:124 #, python-format -msgid "It is not possible to execute and send a query automatically by mail if there are parameters to fill" -msgstr "Il n'est pas possible d'exécuter en envoyer le résultat d'une requête par mail si celle-ci contient des paramètres." +msgid "" +"It is not possible to execute and send a query automatically by mail if " +"there are parameters to fill" +msgstr "" +"Il n'est pas possible d'exécuter en envoyer le résultat d'une requête par " +"mail si celle-ci contient des paramètres." #. module: sql_export_mail -#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export_mail_condition -#: field:sql.export,mail_condition:0 -msgid "Mail condition" +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__mail_condition +#, fuzzy +#| msgid "Mail condition" +msgid "Mail Condition" msgstr "Condition d'envoi par mail" #. module: sql_export_mail @@ -77,18 +104,17 @@ msgid "SQL export" msgstr "Export SQL" #. module: sql_export_mail -#: code:addons/sql_export_mail/models/sql_export.py:135 +#: code:addons/sql_export_mail/models/sql_export.py:134 #, python-format msgid "The user does not have any e-mail address." msgstr "L'utilisateur selectionné n'a pas d'addresse mail." #. module: sql_export_mail -#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export_mail_user_ids -#: field:sql.export,mail_user_ids:0 +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__mail_user_ids msgid "User to notify" msgstr "Utilisateurs à notifier par mail" #. module: sql_export_mail -#: view:sql.export:sql_export_mail.sql_export_mail_view_form +#: model_terms:ir.ui.view,arch_db:sql_export_mail.sql_export_mail_view_form msgid "Users Notified by e-mail" msgstr "Utilisateurs notifiés par mail" diff --git a/sql_export_mail/i18n/sql_export_mail.pot b/sql_export_mail/i18n/sql_export_mail.pot index a27de68f6..4ec87e101 100644 --- a/sql_export_mail/i18n/sql_export_mail.pot +++ b/sql_export_mail/i18n/sql_export_mail.pot @@ -4,10 +4,8 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-07-18 13:24+0000\n" -"PO-Revision-Date: 2017-07-18 13:24+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,35 +14,34 @@ msgstr "" "Plural-Forms: \n" #. module: sql_export_mail -#: model:email.template,body_html:sql_export_mail.sql_export_mailer +#: model:mail.template,body_html:sql_export_mail.sql_export_mailer msgid "\n" "
\n" "\n" "

You will find the report ${object.name or ''} as an attachment of the mail.

\n" "\n" "
\n" -" " +" " msgstr "" #. module: sql_export_mail -#: model:email.template,subject:sql_export_mail.sql_export_mailer +#: model:mail.template,subject:sql_export_mail.sql_export_mailer msgid "${object.name or ''}" msgstr "" #. module: sql_export_mail -#: help:sql.export,mail_user_ids:0 +#: model:ir.model.fields,help:sql_export_mail.field_sql_export__mail_user_ids msgid "Add the users who want to receive the report by e-mail. You need to link the sql query with a cron to send mail automatically" msgstr "" #. module: sql_export_mail -#: view:sql.export:sql_export_mail.sql_export_mail_view_form +#: model_terms:ir.ui.view,arch_db:sql_export_mail.sql_export_mail_view_form msgid "Create Cron" msgstr "" #. module: sql_export_mail -#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export_cron_ids -#: view:sql.export:sql_export_mail.sql_export_mail_view_form -#: field:sql.export,cron_ids:0 +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__cron_ids +#: model_terms:ir.ui.view,arch_db:sql_export_mail.sql_export_mail_view_form msgid "Crons" msgstr "" @@ -54,15 +51,14 @@ msgid "File Not Empty" msgstr "" #. module: sql_export_mail -#: code:addons/sql_export_mail/models/sql_export.py:126 +#: code:addons/sql_export_mail/models/sql_export.py:124 #, python-format -msgid "It is not possible to execute and send a query automatically by e-mail if there are parameters to fill" +msgid "It is not possible to execute and send a query automatically by mail if there are parameters to fill" msgstr "" #. module: sql_export_mail -#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export_mail_condition -#: field:sql.export,mail_condition:0 -msgid "Mail condition" +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__mail_condition +msgid "Mail Condition" msgstr "" #. module: sql_export_mail @@ -71,19 +67,18 @@ msgid "SQL export" msgstr "" #. module: sql_export_mail -#: code:addons/sql_export_mail/models/sql_export.py:135 +#: code:addons/sql_export_mail/models/sql_export.py:134 #, 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_mail_user_ids -#: field:sql.export,mail_user_ids:0 +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__mail_user_ids msgid "User to notify" msgstr "" #. module: sql_export_mail -#: view:sql.export:sql_export_mail.sql_export_mail_view_form +#: model_terms:ir.ui.view,arch_db:sql_export_mail.sql_export_mail_view_form msgid "Users Notified by e-mail" msgstr "" diff --git a/sql_export_mail/mail_template.xml b/sql_export_mail/mail_template.xml index 0bb497d32..d163fc664 100644 --- a/sql_export_mail/mail_template.xml +++ b/sql_export_mail/mail_template.xml @@ -1,24 +1,22 @@ - - + - - - SQL Export - admin@example.com - ${object.get_email_address_for_template()} - ${object.name or ''} - - - + + SQL Export + admin@example.com + ${object.get_email_address_for_template()} + ${object.name or ''} + + +

You will find the report ${object.name or ''} as an attachment of the mail.

- ]]> - + ]]> + - diff --git a/sql_export_mail/models/sql_export.py b/sql_export_mail/models/sql_export.py index 6b0b5a74c..a4478c695 100644 --- a/sql_export_mail/models/sql_export.py +++ b/sql_export_mail/models/sql_export.py @@ -1,12 +1,11 @@ -# -*- coding: utf-8 -*- # Copyright 2019 Akretion # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from openerp import models, fields, api, _ -from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT -from openerp.exceptions import Warning as UserError +from odoo import models, fields, api, _ +from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT +from odoo.exceptions import UserError from datetime import datetime, timedelta -from openerp import SUPERUSER_ID +from odoo import SUPERUSER_ID class SqlExport(models.Model): @@ -34,14 +33,13 @@ class SqlExport(models.Model): def create_cron(self): self.ensure_one() nextcall = datetime.now() + timedelta(hours=2) - nextcall_fmt = datetime.strftime(nextcall, - DEFAULT_SERVER_DATETIME_FORMAT) cron_vals = { 'active': True, - 'model': 'sql.export', - 'function': '_run_all_sql_export_for_cron', + '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_fmt, + 'nextcall': nextcall, 'doall': False, 'numbercall': -1, 'user_id': SUPERUSER_ID, @@ -50,7 +48,9 @@ class SqlExport(models.Model): # 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 - write_vals = {'args': '[[%s]]' % cron.id} + write_vals = { + 'code': 'model._run_all_sql_export_for_cron([%s])' % cron.id + } cron.write(write_vals) self.write({'cron_ids': [(4, cron.id)]}) @@ -135,10 +135,4 @@ class SqlExport(models.Model): self.env.context.get('mail_to')) else: mail_users = self.mail_user_ids - emails = '' - for user in mail_users: - if emails and user.email: - emails += ',' + user.email - elif user.email: - emails += user.email - return emails + return ','.join([x.email for x in mail_users if x.email]) diff --git a/sql_export_mail/static/description/icon.png b/sql_export_mail/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 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 z 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 Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/sql_export_mail/static/description/index.html b/sql_export_mail/static/description/index.html new file mode 100644 index 000000000..b88d51d8e --- /dev/null +++ b/sql_export_mail/static/description/index.html @@ -0,0 +1,431 @@ + + + + + + +SQL Export Mail + + + +
+

SQL Export Mail

+ + +

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runbot

+

Allow to send the result of a query (made with the module sql_export) by mail.

+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  1. Go to the sql query for which you want users to be notified by e-mail.
  2. +
  3. Add users to be notified in the field Users Notified by e-mail.
  4. +
  5. Click on the button create a cron and then configure the cron to run when +you want to. If you already have created a cron for another query, you can +use it again for other queries
  6. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/sql_export_mail/tests/__init__.py b/sql_export_mail/tests/__init__.py index 1d119c788..8d5f08c3f 100644 --- a/sql_export_mail/tests/__init__.py +++ b/sql_export_mail/tests/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- from . import test_sql_query_mail diff --git a/sql_export_mail/tests/test_sql_query_mail.py b/sql_export_mail/tests/test_sql_query_mail.py index 0a021e2d6..e028b4960 100644 --- a/sql_export_mail/tests/test_sql_query_mail.py +++ b/sql_export_mail/tests/test_sql_query_mail.py @@ -1,10 +1,9 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2019 Akretion () # @author: Florian da Costa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp.tests.common import TransactionCase -from openerp import SUPERUSER_ID +from odoo.tests.common import TransactionCase +from odoo import SUPERUSER_ID class TestExportSqlQueryMail(TransactionCase): @@ -14,20 +13,17 @@ class TestExportSqlQueryMail(TransactionCase): self.sql_report_demo = self.env.ref('sql_export.sql_export_partner') self.sql_report_demo.write({'mail_user_ids': [(4, SUPERUSER_ID)]}) - def test_sql_query_create_cron(self): - self.sql_report_demo.create_cron() - self.assertTrue(self.sql_report_demo.cron_ids) - cron = self.sql_report_demo.cron_ids - self.assertEqual(cron.function, '_run_all_sql_export_for_cron') - def test_sql_query_mail(self): mail_obj = self.env['mail.mail'] mails = mail_obj.search( [('model', '=', 'sql.export'), ('res_id', '=', self.sql_report_demo.id)]) self.assertFalse(mails) - self.sql_report_demo.send_mail() + 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( [('model', '=', 'sql.export'), ('res_id', '=', self.sql_report_demo.id)]) self.assertTrue(mails) + self.assertTrue(mails.attachment_ids) diff --git a/sql_export_mail/views/sql_export_view.xml b/sql_export_mail/views/sql_export_view.xml index a2f0fe781..93a94c5b9 100644 --- a/sql_export_mail/views/sql_export_view.xml +++ b/sql_export_mail/views/sql_export_view.xml @@ -1,6 +1,5 @@ - - + @@ -27,5 +26,4 @@ - - + From 8073d9a60140b0a396b6dc4c3474c13496c124bf Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Tue, 2 Jul 2019 15:58:03 +0200 Subject: [PATCH 06/18] Add group on cron field to avoid access error when user does not have the right to read crons. --- sql_export_mail/views/sql_export_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql_export_mail/views/sql_export_view.xml b/sql_export_mail/views/sql_export_view.xml index 93a94c5b9..b34ede623 100644 --- a/sql_export_mail/views/sql_export_view.xml +++ b/sql_export_mail/views/sql_export_view.xml @@ -19,7 +19,7 @@ - + From 0b14ce9b778ed6b0044a4b283d4631937cedf0c7 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Wed, 21 Aug 2019 13:57:13 +0200 Subject: [PATCH 07/18] Adapt module sql_export_mail to be compatible with multiple file format --- sql_export_mail/models/sql_export.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sql_export_mail/models/sql_export.py b/sql_export_mail/models/sql_export.py index a4478c695..760b271cb 100644 --- a/sql_export_mail/models/sql_export.py +++ b/sql_export_mail/models/sql_export.py @@ -66,13 +66,23 @@ class SqlExport(models.Model): params=params, mode='fetchone') if not res: return - binary = self._execute_sql_request( - params=params, mode='stdout', copy_options=self.copy_options) + 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() + binary = wizard.binary_file + filename = wizard.file_name msg_id = mail_template.send_mail(self.id, force_send=False) mail = self.env['mail.mail'].browse(msg_id) attach_vals = { 'name': now_time + ' - ' + self.name, - 'datas_fname': now_time + ' - ' + self.name + '.csv', + 'datas_fname': filename, 'datas': binary, 'res_model': 'mail.mail', 'res_id': mail.id, From b04c585d7e0790bc5fa9e1d0402d75197884be2c Mon Sep 17 00:00:00 2001 From: hkapatel-initos Date: Mon, 14 Jun 2021 16:57:16 +0530 Subject: [PATCH 08/18] [IMP] sql_export_mail: black, isort, prettier --- sql_export_mail/__manifest__.py | 29 ++-- sql_export_mail/mail_template.xml | 11 +- sql_export_mail/models/sql_export.py | 150 +++++++++---------- sql_export_mail/tests/test_sql_query_mail.py | 17 +-- sql_export_mail/views/sql_export_view.xml | 25 +++- 5 files changed, 122 insertions(+), 110 deletions(-) diff --git a/sql_export_mail/__manifest__.py b/sql_export_mail/__manifest__.py index 323a031dd..3edc802aa 100644 --- a/sql_export_mail/__manifest__.py +++ b/sql_export_mail/__manifest__.py @@ -1,20 +1,19 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { - 'name': 'SQL Export Mail', - 'version': '12.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', + "name": "SQL Export Mail", + "version": "12.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", ], - 'license': 'AGPL-3', - 'data': [ - 'views/sql_export_view.xml', - 'mail_template.xml', + "license": "AGPL-3", + "data": [ + "views/sql_export_view.xml", + "mail_template.xml", ], - 'installable': True, + "installable": True, } diff --git a/sql_export_mail/mail_template.xml b/sql_export_mail/mail_template.xml index d163fc664..d5d40a75a 100644 --- a/sql_export_mail/mail_template.xml +++ b/sql_export_mail/mail_template.xml @@ -1,5 +1,4 @@ - - + @@ -8,9 +7,11 @@ admin@example.com ${object.get_email_address_for_template()} ${object.name or ''} - - - + +

You will find the report ${object.name or ''} as an attachment of the mail.

diff --git a/sql_export_mail/models/sql_export.py b/sql_export_mail/models/sql_export.py index 760b271cb..f2a4aae9a 100644 --- a/sql_export_mail/models/sql_export.py +++ b/sql_export_mail/models/sql_export.py @@ -1,148 +1,148 @@ # Copyright 2019 Akretion # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import models, fields, api, _ -from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT -from odoo.exceptions import UserError from datetime import datetime, timedelta -from odoo import SUPERUSER_ID + +from odoo import SUPERUSER_ID, _, api, fields, models +from odoo.exceptions import UserError +from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT class SqlExport(models.Model): - _inherit = 'sql.export' + _inherit = "sql.export" mail_user_ids = fields.Many2many( - 'res.users', - 'mail_user_sqlquery_rel', - 'sql_id', - 'user_id', - 'User to notify', - help='Add the users who want to receive the report by e-mail. You ' - 'need to link the sql query with a cron to send mail automatically') + "res.users", + "mail_user_sqlquery_rel", + "sql_id", + "user_id", + "User to notify", + help="Add the users who want to receive the report by e-mail. You " + "need to link the sql query with a cron to send mail automatically", + ) cron_ids = fields.Many2many( - 'ir.cron', - 'cron_sqlquery_rel', - 'sql_id', - 'cron_id', - 'Crons') + "ir.cron", "cron_sqlquery_rel", "sql_id", "cron_id", "Crons" + ) # We could implement other conditions, that is why it is a selection field mail_condition = fields.Selection( - [('not_empty', 'File Not Empty')], default='not_empty') + [("not_empty", "File Not Empty")], default="not_empty" + ) @api.multi def create_cron(self): self.ensure_one() nextcall = datetime.now() + timedelta(hours=2) cron_vals = { - '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, - 'doall': False, - 'numbercall': -1, - 'user_id': SUPERUSER_ID, + "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, + "doall": False, + "numbercall": -1, + "user_id": SUPERUSER_ID, } - cron = self.env['ir.cron'].create(cron_vals) + cron = self.env["ir.cron"].create(cron_vals) # 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 - write_vals = { - 'code': 'model._run_all_sql_export_for_cron([%s])' % cron.id - } + write_vals = {"code": "model._run_all_sql_export_for_cron([%s])" % cron.id} cron.write(write_vals) - self.write({'cron_ids': [(4, cron.id)]}) + self.write({"cron_ids": [(4, cron.id)]}) @api.multi def send_mail(self, params=None): self.ensure_one() - mail_template = self.env.ref('sql_export_mail.sql_export_mailer') - now_time = datetime.strftime(datetime.now(), - DEFAULT_SERVER_DATETIME_FORMAT) - attach_obj = self.env['ir.attachment'] - if self.mail_condition == 'not_empty': - res = self._execute_sql_request( - params=params, mode='fetchone') + mail_template = self.env.ref("sql_export_mail.sql_export_mailer") + now_time = datetime.strftime(datetime.now(), DEFAULT_SERVER_DATETIME_FORMAT) + 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, - }) + 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() binary = wizard.binary_file filename = wizard.file_name msg_id = mail_template.send_mail(self.id, force_send=False) - mail = self.env['mail.mail'].browse(msg_id) + mail = self.env["mail.mail"].browse(msg_id) attach_vals = { - 'name': now_time + ' - ' + self.name, - 'datas_fname': filename, - 'datas': binary, - 'res_model': 'mail.mail', - 'res_id': mail.id, + "name": now_time + " - " + self.name, + "datas_fname": filename, + "datas": binary, + "res_model": "mail.mail", + "res_id": mail.id, } attachment = attach_obj.create(attach_vals) - mail.write({'attachment_ids': [(4, attachment.id)]}) + mail.write({"attachment_ids": [(4, attachment.id)]}) @api.model def _run_all_sql_export_for_cron(self, cron_ids): - exports = self.search([('cron_ids', 'in', cron_ids)]) + exports = self.search([("cron_ids", "in", cron_ids)]) for export in exports: - if "%(company_id)s" in export.query and \ - "%(user_id)s" not in export.query: + if "%(company_id)s" in export.query and "%(user_id)s" not in export.query: variable_dict = {} - companies = self.env['res.company'].search([]) + companies = self.env["res.company"].search([]) for company in companies: users = export.mail_user_ids.filtered( - lambda u: u.company_id == company) + lambda u: u.company_id == company + ) if users: - variable_dict['company_id'] = users[0].company_id.id + variable_dict["company_id"] = users[0].company_id.id export.with_context(mail_to=users.ids).send_mail( - params=variable_dict) + params=variable_dict + ) elif "%(user_id)s" in export.query: variable_dict = {} for user in export.mail_user_ids: - variable_dict['user_id'] = user.id + variable_dict["user_id"] = user.id if "%(company_id)s" in export.query: - variable_dict['company_id'] = user.company_id.id + variable_dict["company_id"] = user.company_id.id export.with_context(mail_to=[user.id]).send_mail( - params=variable_dict) + params=variable_dict + ) else: export.send_mail() @api.multi - @api.constrains('field_ids', 'mail_user_ids') + @api.constrains("field_ids", "mail_user_ids") def check_no_parameter_if_sent_by_mail(self): for export in self: if export.field_ids and export.mail_user_ids: - raise UserError(_( - "It is not possible to execute and send a query " - "automatically by mail if there are parameters to fill")) + raise UserError( + _( + "It is not possible to execute and send a query " + "automatically by mail if there are parameters to fill" + ) + ) @api.multi - @api.constrains('mail_user_ids') + @api.constrains("mail_user_ids") def check_mail_user(self): for export in self: for user in export.mail_user_ids: if not user.email: - raise UserError(_( - "The user does not have any e-mail address.")) + raise UserError(_("The user does not have any e-mail address.")) @api.multi def get_email_address_for_template(self): """ - Called from mail template + Called from mail template """ self.ensure_one() - if self.env.context.get('mail_to'): - mail_users = self.env['res.users'].browse( - self.env.context.get('mail_to')) + if self.env.context.get("mail_to"): + mail_users = self.env["res.users"].browse(self.env.context.get("mail_to")) else: mail_users = self.mail_user_ids - return ','.join([x.email for x in mail_users if x.email]) + return ",".join([x.email for x in mail_users if x.email]) diff --git a/sql_export_mail/tests/test_sql_query_mail.py b/sql_export_mail/tests/test_sql_query_mail.py index e028b4960..8de0ce9d0 100644 --- a/sql_export_mail/tests/test_sql_query_mail.py +++ b/sql_export_mail/tests/test_sql_query_mail.py @@ -2,28 +2,27 @@ # @author: Florian da Costa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo.tests.common import TransactionCase from odoo import SUPERUSER_ID +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)]}) + self.sql_report_demo = self.env.ref("sql_export.sql_export_partner") + self.sql_report_demo.write({"mail_user_ids": [(4, SUPERUSER_ID)]}) def test_sql_query_mail(self): - mail_obj = self.env['mail.mail'] + mail_obj = self.env["mail.mail"] mails = mail_obj.search( - [('model', '=', 'sql.export'), - ('res_id', '=', self.sql_report_demo.id)]) + [("model", "=", "sql.export"), ("res_id", "=", self.sql_report_demo.id)] + ) self.assertFalse(mails) 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( - [('model', '=', 'sql.export'), - ('res_id', '=', self.sql_report_demo.id)]) + [("model", "=", "sql.export"), ("res_id", "=", self.sql_report_demo.id)] + ) self.assertTrue(mails) self.assertTrue(mails.attachment_ids) diff --git a/sql_export_mail/views/sql_export_view.xml b/sql_export_mail/views/sql_export_view.xml index b34ede623..19b5402cf 100644 --- a/sql_export_mail/views/sql_export_view.xml +++ b/sql_export_mail/views/sql_export_view.xml @@ -1,4 +1,4 @@ - + @@ -7,19 +7,32 @@ - + - + - + From d25dfc2aff55675abe8ee422a46b476ce5ac3d49 Mon Sep 17 00:00:00 2001 From: hkapatel Date: Tue, 15 Jun 2021 17:07:19 +0530 Subject: [PATCH 09/18] [MIG] sql_export_mail: Migration to 14.0 [UPD] Update sql_export_mail.pot [UPD] README.rst Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: server-tools-14.0/server-tools-14.0-sql_export_mail Translate-URL: https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-sql_export_mail/ [UPD] Update sql_export_mail.pot Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: server-tools-14.0/server-tools-14.0-sql_export_mail Translate-URL: https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-sql_export_mail/ [UPD] Update sql_export_mail.pot Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: server-tools-14.0/server-tools-14.0-sql_export_mail Translate-URL: https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-sql_export_mail/ --- sql_export_mail/README.rst | 11 +-- sql_export_mail/__manifest__.py | 7 +- sql_export_mail/i18n/fr.po | 68 +++++++++++++---- sql_export_mail/i18n/sql_export_mail.pot | 74 ++++++++++++++++--- sql_export_mail/models/sql_export.py | 10 +-- sql_export_mail/readme/CONTRIBUTORS.rst | 1 + sql_export_mail/static/description/index.html | 7 +- sql_export_mail/views/sql_export_view.xml | 2 +- 8 files changed, 132 insertions(+), 48 deletions(-) diff --git a/sql_export_mail/README.rst b/sql_export_mail/README.rst index d00fbc453..89058c698 100644 --- a/sql_export_mail/README.rst +++ b/sql_export_mail/README.rst @@ -14,13 +14,13 @@ SQL Export Mail :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/12.0/sql_export_mail + :target: https://github.com/OCA/server-tools/tree/14.0/sql_export_mail :alt: OCA/server-tools .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-sql_export_mail + :target: https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-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/12.0 + :target: https://runbot.odoo-community.org/runbot/149/14.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -49,7 +49,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -65,6 +65,7 @@ Contributors ~~~~~~~~~~~~ * Florian da Costa +* Helly kapatel Maintainers ~~~~~~~~~~~ @@ -79,6 +80,6 @@ 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 `_ project on GitHub. +This module is part of the `OCA/server-tools `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sql_export_mail/__manifest__.py b/sql_export_mail/__manifest__.py index 3edc802aa..278d42817 100644 --- a/sql_export_mail/__manifest__.py +++ b/sql_export_mail/__manifest__.py @@ -1,15 +1,12 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "SQL Export Mail", - "version": "12.0.1.0.0", + "version": "14.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", - ], + "depends": ["sql_export", "mail"], "license": "AGPL-3", "data": [ "views/sql_export_view.xml", diff --git a/sql_export_mail/i18n/fr.po b/sql_export_mail/i18n/fr.po index b308c401e..c616a5c03 100644 --- a/sql_export_mail/i18n/fr.po +++ b/sql_export_mail/i18n/fr.po @@ -19,17 +19,6 @@ msgstr "" #. module: sql_export_mail #: model:mail.template,body_html:sql_export_mail.sql_export_mailer #, fuzzy -#| msgid "" -#| "\n" -#| "
\n" -#| "\n" -#| "

You will find the report ${object.name or ''} as an attachment of the " -#| "mail.

\n" -#| "\n" -#| "
\n" -#| " " msgid "" "\n" "
\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -15,7 +15,8 @@ msgstr "" #. module: sql_export_mail #: model:mail.template,body_html:sql_export_mail.sql_export_mailer -msgid "\n" +msgid "" +"\n" "
\n" "\n" "

You will find the report ${object.name or ''} as an attachment of the mail.

\n" @@ -31,7 +32,34 @@ msgstr "" #. module: sql_export_mail #: model:ir.model.fields,help:sql_export_mail.field_sql_export__mail_user_ids -msgid "Add the users who want to receive the report by e-mail. You need to link the sql query with a cron to send mail automatically" +msgid "" +"Add the users who want to receive the report by e-mail. You need to link the" +" 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 @@ -46,14 +74,31 @@ msgid "Crons" msgstr "" #. module: sql_export_mail -#: selection:sql.export,mail_condition:0 +#: 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 -#: code:addons/sql_export_mail/models/sql_export.py:124 +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__id +msgid "ID" +msgstr "" + +#. module: sql_export_mail +#: code:addons/sql_export_mail/models/sql_export.py:0 #, python-format -msgid "It is not possible to execute and send a query automatically by mail if there are parameters to fill" +msgid "" +"It is not possible to execute and send a query automatically by mail if " +"there are parameters to fill" +msgstr "" + +#. module: sql_export_mail +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export____last_update +msgid "Last Modified on" msgstr "" #. module: sql_export_mail @@ -67,11 +112,21 @@ msgid "SQL export" msgstr "" #. module: sql_export_mail -#: code:addons/sql_export_mail/models/sql_export.py:134 +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__smart_search +msgid "Smart Search" +msgstr "" + +#. module: sql_export_mail +#: 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" @@ -81,4 +136,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:sql_export_mail.sql_export_mail_view_form msgid "Users Notified by e-mail" msgstr "" - diff --git a/sql_export_mail/models/sql_export.py b/sql_export_mail/models/sql_export.py index f2a4aae9a..d3529c638 100644 --- a/sql_export_mail/models/sql_export.py +++ b/sql_export_mail/models/sql_export.py @@ -5,7 +5,6 @@ from datetime import datetime, timedelta from odoo import SUPERUSER_ID, _, api, fields, models from odoo.exceptions import UserError -from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT class SqlExport(models.Model): @@ -28,7 +27,6 @@ class SqlExport(models.Model): [("not_empty", "File Not Empty")], default="not_empty" ) - @api.multi def create_cron(self): self.ensure_one() nextcall = datetime.now() + timedelta(hours=2) @@ -51,11 +49,9 @@ class SqlExport(models.Model): cron.write(write_vals) self.write({"cron_ids": [(4, cron.id)]}) - @api.multi def send_mail(self, params=None): self.ensure_one() mail_template = self.env.ref("sql_export_mail.sql_export_mailer") - now_time = datetime.strftime(datetime.now(), DEFAULT_SERVER_DATETIME_FORMAT) attach_obj = self.env["ir.attachment"] if self.mail_condition == "not_empty": res = self._execute_sql_request(params=params, mode="fetchone") @@ -78,8 +74,7 @@ class SqlExport(models.Model): msg_id = mail_template.send_mail(self.id, force_send=False) mail = self.env["mail.mail"].browse(msg_id) attach_vals = { - "name": now_time + " - " + self.name, - "datas_fname": filename, + "name": filename, "datas": binary, "res_model": "mail.mail", "res_id": mail.id, @@ -115,7 +110,6 @@ class SqlExport(models.Model): else: export.send_mail() - @api.multi @api.constrains("field_ids", "mail_user_ids") def check_no_parameter_if_sent_by_mail(self): for export in self: @@ -127,7 +121,6 @@ class SqlExport(models.Model): ) ) - @api.multi @api.constrains("mail_user_ids") def check_mail_user(self): for export in self: @@ -135,7 +128,6 @@ class SqlExport(models.Model): if not user.email: raise UserError(_("The user does not have any e-mail address.")) - @api.multi def get_email_address_for_template(self): """ Called from mail template diff --git a/sql_export_mail/readme/CONTRIBUTORS.rst b/sql_export_mail/readme/CONTRIBUTORS.rst index 0bddb053a..c2183a83d 100644 --- a/sql_export_mail/readme/CONTRIBUTORS.rst +++ b/sql_export_mail/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * Florian da Costa +* Helly kapatel diff --git a/sql_export_mail/static/description/index.html b/sql_export_mail/static/description/index.html index b88d51d8e..680790e0e 100644 --- a/sql_export_mail/static/description/index.html +++ b/sql_export_mail/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runbot

Allow to send the result of a query (made with the module sql_export) by mail.

Table of contents

@@ -398,7 +398,7 @@ use it again for other queries

Bugs are tracked on GitHub 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.

+feedback.

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

@@ -413,6 +413,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

Contributors

@@ -422,7 +423,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

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 project on GitHub.

+

This module is part of the OCA/server-tools project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/sql_export_mail/views/sql_export_view.xml b/sql_export_mail/views/sql_export_view.xml index 19b5402cf..7645c5c44 100644 --- a/sql_export_mail/views/sql_export_view.xml +++ b/sql_export_mail/views/sql_export_view.xml @@ -30,7 +30,7 @@ From d06052ca5c73cb92a78d84b7587a1f23869fe252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dept=2E=20T=C3=A9cnico?= Date: Mon, 14 Feb 2022 11:20:27 +0000 Subject: [PATCH 10/18] Added translation using Weblate (Catalan) --- sql_export_mail/i18n/ca.po | 139 +++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 sql_export_mail/i18n/ca.po diff --git a/sql_export_mail/i18n/ca.po b/sql_export_mail/i18n/ca.po new file mode 100644 index 000000000..df754f2ca --- /dev/null +++ b/sql_export_mail/i18n/ca.po @@ -0,0 +1,139 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sql_export_mail +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: ca\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" + +#. module: sql_export_mail +#: model:mail.template,body_html:sql_export_mail.sql_export_mailer +msgid "" +"\n" +"
\n" +"\n" +"

You will find the report ${object.name or ''} as an attachment of the mail.

\n" +"\n" +"
\n" +" " +msgstr "" + +#. module: sql_export_mail +#: model:mail.template,subject:sql_export_mail.sql_export_mailer +msgid "${object.name or ''}" +msgstr "" + +#. module: sql_export_mail +#: model:ir.model.fields,help:sql_export_mail.field_sql_export__mail_user_ids +msgid "" +"Add the users who want to receive the report by e-mail. You need to link the" +" 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" +msgstr "" + +#. module: sql_export_mail +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__cron_ids +#: model_terms:ir.ui.view,arch_db:sql_export_mail.sql_export_mail_view_form +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 +#: code:addons/sql_export_mail/models/sql_export.py:0 +#, python-format +msgid "" +"It is not possible to execute and send a query automatically by mail if " +"there are parameters to fill" +msgstr "" + +#. module: sql_export_mail +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export____last_update +msgid "Last Modified on" +msgstr "" + +#. module: sql_export_mail +#: model:ir.model.fields,field_description:sql_export_mail.field_sql_export__mail_condition +msgid "Mail Condition" +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 +#: 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" +msgstr "" + +#. module: sql_export_mail +#: model_terms:ir.ui.view,arch_db:sql_export_mail.sql_export_mail_view_form +msgid "Users Notified by e-mail" +msgstr "" From 5d3e9ed19e1b6b6251286e035d94f81ccbc1258c Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Wed, 26 Oct 2022 16:24:25 +0200 Subject: [PATCH 11/18] [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 --- sql_export_mail/README.rst | 25 +++++--- sql_export_mail/__manifest__.py | 14 +++-- sql_export_mail/{ => data}/mail_template.xml | 0 sql_export_mail/i18n/sql_export_mail.pot | 58 ++++--------------- sql_export_mail/models/sql_export.py | 27 +++++---- sql_export_mail/static/description/index.html | 11 ++-- sql_export_mail/views/sql_export_view.xml | 29 ++++++---- 7 files changed, 75 insertions(+), 89 deletions(-) rename sql_export_mail/{ => data}/mail_template.xml (100%) diff --git a/sql_export_mail/README.rst b/sql_export_mail/README.rst index 89058c698..ba67e1e68 100644 --- a/sql_export_mail/README.rst +++ b/sql_export_mail/README.rst @@ -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 `_. +Bugs are tracked on `GitHub 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 `_. +`feedback `_. 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 `_ project on GitHub. +.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px + :target: https://github.com/legalsylvain + :alt: legalsylvain + +Current `maintainer `__: + +|maintainer-legalsylvain| + +This module is part of the `OCA/reporting-engine `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sql_export_mail/__manifest__.py b/sql_export_mail/__manifest__.py index 278d42817..e6768b832 100644 --- a/sql_export_mail/__manifest__.py +++ b/sql_export_mail/__manifest__.py @@ -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, } diff --git a/sql_export_mail/mail_template.xml b/sql_export_mail/data/mail_template.xml similarity index 100% rename from sql_export_mail/mail_template.xml rename to sql_export_mail/data/mail_template.xml diff --git a/sql_export_mail/i18n/sql_export_mail.pot b/sql_export_mail/i18n/sql_export_mail.pot index 68bf42e1e..35aba27fe 100644 --- a/sql_export_mail/i18n/sql_export_mail.pot +++ b/sql_export_mail/i18n/sql_export_mail.pot @@ -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" diff --git a/sql_export_mail/models/sql_export.py b/sql_export_mail/models/sql_export.py index d3529c638..c30d2d4d2 100644 --- a/sql_export_mail/models/sql_export.py +++ b/sql_export_mail/models/sql_export.py @@ -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) diff --git a/sql_export_mail/static/description/index.html b/sql_export_mail/static/description/index.html index 680790e0e..e6288135f 100644 --- a/sql_export_mail/static/description/index.html +++ b/sql_export_mail/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/reporting-engine Translate me on Weblate Try me on Runbot

Allow to send the result of a query (made with the module sql_export) by mail.

Table of contents

@@ -395,10 +395,10 @@ use it again for other queries

Bug Tracker

-

Bugs are tracked on GitHub Issues. +

Bugs are tracked on GitHub 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.

+feedback.

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

@@ -407,6 +407,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

Authors

  • Akretion
  • +
  • GRAP
@@ -423,7 +424,9 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

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 project on GitHub.

+

Current maintainer:

+

legalsylvain

+

This module is part of the OCA/reporting-engine project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/sql_export_mail/views/sql_export_view.xml b/sql_export_mail/views/sql_export_view.xml index 7645c5c44..487bad1d9 100644 --- a/sql_export_mail/views/sql_export_view.xml +++ b/sql_export_mail/views/sql_export_view.xml @@ -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, [])])]}" /> @@ -21,21 +20,27 @@ attrs="{'invisible': [('cron_ids', '=', [(6, False, [])])]}" />
- - - - - - - + + + + + + - - - + + + +
From ea9408114cd1664d4db34c7721910707a87af5d8 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Wed, 22 Feb 2023 12:45:30 +0100 Subject: [PATCH 12/18] [FIX] email template on sql_export_mail --- sql_export_mail/data/mail_template.xml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sql_export_mail/data/mail_template.xml b/sql_export_mail/data/mail_template.xml index d5d40a75a..ca64eb05b 100644 --- a/sql_export_mail/data/mail_template.xml +++ b/sql_export_mail/data/mail_template.xml @@ -5,19 +5,21 @@ SQL Export admin@example.com - ${object.get_email_address_for_template()} - ${object.name or ''} + {{object.get_email_address_for_template()}} + {{object.name or ''}} - + +
-

You will find the report ${object.name or ''} as an attachment of the mail.

+

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

- ]]>
+
From 0cd67c6b85a02acfd1f585cf6dae78f2d54a4491 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Fri, 3 Feb 2023 11:36:59 +0100 Subject: [PATCH 13/18] [IMP] Add back the variable feature in sql_export Refactore to use the new properties field --- sql_export_mail/models/sql_export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql_export_mail/models/sql_export.py b/sql_export_mail/models/sql_export.py index c30d2d4d2..be8d806d6 100644 --- a/sql_export_mail/models/sql_export.py +++ b/sql_export_mail/models/sql_export.py @@ -113,10 +113,10 @@ class SqlExport(models.Model): else: export.send_mail() - @api.constrains("field_ids", "mail_user_ids") + @api.constrains("query_properties_definition", "mail_user_ids") def check_no_parameter_if_sent_by_mail(self): for export in self: - if export.field_ids and export.mail_user_ids: + if export.query_properties_definition and export.mail_user_ids: raise UserError( _( "It is not possible to execute and send a query " From bc1df4612aeb9ec5a64bd097b4ee0d7cf6bc21dc Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Mon, 19 Jun 2023 10:32:30 +0200 Subject: [PATCH 14/18] [IMP] sql_export_mail : Add migration script to fix email template [UPD] Update sql_export_mail.pot sql_export_mail 16.0.1.0.1 Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: reporting-engine-16.0/reporting-engine-16.0-sql_export_mail Translate-URL: https://translation.odoo-community.org/projects/reporting-engine-16-0/reporting-engine-16-0-sql_export_mail/ --- sql_export_mail/__manifest__.py | 2 +- sql_export_mail/i18n/ca.po | 77 ++++--------- sql_export_mail/i18n/fr.po | 108 +++++++----------- sql_export_mail/i18n/sql_export_mail.pot | 13 +-- .../16.0.1.0.0/noupdate_changes.xml | 19 +++ .../migrations/16.0.1.0.0/post-migration.py | 8 ++ 6 files changed, 97 insertions(+), 130 deletions(-) create mode 100644 sql_export_mail/migrations/16.0.1.0.0/noupdate_changes.xml create mode 100644 sql_export_mail/migrations/16.0.1.0.0/post-migration.py diff --git a/sql_export_mail/__manifest__.py b/sql_export_mail/__manifest__.py index e6768b832..ac0bc5d82 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.1.0.0", + "version": "16.0.1.0.1", "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/i18n/ca.po b/sql_export_mail/i18n/ca.po index df754f2ca..164c0dc07 100644 --- a/sql_export_mail/i18n/ca.po +++ b/sql_export_mail/i18n/ca.po @@ -17,50 +17,21 @@ msgstr "" #. module: sql_export_mail #: model:mail.template,body_html:sql_export_mail.sql_export_mailer msgid "" +"
\n" "\n" -"
\n" -"\n" -"

You will find the report ${object.name or ''} as an attachment of the mail.

\n" +"

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

\n" "\n" "
\n" " " msgstr "" -#. module: sql_export_mail -#: model:mail.template,subject:sql_export_mail.sql_export_mailer -msgid "${object.name or ''}" -msgstr "" - #. module: sql_export_mail #: model:ir.model.fields,help:sql_export_mail.field_sql_export__mail_user_ids msgid "" -"Add the users who want to receive the report by e-mail. You need to link the" -" 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" +"Add the users who want to receive the report by e-mail. You need to link the " +"sql query with a cron to send mail automatically" msgstr "" #. module: sql_export_mail @@ -74,22 +45,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 "" @@ -98,8 +60,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 @@ -107,27 +69,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" @@ -137,3 +95,8 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:sql_export_mail.sql_export_mail_view_form msgid "Users Notified by e-mail" msgstr "" + +#. module: sql_export_mail +#: model:mail.template,subject:sql_export_mail.sql_export_mailer +msgid "{{object.name or ''}}" +msgstr "" diff --git a/sql_export_mail/i18n/fr.po b/sql_export_mail/i18n/fr.po index c616a5c03..74a4980d8 100644 --- a/sql_export_mail/i18n/fr.po +++ b/sql_export_mail/i18n/fr.po @@ -18,32 +18,16 @@ msgstr "" #. module: sql_export_mail #: model:mail.template,body_html:sql_export_mail.sql_export_mailer -#, fuzzy msgid "" -"\n" "
\n" "\n" -"

You will find the report ${object.name or ''} as an attachment of the " -"mail.

\n" +"

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

\n" "\n" "
\n" " " msgstr "" -"\n" -"
\n" -"\n" -"

Vous trouverez le rapport ${object.name or ''} en pièce jointe de ce mail." -"

\n" -"\n" -"
\n" -" " - -#. module: sql_export_mail -#: model:mail.template,subject:sql_export_mail.sql_export_mailer -msgid "${object.name or ''}" -msgstr "${object.name or ''}" #. module: sql_export_mail #: model:ir.model.fields,help:sql_export_mail.field_sql_export__mail_user_ids @@ -54,31 +38,6 @@ msgstr "" "Ajoutez les utilisateurs voulant recevoir le rapport par mail. Vous devez " "ensuite créer une tâche planifiée pour envoyer le mail automatiquement." -#. 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" @@ -90,22 +49,13 @@ msgstr "Créer une tâche planfiée" msgid "Crons" msgstr "Tâches planifiées" -#. 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 "Fichier non vide." #. 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 "" @@ -116,8 +66,8 @@ msgstr "" "mail si celle-ci contient des paramètres." #. 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 @@ -126,27 +76,23 @@ msgstr "" msgid "Mail Condition" msgstr "Condition d'envoi par mail" +#. 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 "Export SQL" #. 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 "L'utilisateur selectionné n'a pas d'addresse mail." -#. 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" @@ -156,3 +102,35 @@ msgstr "Utilisateurs à notifier par mail" #: model_terms:ir.ui.view,arch_db:sql_export_mail.sql_export_mail_view_form msgid "Users Notified by e-mail" msgstr "Utilisateurs notifiés par mail" + +#. module: sql_export_mail +#: model:mail.template,subject:sql_export_mail.sql_export_mailer +msgid "{{object.name or ''}}" +msgstr "" + +#, fuzzy +#~ msgid "" +#~ "\n" +#~ "
\n" +#~ "\n" +#~ "

You will find the report ${object.name or ''} as an attachment of the " +#~ "mail.

\n" +#~ "\n" +#~ "
\n" +#~ " " +#~ msgstr "" +#~ "\n" +#~ "
\n" +#~ "\n" +#~ "

Vous trouverez le rapport ${object.name or ''} en pièce jointe de ce " +#~ "mail.

\n" +#~ "\n" +#~ "
\n" +#~ " " + +#~ msgid "${object.name or ''}" +#~ msgstr "${object.name or ''}" diff --git a/sql_export_mail/i18n/sql_export_mail.pot b/sql_export_mail/i18n/sql_export_mail.pot index 35aba27fe..971cd1468 100644 --- a/sql_export_mail/i18n/sql_export_mail.pot +++ b/sql_export_mail/i18n/sql_export_mail.pot @@ -16,20 +16,14 @@ msgstr "" #. module: sql_export_mail #: model:mail.template,body_html:sql_export_mail.sql_export_mailer msgid "" -"\n" "
\n" "\n" -"

You will find the report ${object.name or ''} as an attachment of the mail.

\n" +"

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

\n" "\n" "
\n" " " msgstr "" -#. module: sql_export_mail -#: model:mail.template,subject:sql_export_mail.sql_export_mailer -msgid "${object.name or ''}" -msgstr "" - #. module: sql_export_mail #: model:ir.model.fields,help:sql_export_mail.field_sql_export__mail_user_ids msgid "" @@ -98,3 +92,8 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:sql_export_mail.sql_export_mail_view_form msgid "Users Notified by e-mail" msgstr "" + +#. module: sql_export_mail +#: model:mail.template,subject:sql_export_mail.sql_export_mailer +msgid "{{object.name or ''}}" +msgstr "" 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 new file mode 100644 index 000000000..fe76bd1f4 --- /dev/null +++ b/sql_export_mail/migrations/16.0.1.0.0/noupdate_changes.xml @@ -0,0 +1,19 @@ + + + + + {{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 new file mode 100644 index 000000000..bea37ae39 --- /dev/null +++ b/sql_export_mail/migrations/16.0.1.0.0/post-migration.py @@ -0,0 +1,8 @@ +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" + ) From 4898f36f8fdbafb46490bf58db12f38327c08864 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Tue, 20 Jun 2023 11:00:40 +0200 Subject: [PATCH 15/18] [FIX] sql_export_mail : do not raise an error if non admin user want to access to sql export [UPD] README.rst [BOT] post-merge updates [BOT] post-merge updates --- sql_export_mail/README.rst | 15 ++++--- sql_export_mail/__manifest__.py | 2 +- sql_export_mail/models/sql_export.py | 7 +++- sql_export_mail/static/description/index.html | 40 ++++++++++--------- sql_export_mail/views/sql_export_view.xml | 3 +- 5 files changed, 39 insertions(+), 28 deletions(-) diff --git a/sql_export_mail/README.rst b/sql_export_mail/README.rst index ba67e1e68..082cfcebc 100644 --- a/sql_export_mail/README.rst +++ b/sql_export_mail/README.rst @@ -2,10 +2,13 @@ SQL Export Mail =============== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:7545ca6358f23ee0f98d8fa0d2610030bdce7d1dc9a2b1e241be5443612fcf1e + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -19,11 +22,11 @@ SQL Export Mail .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png :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/143/16.0 - :alt: Try me on Runbot +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=16.0 + :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| Allow to send the result of a query (made with the module sql_export) by mail. @@ -48,7 +51,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 +If you spotted it first, help us to smash it by providing a detailed and welcomed `feedback `_. Do not contact contributors directly about support or help with technical issues. diff --git a/sql_export_mail/__manifest__.py b/sql_export_mail/__manifest__.py index ac0bc5d82..371758df0 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.1.0.1", + "version": "16.0.2.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/models/sql_export.py b/sql_export_mail/models/sql_export.py index be8d806d6..488b9381d 100644 --- a/sql_export_mail/models/sql_export.py +++ b/sql_export_mail/models/sql_export.py @@ -20,7 +20,12 @@ class SqlExport(models.Model): "need to link the sql query with a cron to send mail automatically", ) cron_ids = fields.Many2many( - "ir.cron", "cron_sqlquery_rel", "sql_id", "cron_id", "Crons" + "ir.cron", + "cron_sqlquery_rel", + "sql_id", + "cron_id", + "Crons", + groups="base.group_system", ) # We could implement other conditions, that is why it is a selection field mail_condition = fields.Selection( diff --git a/sql_export_mail/static/description/index.html b/sql_export_mail/static/description/index.html index e6288135f..3c50d3a35 100644 --- a/sql_export_mail/static/description/index.html +++ b/sql_export_mail/static/description/index.html @@ -1,20 +1,20 @@ - + - + SQL Export Mail