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

[17.0][MIG] mail_template_attach_existing_attachment #1543

Open
wants to merge 3 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
115 changes: 115 additions & 0 deletions mail_template_attach_existing_attachment/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
========================================
Mail Template Attach Existing Attachment
========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:357b69bbbb54f796331009fc359e4aa8162a9efb1d806396d930e1ef3f23659e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Fsocial-lightgray.png?logo=github
:target: https://github.com/OCA/social/tree/17.0/mail_template_attach_existing_attachment
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-17-0/social-17-0-mail_template_attach_existing_attachment
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module, based on mail_attach_existing_attachment allow to define
`REGular EXpression <https://docs.python.org/3/library/re.html>`__ to
pre-select existing attachment that matched with file name to send in
compose mail.

This module is designed to work in mass mailing to select proper files
to attached from mail template configuration.

**Table of contents**

.. contents::
:local:

Configuration
=============

- Configure attachment name pattern (regex) on email template advanced
setting (menu: Settings > Technical > Emails > Templates)

|image1|

.. |image1| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_template_attach_existing_attachment/static/description/email-template.png

Usage
=====

To use this module, you need to:

- Adding some attachments on an object

|image1|

- Then, by sending the object via email, you can see existing attachment
matching the regex are selected by default from chosen configured
template

|image2|

--------------

Using in mass mailing existing attachements matching configured regex
will be part of the mail.

.. |image1| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_template_attach_existing_attachment/static/description/attachment.png
.. |image2| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_template_attach_existing_attachment/static/description/mail_compose_message.png

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_template_attach_existing_attachment%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* Pierre Verkest

Contributors
------------

- Pierre Verkest <[email protected]>

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/social <https://github.com/OCA/social/tree/17.0/mail_template_attach_existing_attachment>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions mail_template_attach_existing_attachment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizard
15 changes: 15 additions & 0 deletions mail_template_attach_existing_attachment/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2022 Foodles (http://www.foodles.co).
# @author Pierre Verkest <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Mail Template Attach Existing Attachment",
"summary": "Select default attachement to send with regex set on mail template",
"author": "Pierre Verkest, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social",
"category": "Social Network",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"depends": ["mail_attach_existing_attachment"],
"data": ["views/mail_template.xml"],
"installable": True,
}
66 changes: 66 additions & 0 deletions mail_template_attach_existing_attachment/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_template_attach_existing_attachment
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \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: mail_template_attach_existing_attachment
#: model:ir.model.fields,field_description:mail_template_attach_existing_attachment.field_mail_template__attach_exist_document_regex
msgid "Attachment name pattern (regex)"
msgstr "Regex: ajout docs existants"

#. module: mail_template_attach_existing_attachment
#: model:ir.model.fields,field_description:mail_template_attach_existing_attachment.field_mail_compose_message__display_name
#: model:ir.model.fields,field_description:mail_template_attach_existing_attachment.field_mail_template__display_name
msgid "Display Name"
msgstr "Nom affiché"

#. module: mail_template_attach_existing_attachment
#: model:ir.model,name:mail_template_attach_existing_attachment.model_mail_template
msgid "Email Templates"
msgstr "Modèles d'emails"

#. module: mail_template_attach_existing_attachment
#: model:ir.model,name:mail_template_attach_existing_attachment.model_mail_compose_message
msgid "Email composition wizard"
msgstr "Assistant de composition d'emails"

#. module: mail_template_attach_existing_attachment
#: model:ir.model.fields,field_description:mail_template_attach_existing_attachment.field_mail_compose_message__id
#: model:ir.model.fields,field_description:mail_template_attach_existing_attachment.field_mail_template__id
msgid "ID"
msgstr "ID"

#. module: mail_template_attach_existing_attachment
#: model:ir.model.fields,field_description:mail_template_attach_existing_attachment.field_mail_compose_message____last_update
#: model:ir.model.fields,field_description:mail_template_attach_existing_attachment.field_mail_template____last_update
msgid "Last Modified on"
msgstr "Dernière modification le"

#. module: mail_template_attach_existing_attachment
#: model:ir.model.fields,help:mail_template_attach_existing_attachment.field_mail_template__attach_exist_document_regex
msgid ""
"REGular EXpression to find existing document (base on file name) to attach "
"in mass mailing or by default in mail composer"
msgstr ""
"Expression régulière (regex) utilisé pour joindre les documents liés "
"existants a ajouter aux pièces jointes. L'expression est testé sur le nom de "
"fichier (name)."

#. module: mail_template_attach_existing_attachment
#: code:addons/.src/social/mail_template_attach_existing_attachment/models/mail_template.py:0
#: code:addons/mail_template_attach_existing_attachment/models/mail_template.py:0
#, python-format
msgid "The following regular expression is invalid to select attachment: %s"
msgstr ""
"L'expression régulière est invalide pour trouver les noms de fichiers: %s"
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_template_attach_existing_attachment
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \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: mail_template_attach_existing_attachment
#: model:ir.model.fields,field_description:mail_template_attach_existing_attachment.field_mail_template__attach_exist_document_regex
msgid "Attachment name pattern (regex)"
msgstr ""

#. module: mail_template_attach_existing_attachment
#: model:ir.model.fields,field_description:mail_template_attach_existing_attachment.field_mail_compose_message__display_name
#: model:ir.model.fields,field_description:mail_template_attach_existing_attachment.field_mail_template__display_name
msgid "Display Name"
msgstr ""

#. module: mail_template_attach_existing_attachment
#: model:ir.model,name:mail_template_attach_existing_attachment.model_mail_template
msgid "Email Templates"
msgstr ""

#. module: mail_template_attach_existing_attachment
#: model:ir.model,name:mail_template_attach_existing_attachment.model_mail_compose_message
msgid "Email composition wizard"
msgstr ""

#. module: mail_template_attach_existing_attachment
#: model:ir.model.fields,field_description:mail_template_attach_existing_attachment.field_mail_compose_message__id
#: model:ir.model.fields,field_description:mail_template_attach_existing_attachment.field_mail_template__id
msgid "ID"
msgstr ""

#. module: mail_template_attach_existing_attachment
#: model:ir.model.fields,field_description:mail_template_attach_existing_attachment.field_mail_compose_message____last_update
#: model:ir.model.fields,field_description:mail_template_attach_existing_attachment.field_mail_template____last_update
msgid "Last Modified on"
msgstr ""

#. module: mail_template_attach_existing_attachment
#: model:ir.model.fields,help:mail_template_attach_existing_attachment.field_mail_template__attach_exist_document_regex
msgid ""
"REGular EXpression to find existing document (base on file name) to attach "
"in mass mailing or by default in mail composer"
msgstr ""

#. module: mail_template_attach_existing_attachment
#: code:addons/.src/social/mail_template_attach_existing_attachment/models/mail_template.py:0
#: code:addons/mail_template_attach_existing_attachment/models/mail_template.py:0
#, python-format
msgid "The following regular expression is invalid to select attachment: %s"
msgstr ""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import mail_template
36 changes: 36 additions & 0 deletions mail_template_attach_existing_attachment/models/mail_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2022 Foodles (http://www.foodles.co).
# @author Pierre Verkest <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import re

from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


class MailTemplate(models.Model):
"Templates for sending email"

_inherit = "mail.template"

attach_exist_document_regex = fields.Char(
string="Attachment name pattern (regex)",
help=(
"REGular EXpression to find existing document (base on file name) "
"to attach in mass mailing or by default in mail composer"
),
)

@api.constrains("attach_exist_document_regex")
def validate_regex(self):
for record in self:
try:
if record.attach_exist_document_regex:
re.compile(record.attach_exist_document_regex)
except re.error as re_error:
raise ValidationError(
_(
"The following regular expression is invalid to "
"select attachment: %s"
)
% record.attach_exist_document_regex
) from re_error
3 changes: 3 additions & 0 deletions mail_template_attach_existing_attachment/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
4 changes: 4 additions & 0 deletions mail_template_attach_existing_attachment/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Configure attachment name pattern (regex) on email template advanced
setting (menu: Settings \> Technical \> Emails \> Templates)

![](../static/description/email-template.png)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Pierre Verkest \<[email protected]\>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This module, based on mail_attach_existing_attachment allow to define
[REGular EXpression](https://docs.python.org/3/library/re.html) to
pre-select existing attachment that matched with file name to send in
compose mail.

This module is designed to work in mass mailing to select proper files
to attached from mail template configuration.
16 changes: 16 additions & 0 deletions mail_template_attach_existing_attachment/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
To use this module, you need to:

- Adding some attachments on an object

![](../static/description/attachment.png)

- Then, by sending the object via email, you can see existing attachment
matching the regex are selected by default from chosen configured
template

![](../static/description/mail_compose_message.png)

---

Using in mass mailing existing attachements matching configured regex
will be part of the mail.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading