-
-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] l10n_es_aeat_mod347: fix added for partner_record's states
- Loading branch information
1 parent
74025f8
commit 570bcd7
Showing
9 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
# Copyright 2016 Tecnativa - Angel Moya <[email protected]> | ||
# Copyright 2018 PESOL - Angel Moya <[email protected]> | ||
# 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). | ||
|
||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
# Copyright 2018 PESOL - Angel Moya <[email protected]> | ||
# 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"}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ | |
* `Sygel <https://www.sygel.es>`_: | ||
|
||
* Manuel Regidor | ||
* Alejandro Ji Cheung (https://factorlibre.com) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = "[email protected]" | ||
|
||
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 = "[email protected]" | ||
first_partner_mod347_record.action_send() | ||
self.assertTrue(first_partner_mod347_record.state, "sent") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |