From 92d48790fe85a9219bc7800fce9af751a57a164d Mon Sep 17 00:00:00 2001 From: Bhavesh Heliconia Date: Thu, 30 Jan 2025 09:59:34 +0530 Subject: [PATCH] [MIG] mail_attach_existing_attachment: Migration to 18.0 --- mail_attach_existing_attachment/README.rst | 6 +- .../__manifest__.py | 2 +- mail_attach_existing_attachment/i18n/ca.po | 7 +- mail_attach_existing_attachment/i18n/de.po | 7 +- mail_attach_existing_attachment/i18n/es.po | 7 +- mail_attach_existing_attachment/i18n/es_CO.po | 7 +- mail_attach_existing_attachment/i18n/fr.po | 7 +- mail_attach_existing_attachment/i18n/he.po | 7 +- mail_attach_existing_attachment/i18n/hr.po | 11 ++- mail_attach_existing_attachment/i18n/it.po | 7 +- .../i18n/mail_attach_existing_attachment.pot | 9 +- mail_attach_existing_attachment/i18n/pt_BR.po | 7 +- mail_attach_existing_attachment/i18n/sl.po | 11 ++- mail_attach_existing_attachment/i18n/zh_CN.po | 7 +- .../readme/CONTRIBUTORS.md | 2 + .../static/description/index.html | 6 +- .../test_mail_attach_existing_attachment.py | 91 +++++++++++++++---- .../wizard/mail_compose_message.py | 28 +++++- .../wizard/mail_compose_message_view.xml | 10 +- 19 files changed, 178 insertions(+), 61 deletions(-) diff --git a/mail_attach_existing_attachment/README.rst b/mail_attach_existing_attachment/README.rst index 855984836cd..716cf911daa 100644 --- a/mail_attach_existing_attachment/README.rst +++ b/mail_attach_existing_attachment/README.rst @@ -7,7 +7,7 @@ Mail Attach Existing Attachment !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:ac2a9aa40b0d4a582c625061abbe71035a0b6c6421af29465d20d9e51dcfbda3 + !! source digest: sha256:06897e29cf4f22512f7b26e538e7883ef789bd3f99a6c2666c3f6fce2ac51427 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -89,6 +89,10 @@ Contributors - Sergio Teruel - Ernesto Tejeda +- `Heliconia Solutions Pvt. Ltd. `__ + + - Bhavesh Heliconia + Maintainers ----------- diff --git a/mail_attach_existing_attachment/__manifest__.py b/mail_attach_existing_attachment/__manifest__.py index 16446dd3f02..009e290aadf 100644 --- a/mail_attach_existing_attachment/__manifest__.py +++ b/mail_attach_existing_attachment/__manifest__.py @@ -7,7 +7,7 @@ "author": "ACSONE SA/NV, Tecnativa, Odoo Community Association (OCA)", "website": "https://github.com/OCA/social", "category": "Social Network", - "version": "16.0.1.1.0", + "version": "18.0.1.0.0", "license": "AGPL-3", "depends": ["mail"], "data": ["wizard/mail_compose_message_view.xml"], diff --git a/mail_attach_existing_attachment/i18n/ca.po b/mail_attach_existing_attachment/i18n/ca.po index 7f599ca09d7..129509786de 100644 --- a/mail_attach_existing_attachment/i18n/ca.po +++ b/mail_attach_existing_attachment/i18n/ca.po @@ -19,18 +19,21 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__can_attach_attachment #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__can_attach_attachment msgid "Can Attach Attachment" msgstr "" +#. module: mail_attach_existing_attachment +#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__display_object_attachment_ids +msgid "Display Object Attachment" +msgstr "" + #. module: mail_attach_existing_attachment #: model:ir.model,name:mail_attach_existing_attachment.model_mail_compose_message msgid "Email composition wizard" msgstr "Assistent per composició de correus electrònics" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__object_attachment_ids #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__object_attachment_ids msgid "Object Attachments" msgstr "" diff --git a/mail_attach_existing_attachment/i18n/de.po b/mail_attach_existing_attachment/i18n/de.po index 46ed67b42d8..62cd915bbde 100644 --- a/mail_attach_existing_attachment/i18n/de.po +++ b/mail_attach_existing_attachment/i18n/de.po @@ -20,18 +20,21 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__can_attach_attachment #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__can_attach_attachment msgid "Can Attach Attachment" msgstr "Kann Anhang anhängen" +#. module: mail_attach_existing_attachment +#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__display_object_attachment_ids +msgid "Display Object Attachment" +msgstr "" + #. module: mail_attach_existing_attachment #: model:ir.model,name:mail_attach_existing_attachment.model_mail_compose_message msgid "Email composition wizard" msgstr "Assistent zum Email verfassen" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__object_attachment_ids #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__object_attachment_ids #, fuzzy msgid "Object Attachments" diff --git a/mail_attach_existing_attachment/i18n/es.po b/mail_attach_existing_attachment/i18n/es.po index 58d61c35619..23b9543fe40 100644 --- a/mail_attach_existing_attachment/i18n/es.po +++ b/mail_attach_existing_attachment/i18n/es.po @@ -21,18 +21,21 @@ msgstr "" "X-Generator: Weblate 4.17\n" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__can_attach_attachment #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__can_attach_attachment msgid "Can Attach Attachment" msgstr "Puede adjuntar adjuntos" +#. module: mail_attach_existing_attachment +#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__display_object_attachment_ids +msgid "Display Object Attachment" +msgstr "" + #. module: mail_attach_existing_attachment #: model:ir.model,name:mail_attach_existing_attachment.model_mail_compose_message msgid "Email composition wizard" msgstr "Asistente composición Correo Electrónico" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__object_attachment_ids #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__object_attachment_ids msgid "Object Attachments" msgstr "Archivos adjuntos de objetos" diff --git a/mail_attach_existing_attachment/i18n/es_CO.po b/mail_attach_existing_attachment/i18n/es_CO.po index a11b3ba04cb..fb5bd09b8ff 100644 --- a/mail_attach_existing_attachment/i18n/es_CO.po +++ b/mail_attach_existing_attachment/i18n/es_CO.po @@ -19,18 +19,21 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__can_attach_attachment #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__can_attach_attachment msgid "Can Attach Attachment" msgstr "" +#. module: mail_attach_existing_attachment +#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__display_object_attachment_ids +msgid "Display Object Attachment" +msgstr "" + #. module: mail_attach_existing_attachment #: model:ir.model,name:mail_attach_existing_attachment.model_mail_compose_message msgid "Email composition wizard" msgstr "Asistente de redacción de E-mail" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__object_attachment_ids #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__object_attachment_ids msgid "Object Attachments" msgstr "" diff --git a/mail_attach_existing_attachment/i18n/fr.po b/mail_attach_existing_attachment/i18n/fr.po index 5fad366f286..428f66dfd09 100644 --- a/mail_attach_existing_attachment/i18n/fr.po +++ b/mail_attach_existing_attachment/i18n/fr.po @@ -20,18 +20,21 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__can_attach_attachment #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__can_attach_attachment msgid "Can Attach Attachment" msgstr "Il est possible d'attacher des pièces jointes" +#. module: mail_attach_existing_attachment +#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__display_object_attachment_ids +msgid "Display Object Attachment" +msgstr "" + #. module: mail_attach_existing_attachment #: model:ir.model,name:mail_attach_existing_attachment.model_mail_compose_message msgid "Email composition wizard" msgstr "Assistant de composition de courriel" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__object_attachment_ids #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__object_attachment_ids #, fuzzy msgid "Object Attachments" diff --git a/mail_attach_existing_attachment/i18n/he.po b/mail_attach_existing_attachment/i18n/he.po index 4c02acfb95b..d3c265b651c 100644 --- a/mail_attach_existing_attachment/i18n/he.po +++ b/mail_attach_existing_attachment/i18n/he.po @@ -18,18 +18,21 @@ msgstr "" "X-Generator: Weblate 3.10\n" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__can_attach_attachment #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__can_attach_attachment msgid "Can Attach Attachment" msgstr "ניתן לצרף קובץ מצורף" +#. module: mail_attach_existing_attachment +#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__display_object_attachment_ids +msgid "Display Object Attachment" +msgstr "" + #. module: mail_attach_existing_attachment #: model:ir.model,name:mail_attach_existing_attachment.model_mail_compose_message msgid "Email composition wizard" msgstr "אשף יצירת דואר אלקטרוני" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__object_attachment_ids #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__object_attachment_ids msgid "Object Attachments" msgstr "קבצים מצורפים לאובייקט" diff --git a/mail_attach_existing_attachment/i18n/hr.po b/mail_attach_existing_attachment/i18n/hr.po index 907bb5d7745..b07a723e1e9 100644 --- a/mail_attach_existing_attachment/i18n/hr.po +++ b/mail_attach_existing_attachment/i18n/hr.po @@ -17,22 +17,25 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" -"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__can_attach_attachment #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__can_attach_attachment msgid "Can Attach Attachment" msgstr "Može pridružiti privitak" +#. module: mail_attach_existing_attachment +#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__display_object_attachment_ids +msgid "Display Object Attachment" +msgstr "" + #. module: mail_attach_existing_attachment #: model:ir.model,name:mail_attach_existing_attachment.model_mail_compose_message msgid "Email composition wizard" msgstr "Čarobnjak za sastavljanje maila" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__object_attachment_ids #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__object_attachment_ids #, fuzzy msgid "Object Attachments" diff --git a/mail_attach_existing_attachment/i18n/it.po b/mail_attach_existing_attachment/i18n/it.po index 153311ccfb2..95ca26cadb6 100644 --- a/mail_attach_existing_attachment/i18n/it.po +++ b/mail_attach_existing_attachment/i18n/it.po @@ -21,18 +21,21 @@ msgstr "" "X-Generator: Weblate 5.6.2\n" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__can_attach_attachment #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__can_attach_attachment msgid "Can Attach Attachment" msgstr "Può inserire allegati" +#. module: mail_attach_existing_attachment +#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__display_object_attachment_ids +msgid "Display Object Attachment" +msgstr "Visualizza allegato oggetto" + #. module: mail_attach_existing_attachment #: model:ir.model,name:mail_attach_existing_attachment.model_mail_compose_message msgid "Email composition wizard" msgstr "Procedura guidata creazione e-mail" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__object_attachment_ids #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__object_attachment_ids msgid "Object Attachments" msgstr "Allegati oggetto" diff --git a/mail_attach_existing_attachment/i18n/mail_attach_existing_attachment.pot b/mail_attach_existing_attachment/i18n/mail_attach_existing_attachment.pot index 0abc5c00134..13f148abb8a 100644 --- a/mail_attach_existing_attachment/i18n/mail_attach_existing_attachment.pot +++ b/mail_attach_existing_attachment/i18n/mail_attach_existing_attachment.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" +"Project-Id-Version: Odoo Server 17.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -14,18 +14,21 @@ msgstr "" "Plural-Forms: \n" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__can_attach_attachment #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__can_attach_attachment msgid "Can Attach Attachment" msgstr "" +#. module: mail_attach_existing_attachment +#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__display_object_attachment_ids +msgid "Display Object Attachment" +msgstr "" + #. module: mail_attach_existing_attachment #: model:ir.model,name:mail_attach_existing_attachment.model_mail_compose_message msgid "Email composition wizard" msgstr "" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__object_attachment_ids #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__object_attachment_ids msgid "Object Attachments" msgstr "" diff --git a/mail_attach_existing_attachment/i18n/pt_BR.po b/mail_attach_existing_attachment/i18n/pt_BR.po index 97c40b24a99..497ae45c47f 100644 --- a/mail_attach_existing_attachment/i18n/pt_BR.po +++ b/mail_attach_existing_attachment/i18n/pt_BR.po @@ -21,18 +21,21 @@ msgstr "" "X-Generator: Weblate 3.8\n" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__can_attach_attachment #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__can_attach_attachment msgid "Can Attach Attachment" msgstr "Pode Anexar Anexo" +#. module: mail_attach_existing_attachment +#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__display_object_attachment_ids +msgid "Display Object Attachment" +msgstr "" + #. module: mail_attach_existing_attachment #: model:ir.model,name:mail_attach_existing_attachment.model_mail_compose_message msgid "Email composition wizard" msgstr "Assistente de Composição de Email" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__object_attachment_ids #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__object_attachment_ids msgid "Object Attachments" msgstr "Anexos de Objeto" diff --git a/mail_attach_existing_attachment/i18n/sl.po b/mail_attach_existing_attachment/i18n/sl.po index 2794df127fa..038e553951d 100644 --- a/mail_attach_existing_attachment/i18n/sl.po +++ b/mail_attach_existing_attachment/i18n/sl.po @@ -17,23 +17,26 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" -"%100==4 ? 2 : 3;\n" +"Plural-Forms: nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || " +"n%100==4 ? 2 : 3;\n" "X-Generator: Weblate 3.10\n" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__can_attach_attachment #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__can_attach_attachment msgid "Can Attach Attachment" msgstr "Lahko pripenja priponke" +#. module: mail_attach_existing_attachment +#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__display_object_attachment_ids +msgid "Display Object Attachment" +msgstr "" + #. module: mail_attach_existing_attachment #: model:ir.model,name:mail_attach_existing_attachment.model_mail_compose_message msgid "Email composition wizard" msgstr "Čarovnik za sestavljanje e-pošte" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__object_attachment_ids #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__object_attachment_ids msgid "Object Attachments" msgstr "Priponke objekta" diff --git a/mail_attach_existing_attachment/i18n/zh_CN.po b/mail_attach_existing_attachment/i18n/zh_CN.po index 7cff2bcab5a..14f9c018967 100644 --- a/mail_attach_existing_attachment/i18n/zh_CN.po +++ b/mail_attach_existing_attachment/i18n/zh_CN.po @@ -20,18 +20,21 @@ msgstr "" "Plural-Forms: nplurals=1; plural=0;\n" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__can_attach_attachment #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__can_attach_attachment msgid "Can Attach Attachment" msgstr "" +#. module: mail_attach_existing_attachment +#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__display_object_attachment_ids +msgid "Display Object Attachment" +msgstr "" + #. module: mail_attach_existing_attachment #: model:ir.model,name:mail_attach_existing_attachment.model_mail_compose_message msgid "Email composition wizard" msgstr "" #. module: mail_attach_existing_attachment -#: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_account_invoice_send__object_attachment_ids #: model:ir.model.fields,field_description:mail_attach_existing_attachment.field_mail_compose_message__object_attachment_ids #, fuzzy msgid "Object Attachments" diff --git a/mail_attach_existing_attachment/readme/CONTRIBUTORS.md b/mail_attach_existing_attachment/readme/CONTRIBUTORS.md index 6d5a5f9f5e6..9070959d5dc 100644 --- a/mail_attach_existing_attachment/readme/CONTRIBUTORS.md +++ b/mail_attach_existing_attachment/readme/CONTRIBUTORS.md @@ -3,3 +3,5 @@ - [Tecnativa](https://www.tecnativa.com): - Sergio Teruel - Ernesto Tejeda +- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) + - Bhavesh Heliconia diff --git a/mail_attach_existing_attachment/static/description/index.html b/mail_attach_existing_attachment/static/description/index.html index cd62fa0e3a8..24004bdb7fa 100644 --- a/mail_attach_existing_attachment/static/description/index.html +++ b/mail_attach_existing_attachment/static/description/index.html @@ -367,7 +367,7 @@

Mail Attach Existing Attachment

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:ac2a9aa40b0d4a582c625061abbe71035a0b6c6421af29465d20d9e51dcfbda3 +!! source digest: sha256:06897e29cf4f22512f7b26e538e7883ef789bd3f99a6c2666c3f6fce2ac51427 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/social Translate me on Weblate Try me on Runboat

This module was written to add the possibility to add attachments @@ -434,6 +434,10 @@

Contributors

  • Ernesto Tejeda
  • +
  • Heliconia Solutions Pvt. Ltd.
      +
    • Bhavesh Heliconia
    • +
    +
  • diff --git a/mail_attach_existing_attachment/tests/test_mail_attach_existing_attachment.py b/mail_attach_existing_attachment/tests/test_mail_attach_existing_attachment.py index d762a36b7a1..5e3fd481275 100644 --- a/mail_attach_existing_attachment/tests/test_mail_attach_existing_attachment.py +++ b/mail_attach_existing_attachment/tests/test_mail_attach_existing_attachment.py @@ -1,14 +1,15 @@ # Copyright 2015 ACSONE SA/NV +# Copyright 2024 360ERP () # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo.tests import common +from odoo.tests import Form, TransactionCase -class TestAttachExistingAttachment(common.TransactionCase): - def setUp(self): - super().setUp() - self.partner_obj = self.env["res.partner"] - self.partner_01 = self.env["res.partner"].create( +class TestMailComposer(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner_01 = cls.env["res.partner"].create( { "name": "Partner 1", "email": "partner1@example.org", @@ -16,22 +17,74 @@ def setUp(self): "parent_id": False, } ) - - def test_send_email_attachment(self): - attach1 = self.env["ir.attachment"].create( + cls.attach1 = cls.env["ir.attachment"].create( { "name": "Attach1", "datas": "bWlncmF0aW9uIHRlc3Q=", "res_model": "res.partner", - "res_id": self.partner_01.id, + "res_id": cls.partner_01.id, } ) - vals = { - "model": "res.partner", - "partner_ids": [(6, 0, [self.partner_01.id])], - "res_id": self.partner_01.id, - "object_attachment_ids": [(6, 0, [attach1.id])], - } - mail = self.env["mail.compose.message"].create(vals) - values = mail.get_mail_values([self.partner_01.id]) - self.assertTrue(attach1.id in values[self.partner_01.id]["attachment_ids"]) + + def test_01_send_email_attachment(self): + """Test sending amail with attachment from Object Attachment of composer""" + # Open email composer + composer_form = Form( + self.env["mail.compose.message"].with_context( + default_composition_mode="comment", + default_model=self.partner_01._name, + default_res_ids=self.partner_01.ids, + ) + ) + + # Field can_attach_attachment is automatically set + self.assertTrue(composer_form.can_attach_attachment) + + # By default, no attachments are present + self.assertFalse(composer_form.partner_ids[:]) + self.assertEqual(len(composer_form.attachment_ids), 0) + self.assertEqual(len(composer_form.object_attachment_ids), 0) + + # One selectable Object Attachment is displayed + display_records = composer_form.display_object_attachment_ids._records + self.assertEqual(len(display_records), 1) + self.assertEqual(display_records[0]["id"], self.attach1.id) + + # Fill email composer with the Object Attachment + composer_form.partner_ids = self.partner_01 + composer_form.object_attachment_ids = self.attach1 + mail = composer_form.save() + + # Send email: the attachment is sent + values = mail._action_send_mail() + result_message = values[1] + self.assertEqual(result_message.attachment_ids, self.attach1) + + def test_02_prepare_mail_values(self): + """Test method _prepare_mail_values()""" + attach2 = self.attach1.copy() + # Create email composer with 2 Object Attachments + composer = ( + self.env["mail.compose.message"] + .with_context( + default_composition_mode="comment", + default_model=self.partner_01._name, + default_res_ids=self.partner_01.ids, + ) + .create( + { + "object_attachment_ids": (self.attach1 + attach2).ids, + } + ) + ) + + # Two selectable Object Attachments are displayed + display_records = composer.display_object_attachment_ids + self.assertEqual(len(display_records), 2) + self.assertIn(self.attach1, display_records) + self.assertIn(attach2, display_records) + + # Invoking _prepare_mail_values(): both attachment_ids are set + values = composer._prepare_mail_values(self.partner_01.ids) + self.assertIn(self.attach1.id, values[self.partner_01.id]["attachment_ids"]) + self.assertIn(attach2.id, values[self.partner_01.id]["attachment_ids"]) diff --git a/mail_attach_existing_attachment/wizard/mail_compose_message.py b/mail_attach_existing_attachment/wizard/mail_compose_message.py index 671bb987c77..205893ff935 100644 --- a/mail_attach_existing_attachment/wizard/mail_compose_message.py +++ b/mail_attach_existing_attachment/wizard/mail_compose_message.py @@ -11,10 +11,10 @@ class MailComposeMessage(models.TransientModel): def default_get(self, fields_list): res = super().default_get(fields_list) if ( - res.get("res_id") + "can_attach_attachment" not in res and res.get("model") + and res.get("res_ids") and res.get("composition_mode", "") != "mass_mail" - and not res.get("can_attach_attachment") ): res["can_attach_attachment"] = True # pragma: no cover return res @@ -27,9 +27,29 @@ def default_get(self, fields_list): column2="attachment_id", string="Object Attachments", ) + display_object_attachment_ids = fields.One2many( + comodel_name="ir.attachment", + compute="_compute_display_object_attachment_ids", + ) + + @api.depends("res_ids", "model") + def _compute_display_object_attachment_ids(self): + for composer in self: + res_ids = self._evaluate_res_ids() + model = self.model + if model and res_ids: + attachments = self.env["ir.attachment"].search( + [ + ("res_model", "=", model), + ("res_id", "in", res_ids), + ] + ) + composer.display_object_attachment_ids = attachments + else: + composer.display_object_attachment_ids = False - def get_mail_values(self, res_ids): - res = super().get_mail_values(res_ids) + def _prepare_mail_values(self, res_ids): + res = super()._prepare_mail_values(res_ids) if self.object_attachment_ids.ids and self.model and len(res_ids) == 1: res[res_ids[0]].setdefault("attachment_ids", []).extend( self.object_attachment_ids.ids diff --git a/mail_attach_existing_attachment/wizard/mail_compose_message_view.xml b/mail_attach_existing_attachment/wizard/mail_compose_message_view.xml index 2ac084ffe6b..e0b816258ac 100644 --- a/mail_attach_existing_attachment/wizard/mail_compose_message_view.xml +++ b/mail_attach_existing_attachment/wizard/mail_compose_message_view.xml @@ -1,19 +1,17 @@ - - mail.compose.message.form (mail_attach_existing_attachment) + mail.compose.message +