Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[15.0][MIG] sql_export_mail: Migration to 15.0 #860

Merged
merged 18 commits into from
Mar 13, 2024
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
styles and decorator fixes
  • Loading branch information
florian-dacosta authored and BT-ssteiner committed Mar 8, 2024

Verified

This commit was signed with the committer’s verified signature.
survived Denis Varlakov
commit 27dfa0b1e43214dce41213c642b266d9a0efbb6f
21 changes: 2 additions & 19 deletions sql_export_mail/__openerp__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2015 Akretion (<http://www.akretion.com>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# Copyright 2017 Akretion
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
'name': 'SQL Export Mail',
2 changes: 1 addition & 1 deletion sql_export_mail/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -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
46 changes: 16 additions & 30 deletions sql_export_mail/models/sql_export.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2017 Akretion (<http://www.akretion.com>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# 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 @@ def create_cron(self):

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 @@ def _run_all_sql_export_for_cron(self, cron_ids):
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):