diff --git a/l10n_es_aeat_mod347/README.rst b/l10n_es_aeat_mod347/README.rst index 57b8deeee11..4fd8b3b0861 100644 --- a/l10n_es_aeat_mod347/README.rst +++ b/l10n_es_aeat_mod347/README.rst @@ -7,7 +7,7 @@ AEAT modelo 347 !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:81228fbd32728122f983b70f103aeec75e916fa931d483ea00e63f9b28353f36 + !! source digest: sha256:4c3142bf94e5da0cd42ce6af1893ee5bc013612bae8f96a39ca1dab9aa7db393 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -198,6 +198,7 @@ Contributors * `Sygel `_: * Manuel Regidor + * Alejandro Ji Cheung (https://factorlibre.com) Maintainers ~~~~~~~~~~~ diff --git a/l10n_es_aeat_mod347/__init__.py b/l10n_es_aeat_mod347/__init__.py index c55325ead5d..4dbe3c8d00b 100644 --- a/l10n_es_aeat_mod347/__init__.py +++ b/l10n_es_aeat_mod347/__init__.py @@ -1,4 +1,5 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import controllers +from . import wizard from . import models diff --git a/l10n_es_aeat_mod347/__manifest__.py b/l10n_es_aeat_mod347/__manifest__.py index 46c95d793a2..b881fd9dfde 100644 --- a/l10n_es_aeat_mod347/__manifest__.py +++ b/l10n_es_aeat_mod347/__manifest__.py @@ -6,6 +6,7 @@ # Copyright 2016 Tecnativa - Angel Moya # Copyright 2018 PESOL - Angel Moya # Copyright 2014-2022 Tecnativa - Pedro M. Baeza +# Copyright 2023 FactorLibre - Alejandro Ji Cheung # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { diff --git a/l10n_es_aeat_mod347/models/mod347.py b/l10n_es_aeat_mod347/models/mod347.py index d7acb4f8fb0..872c7c592ca 100644 --- a/l10n_es_aeat_mod347/models/mod347.py +++ b/l10n_es_aeat_mod347/models/mod347.py @@ -7,6 +7,7 @@ # Copyright 2018 PESOL - Angel Moya # Copyright 2019 Tecnativa - Carlos Dauden # Copyright 2014-2022 Tecnativa - Pedro M. Baeza +# Copyright 2023 FactorLibre - Alejandro Ji Cheung # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). import datetime @@ -175,7 +176,7 @@ def button_confirm(self): def button_send_mails(self): self.partner_record_ids.filtered( - lambda x: x.state == "pending" + lambda x: x.state == "pending" and x.partner_id.email ).send_email_direct() def btn_list_records(self): @@ -585,7 +586,6 @@ def action_confirm(self): self.write({"state": "confirmed"}) def action_send(self): - self.write({"state": "sent"}) self.ensure_one() template = self.env.ref("l10n_es_aeat_mod347.email_template_347") compose_form = self.env.ref("mail.email_compose_message_wizard_form") @@ -625,9 +625,13 @@ def button_recompute(self): def send_email_direct(self): template = self.env.ref("l10n_es_aeat_mod347.email_template_347") + sent_records = self.env["l10n.es.aeat.mod347.partner_record"] for record in self: - template.send_mail(record.id) - self.write({"state": "sent"}) + mail_id = template.send_mail(record.id) + if mail_id: + sent_records |= record + if sent_records: + sent_records.write({"state": "sent"}) def action_pending(self): self.write({"state": "pending"}) diff --git a/l10n_es_aeat_mod347/readme/CONTRIBUTORS.rst b/l10n_es_aeat_mod347/readme/CONTRIBUTORS.rst index c49365ba214..ad488e954ac 100644 --- a/l10n_es_aeat_mod347/readme/CONTRIBUTORS.rst +++ b/l10n_es_aeat_mod347/readme/CONTRIBUTORS.rst @@ -14,3 +14,4 @@ * `Sygel `_: * Manuel Regidor + * Alejandro Ji Cheung (https://factorlibre.com) diff --git a/l10n_es_aeat_mod347/static/description/index.html b/l10n_es_aeat_mod347/static/description/index.html index 2156c327a49..c595910da63 100644 --- a/l10n_es_aeat_mod347/static/description/index.html +++ b/l10n_es_aeat_mod347/static/description/index.html @@ -366,7 +366,7 @@

AEAT modelo 347

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:81228fbd32728122f983b70f103aeec75e916fa931d483ea00e63f9b28353f36 +!! source digest: sha256:4c3142bf94e5da0cd42ce6af1893ee5bc013612bae8f96a39ca1dab9aa7db393 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

(DeclaraciĆ³n Anual de Operaciones con Terceros) @@ -544,6 +544,7 @@

Contributors

  • Sygel:
  • diff --git a/l10n_es_aeat_mod347/tests/test_l10n_es_aeat_mod347.py b/l10n_es_aeat_mod347/tests/test_l10n_es_aeat_mod347.py index e5c1ebb5f79..f245a71442c 100644 --- a/l10n_es_aeat_mod347/tests/test_l10n_es_aeat_mod347.py +++ b/l10n_es_aeat_mod347/tests/test_l10n_es_aeat_mod347.py @@ -185,3 +185,24 @@ def test_model_347(self): for xml_id in export_config_xml_ids: export_config = self.env.ref(xml_id) self.assertTrue(export_to_boe._export_config(self.model347, export_config)) + + def test_partner_record_ids_states(self): + self.model347.button_calculate() + first_partner_mod347_record = self.model347.partner_record_ids[0] + first_partner = first_partner_mod347_record.partner_id + self.assertFalse(first_partner.email) + + second_partner_mod347_record = self.model347.partner_record_ids[1] + second_partner = second_partner_mod347_record.partner_id + second_partner.email = "test@email.com" + + self.model347.button_send_mails() + self.assertTrue(first_partner_mod347_record.state, "pending") + self.assertTrue(second_partner_mod347_record.state, "sent") + + first_partner_mod347_record.action_send() + self.assertTrue(first_partner_mod347_record.state, "pending") + + first_partner.email = "test1@email.com" + first_partner_mod347_record.action_send() + self.assertTrue(first_partner_mod347_record.state, "sent") diff --git a/l10n_es_aeat_mod347/wizard/__init__.py b/l10n_es_aeat_mod347/wizard/__init__.py new file mode 100644 index 00000000000..43d2e2ee3e9 --- /dev/null +++ b/l10n_es_aeat_mod347/wizard/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2023 FactorLibre - Alejandro Ji Cheung +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import mail_compose_message diff --git a/l10n_es_aeat_mod347/wizard/mail_compose_message.py b/l10n_es_aeat_mod347/wizard/mail_compose_message.py new file mode 100644 index 00000000000..6d590fb1a32 --- /dev/null +++ b/l10n_es_aeat_mod347/wizard/mail_compose_message.py @@ -0,0 +1,18 @@ +# Copyright 2023 FactorLibre - Alejandro Ji Cheung +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import models + + +class MailComposer(models.TransientModel): + _inherit = "mail.compose.message" + + def _action_send_mail(self, auto_commit=False): + res = super()._action_send_mail(auto_commit=auto_commit) + default_model = self._context.get("default_model", False) + if default_model == "l10n.es.aeat.mod347.partner_record": + result_message = res[1] + active_id = self._context.get("active_id") + record = self.env["l10n.es.aeat.mod347.partner_record"].browse(active_id) + if result_message.mail_ids: + record.write({"state": "sent"}) + return res