From 30dee5faa3c8fdb0a69ae42811d31f171c813b13 Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Tue, 7 Dec 2021 11:45:22 +0100 Subject: [PATCH 01/16] Small improvements on communication layout --- report_compassion/report/bvr_sponsorship.xml | 9 ++------- report_compassion/report/partner_communication.xml | 13 ++++++++----- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/report_compassion/report/bvr_sponsorship.xml b/report_compassion/report/bvr_sponsorship.xml index 68ffc9e25..84cbff0f9 100644 --- a/report_compassion/report/bvr_sponsorship.xml +++ b/report_compassion/report/bvr_sponsorship.xml @@ -145,7 +145,7 @@ - + @@ -159,11 +159,6 @@ - - - display: none; - - - + diff --git a/report_compassion/report/partner_communication.xml b/report_compassion/report/partner_communication.xml index 452f71106..5f0a65d63 100644 --- a/report_compassion/report/partner_communication.xml +++ b/report_compassion/report/partner_communication.xml @@ -23,7 +23,6 @@ } #logo { display: inline-block; - margin-top: 6mm; width: 50mm; height: 20mm; } @@ -34,12 +33,16 @@ } #compassion_address { float: left; - margin-bottom: 5mm; + margin-top: 10mm; + font-size: 8pt; } #title { text-decoration: underline; margin-bottom: 2mm; } + #address { + margin-top: 8mm; + } #letter { position: absolute; font-family: "millerLight"; @@ -206,7 +209,7 @@
- +
@@ -226,7 +229,7 @@ 17-312562-0
-
+
P.P.
@@ -238,7 +241,7 @@
-
+
From d1f6d5359c81e19e834ba096092a7b68dfb8d7b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Margueron?= Date: Fri, 26 Nov 2021 09:50:14 +0100 Subject: [PATCH 02/16] CO-3824 : adding the new note from the statement to the invoice created If the note is present in the bank statement change the name of the invoice line to this note --- sponsorship_switzerland/models/completion_rules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sponsorship_switzerland/models/completion_rules.py b/sponsorship_switzerland/models/completion_rules.py index 05fe4a9c8..5fc22934f 100644 --- a/sponsorship_switzerland/models/completion_rules.py +++ b/sponsorship_switzerland/models/completion_rules.py @@ -350,7 +350,7 @@ def _generate_invoice(self, stmts_vals, st_line, partner, ref_index): def _generate_invoice_line(self, invoice_id, product, st_line, partner_id): inv_line_data = { - "name": product.name, + "name": st_line.get("note") or product.name, "account_id": product.property_account_income_id.id, "price_unit": st_line["amount"], "price_subtotal": st_line["amount"], From 93de9b04225269a43c9b97bb37b01312ef4de2e4 Mon Sep 17 00:00:00 2001 From: Raphael <15734398+TheRaphael0000@users.noreply.github.com> Date: Tue, 7 Dec 2021 15:56:21 +0100 Subject: [PATCH 03/16] CO-3835 : Make "Write a letter" page available without login (#1434) * CO-3835: Make "Write a letter" page available without login implement a magic route that create a user from a partner uuid and log it to my compassion * CO-3835 : avoid SQL injection from the email address * CO-3835 : Refactor the magic_login and add a created_with_magic_link field to track these users --- website_compassion/controllers/my_account.py | 68 ++++++++++++++++++++ website_compassion/models/res_user.py | 5 +- 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/website_compassion/controllers/my_account.py b/website_compassion/controllers/my_account.py index feaef0d60..a8b1789d5 100644 --- a/website_compassion/controllers/my_account.py +++ b/website_compassion/controllers/my_account.py @@ -17,6 +17,8 @@ from urllib.request import urlretrieve, urlopen from math import ceil from dateutil.relativedelta import relativedelta +import secrets +from passlib.context import CryptContext from werkzeug.datastructures import Headers from werkzeug.wrappers import Response @@ -198,6 +200,72 @@ def _download_image(type, child_id=None, obj_id=None): class MyAccountController(PaymentFormController): + @route("/my/login//", type="http", auth="public", website=True) + def magic_login(self, partner_uuid=None, redirect_page=None): + if not partner_uuid: + return None + + res_partner = request.env["res.partner"].sudo() + res_users = request.env["res.users"].sudo() + + partner = res_partner.search([["uuid", "=", partner_uuid]], limit=1) + partner = partner.sudo() + + redirect_page_request = request.redirect(f"/my/{redirect_page}") + + if not partner: + # partner does not exist + return redirect_page_request + + user = res_users.search([["partner_id", "=", partner.id]], limit=1) + + if user and not user.created_with_magic_link: + # user already have an account not created with the magic link + # this will ask him to log in then redirect him on the route asked + return redirect_page_request + + if not user: + # don't have a res_user must be created + login = MyAccountController._create_magic_user_from_partner(partner) + else: + # already have a res_user created with a magic link + login = user.login + + MyAccountController._reset_password_and_authenticate(login) + + return redirect_page_request + + @staticmethod + def _reset_password_and_authenticate(login): + # create a random password + password = secrets.token_urlsafe(16) + + # reset password + crypt_context = CryptContext(schemes=["pbkdf2_sha512", "plaintext"], deprecated=["plaintext"]) + password_encrypted = crypt_context.encrypt(password) + request.env.cr.execute("UPDATE res_users SET password=%s WHERE login=%s;", [password_encrypted, login]) + request.env.cr.commit() + + # authenticate + request.session.authenticate(request.session.db, login, password) + return True + + @staticmethod + def _create_magic_user_from_partner(partner): + res_users = request.env["res.users"].sudo() + + values = { + # ensure a login when the partner doesnt have an email + "login": partner.email or "magic_login_" + secrets.token_urlsafe(16), + "partner_id": partner.id, + "created_with_magic_link": True, + } + + # create a signup_token and create the account + partner.signup_prepare() + _, login, _ = res_users.signup(values=values, token=partner.signup_token) + return login + @route(["/my", "/my/home", "/my/account"], type="http", auth="user", website=True) def account(self, redirect=None, **post): # All this paths needs to be redirected diff --git a/website_compassion/models/res_user.py b/website_compassion/models/res_user.py index 971585697..65781e0f3 100644 --- a/website_compassion/models/res_user.py +++ b/website_compassion/models/res_user.py @@ -8,7 +8,8 @@ ############################################################################## import logging -from odoo import models, _ +from odoo import models, _, fields +from odoo.odoo import api _logger = logging.getLogger(__name__) @@ -16,6 +17,8 @@ class ResUsers(models.Model): _inherit = 'res.users' + created_with_magic_link = fields.Boolean(default=False) + def reset_password(self, login): """ retrieve the user corresponding to login (login or email), and reset their password From e018e9d261aedc209fc7fec59360669f08df00f0 Mon Sep 17 00:00:00 2001 From: duvenhage Date: Tue, 7 Dec 2021 16:00:33 +0100 Subject: [PATCH 04/16] CO-3807: Generate test cases fails (#1435) --- .../models/partner_communication_config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/partner_communication_switzerland/models/partner_communication_config.py b/partner_communication_switzerland/models/partner_communication_config.py index 2fc2e67f1..114ba58cd 100644 --- a/partner_communication_switzerland/models/partner_communication_config.py +++ b/partner_communication_switzerland/models/partner_communication_config.py @@ -114,6 +114,10 @@ def _get_test_objects(self, partner): ("partner_id", "=", partner.id), ("invoice_id.invoice_category", "=", "fund") ], limit=4).ids + elif self.model == "account.invoice": + object_ids = self.env["account.invoice"].search([ + ("partner_id", "=", partner.id) + ], limit=4).ids return object_ids def _find_partner(self, number_sponsorships, lang, family_case): From a4798c9183ffbf2022f074f0cd32170165fde648 Mon Sep 17 00:00:00 2001 From: Raphael <15734398+TheRaphael0000@users.noreply.github.com> Date: Thu, 9 Dec 2021 07:04:52 +0100 Subject: [PATCH 05/16] CO-3830 : change of email trigger a merge of mass.mailing.contact (#1430) * CO-3830 : change of email trigger a merge of mass.mailing.contact the remove condition was not correct and it should only remove the contract when these is no more partner in the contract * fix according to the pull request --- mass_mailing_switzerland/models/res_partner.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mass_mailing_switzerland/models/res_partner.py b/mass_mailing_switzerland/models/res_partner.py index d2869d5ee..e86d70acb 100644 --- a/mass_mailing_switzerland/models/res_partner.py +++ b/mass_mailing_switzerland/models/res_partner.py @@ -105,12 +105,21 @@ def write(self, vals): mailing_contact_vals["opt_out"] = vals["opt_out"] if "category_id" in vals: mailing_contact_vals["tag_ids"] = vals["category_id"] - if "email" in vals and not vals["email"] and not self.env.context.get( - "import_from_mailchimp"): - # In this case we don't need anymore the mailchimp contacts - mailing_contacts.unlink() + # Whenever a partner with a mailing_contacts change email we update his mailchimp data + if "email" in vals and not self.env.context.get("import_from_mailchimp"): + # Remove the hold the partner from the mailing_contact + mailing_contacts.write({"partner_ids": [(3, self.id)]}) + # If the partner was the last in this mailing_contact we don't need it anymore + # Keep the previous mailchimp_list_id before we potentially delete it + mailchimp_list_id = mailing_contacts.subscription_list_ids.mapped('list_id').mapped('mailchimp_list_id') + if len(mailing_contacts.partner_ids) <= 0: + mailing_contacts.unlink() + # If the new email is not None, Export to MailChimp the new email address + if vals["email"]: + self.action_export_partner_mailchimp(mailchimp_list_id) if mailing_contact_vals: mailing_contacts.write(mailing_contact_vals) + return super().write(vals) @api.multi From 81e80baf576a16bd3cad2280fd01c54acfa161ce Mon Sep 17 00:00:00 2001 From: Raphael <15734398+TheRaphael0000@users.noreply.github.com> Date: Thu, 9 Dec 2021 08:27:33 +0100 Subject: [PATCH 06/16] CO-3832 : add constrain on invoice validation (#1431) * CO-3832 : add constrain on invoice validation - Add a "raise UserError" when another account.invoice already is already open with the same transaction_id * adapt code according to the pr comments * fix accroding to pr --- sponsorship_switzerland/models/account_invoice.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sponsorship_switzerland/models/account_invoice.py b/sponsorship_switzerland/models/account_invoice.py index ee195ba99..8d6448958 100644 --- a/sponsorship_switzerland/models/account_invoice.py +++ b/sponsorship_switzerland/models/account_invoice.py @@ -93,3 +93,15 @@ def group_or_split_reconcile(self): """Reconcile given invoices with partner open payments. """ return self._group_or_split_reconcile() + + def action_invoice_open(self): + for invoice in self: + condition = [ + ("transaction_id", "=", invoice.transaction_id), + ("state", "in", ["open", "paid"]), + ("id", "!=", invoice.id), + ] + if self.env[self._name].search_count(condition): + error_msg = _("The Transaction ID `{}` is already used in another validated account invoice !") + raise UserError(error_msg.format(invoice.transaction_id)) + return super(AccountInvoice, self).action_invoice_open() \ No newline at end of file From 38a2513262cc285132c7b860d7b1326a9d51843b Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Thu, 9 Dec 2021 10:56:38 +0100 Subject: [PATCH 07/16] Force color black for communications and allow different font sizes. --- .../report/onboarding_photo_by_post.xml | 2 +- report_compassion/report/partner_communication.xml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/partner_communication_switzerland/report/onboarding_photo_by_post.xml b/partner_communication_switzerland/report/onboarding_photo_by_post.xml index 969eedfbf..31fe4b001 100644 --- a/partner_communication_switzerland/report/onboarding_photo_by_post.xml +++ b/partner_communication_switzerland/report/onboarding_photo_by_post.xml @@ -29,7 +29,7 @@ .container { font-family: "millerLight"; - font-size: 12pt; + font-size: 10pt; } #body { width: 100%; diff --git a/report_compassion/report/partner_communication.xml b/report_compassion/report/partner_communication.xml index 5f0a65d63..47f1012bb 100644 --- a/report_compassion/report/partner_communication.xml +++ b/report_compassion/report/partner_communication.xml @@ -46,7 +46,8 @@ #letter { position: absolute; font-family: "millerLight"; - font-size: 10pt; + font-size: pt; + color: black; top: 40mm; margin-left: 11mm; From 3c2746f58a8003a3776d63e97a777aa031ffd759 Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Thu, 9 Dec 2021 11:09:41 +0100 Subject: [PATCH 08/16] Fix bvr_due report styling --- report_compassion/report/bvr_sponsorship.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/report_compassion/report/bvr_sponsorship.xml b/report_compassion/report/bvr_sponsorship.xml index 84cbff0f9..6e39aecf5 100644 --- a/report_compassion/report/bvr_sponsorship.xml +++ b/report_compassion/report/bvr_sponsorship.xml @@ -133,8 +133,11 @@ From 0612bcd9a46225003e6251c9d6fe850dde4a63e5 Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Thu, 9 Dec 2021 13:07:07 +0100 Subject: [PATCH 09/16] CO-3835 Allow magic login to pass parameters --- website_compassion/controllers/my_account.py | 9 +++++---- website_compassion/models/res_user.py | 3 +-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/website_compassion/controllers/my_account.py b/website_compassion/controllers/my_account.py index a8b1789d5..ef722877c 100644 --- a/website_compassion/controllers/my_account.py +++ b/website_compassion/controllers/my_account.py @@ -24,7 +24,7 @@ from werkzeug.wrappers import Response from odoo import fields, _ -from odoo.http import request, route +from odoo.http import request, route, local_redirect from odoo.addons.web.controllers.main import content_disposition from odoo.addons.cms_form_compassion.controllers.payment_controller import ( PaymentFormController, @@ -200,8 +200,9 @@ def _download_image(type, child_id=None, obj_id=None): class MyAccountController(PaymentFormController): - @route("/my/login//", type="http", auth="public", website=True) - def magic_login(self, partner_uuid=None, redirect_page=None): + @route("/my/login//", type="http", auth="public", + website=True) + def magic_login(self, partner_uuid=None, redirect_page=None, **kwargs): if not partner_uuid: return None @@ -211,7 +212,7 @@ def magic_login(self, partner_uuid=None, redirect_page=None): partner = res_partner.search([["uuid", "=", partner_uuid]], limit=1) partner = partner.sudo() - redirect_page_request = request.redirect(f"/my/{redirect_page}") + redirect_page_request = local_redirect(f"/my/{redirect_page}", kwargs) if not partner: # partner does not exist diff --git a/website_compassion/models/res_user.py b/website_compassion/models/res_user.py index 65781e0f3..4f8651633 100644 --- a/website_compassion/models/res_user.py +++ b/website_compassion/models/res_user.py @@ -8,8 +8,7 @@ ############################################################################## import logging -from odoo import models, _, fields -from odoo.odoo import api +from odoo import models, fields _logger = logging.getLogger(__name__) From 906f6ed10d10e514cc8e8c1b9625e2a9063a641a Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Thu, 9 Dec 2021 13:22:50 +0100 Subject: [PATCH 10/16] CO-3830 Cosmetic changes and ensuring the email has changed --- mass_mailing_switzerland/models/res_partner.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/mass_mailing_switzerland/models/res_partner.py b/mass_mailing_switzerland/models/res_partner.py index e86d70acb..33bddbbb8 100644 --- a/mass_mailing_switzerland/models/res_partner.py +++ b/mass_mailing_switzerland/models/res_partner.py @@ -105,16 +105,21 @@ def write(self, vals): mailing_contact_vals["opt_out"] = vals["opt_out"] if "category_id" in vals: mailing_contact_vals["tag_ids"] = vals["category_id"] - # Whenever a partner with a mailing_contacts change email we update his mailchimp data - if "email" in vals and not self.env.context.get("import_from_mailchimp"): + # Whenever a partner with a mailing_contacts change email + # we update his mailchimp data + if "email" in vals and vals["email"] != partner.email and not \ + self.env.context.get("import_from_mailchimp"): # Remove the hold the partner from the mailing_contact mailing_contacts.write({"partner_ids": [(3, self.id)]}) - # If the partner was the last in this mailing_contact we don't need it anymore - # Keep the previous mailchimp_list_id before we potentially delete it - mailchimp_list_id = mailing_contacts.subscription_list_ids.mapped('list_id').mapped('mailchimp_list_id') + # If the partner was the last in this mailing_contact we don't need it + # anymore. Keep the previous mailchimp_list_id before + # we potentially delete it + mailchimp_list_id = mailing_contacts.subscription_list_ids.mapped( + 'list_id').mapped('mailchimp_list_id') if len(mailing_contacts.partner_ids) <= 0: mailing_contacts.unlink() - # If the new email is not None, Export to MailChimp the new email address + # If the new email is not None, Export to MailChimp the new email + # address if vals["email"]: self.action_export_partner_mailchimp(mailchimp_list_id) if mailing_contact_vals: From 2b7a00b2921fd929f4149780759ddfb70fdd784e Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Thu, 9 Dec 2021 14:31:36 +0100 Subject: [PATCH 11/16] Bug fixes --- child_sync_wp/tools/wp_sync.py | 2 +- wordpress_connector/models/contracts.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/child_sync_wp/tools/wp_sync.py b/child_sync_wp/tools/wp_sync.py index 8471a55ed..13958c638 100644 --- a/child_sync_wp/tools/wp_sync.py +++ b/child_sync_wp/tools/wp_sync.py @@ -131,7 +131,7 @@ def remove_children(self, children): _logger.info("Remove from Wordpress : " + str(res)) return res except: - _logger.error("Remove from Wordpress failed.") + _logger.error("Remove from Wordpress failed.", exc_info=True) return False diff --git a/wordpress_connector/models/contracts.py b/wordpress_connector/models/contracts.py index ea3e3b8d4..de7f5a033 100644 --- a/wordpress_connector/models/contracts.py +++ b/wordpress_connector/models/contracts.py @@ -254,6 +254,8 @@ def create_sponsorship_job(self, values, form_data): :param form_data: wordpress form data :return: record """ + child = self.env["compassion.child"].browse(values["child_id"]) + child.remove_from_wordpress() sponsorship = self.env["recurring.contract"].create(values) list_keys = [ "salutation", From a010f82ece2d3e9f9bdd3ef0a5bea8bceb4e1a28 Mon Sep 17 00:00:00 2001 From: Andre Date: Tue, 2 Nov 2021 07:42:05 +0100 Subject: [PATCH 12/16] CS-592 MyCompassion Tipps zum Schreiben grammer mistakes --- website_compassion/i18n/de.po | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/website_compassion/i18n/de.po b/website_compassion/i18n/de.po index 28140649c..233a5f035 100644 --- a/website_compassion/i18n/de.po +++ b/website_compassion/i18n/de.po @@ -796,7 +796,7 @@ msgstr "Spenden" #. module: website_compassion #: model_terms:ir.ui.view,arch_db:website_compassion.letter_text_content msgid "Make sure that any image you upload does not exceed 10Mb." -msgstr "Stell dich sicher, dass jedes Bild 10 MB nicht überschreitet." +msgstr "Bitte stelle sicher, dass dein Bild nicht 10 MB überschreitet." #. module: website_compassion #: model_terms:ir.ui.view,arch_db:website_compassion.my_donations_payment_options_multiple @@ -1245,8 +1245,7 @@ msgstr "" msgid "" "There are many easy-to-use solution to resize an image.
for example" msgstr "" -"Es gibt viele benutzerfreundliche Lösungen, um die Grösse eines Bildes zu " -"ändern.
Zum Beispiel" +"Du kannst die Grösse des Bildes verkleinern, bspw. über " #. module: website_compassion #: model_terms:ir.ui.view,arch_db:website_compassion.letter_actions From d02a4b969296d4bcd9d7363a76556ded599e2c5b Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Mon, 13 Dec 2021 09:07:00 +0100 Subject: [PATCH 13/16] Revert "CO-3830 Cosmetic changes and ensuring the email has changed" This reverts commit 906f6ed10d10e514cc8e8c1b9625e2a9063a641a. --- mass_mailing_switzerland/models/res_partner.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/mass_mailing_switzerland/models/res_partner.py b/mass_mailing_switzerland/models/res_partner.py index 33bddbbb8..e86d70acb 100644 --- a/mass_mailing_switzerland/models/res_partner.py +++ b/mass_mailing_switzerland/models/res_partner.py @@ -105,21 +105,16 @@ def write(self, vals): mailing_contact_vals["opt_out"] = vals["opt_out"] if "category_id" in vals: mailing_contact_vals["tag_ids"] = vals["category_id"] - # Whenever a partner with a mailing_contacts change email - # we update his mailchimp data - if "email" in vals and vals["email"] != partner.email and not \ - self.env.context.get("import_from_mailchimp"): + # Whenever a partner with a mailing_contacts change email we update his mailchimp data + if "email" in vals and not self.env.context.get("import_from_mailchimp"): # Remove the hold the partner from the mailing_contact mailing_contacts.write({"partner_ids": [(3, self.id)]}) - # If the partner was the last in this mailing_contact we don't need it - # anymore. Keep the previous mailchimp_list_id before - # we potentially delete it - mailchimp_list_id = mailing_contacts.subscription_list_ids.mapped( - 'list_id').mapped('mailchimp_list_id') + # If the partner was the last in this mailing_contact we don't need it anymore + # Keep the previous mailchimp_list_id before we potentially delete it + mailchimp_list_id = mailing_contacts.subscription_list_ids.mapped('list_id').mapped('mailchimp_list_id') if len(mailing_contacts.partner_ids) <= 0: mailing_contacts.unlink() - # If the new email is not None, Export to MailChimp the new email - # address + # If the new email is not None, Export to MailChimp the new email address if vals["email"]: self.action_export_partner_mailchimp(mailchimp_list_id) if mailing_contact_vals: From f5f55a64b51309c9fc34d06669d3eec6735cc4a8 Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Mon, 13 Dec 2021 09:07:00 +0100 Subject: [PATCH 14/16] Revert "CO-3830 : change of email trigger a merge of mass.mailing.contact (#1430)" This reverts commit a4798c9183ffbf2022f074f0cd32170165fde648. --- mass_mailing_switzerland/models/res_partner.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/mass_mailing_switzerland/models/res_partner.py b/mass_mailing_switzerland/models/res_partner.py index e86d70acb..d2869d5ee 100644 --- a/mass_mailing_switzerland/models/res_partner.py +++ b/mass_mailing_switzerland/models/res_partner.py @@ -105,21 +105,12 @@ def write(self, vals): mailing_contact_vals["opt_out"] = vals["opt_out"] if "category_id" in vals: mailing_contact_vals["tag_ids"] = vals["category_id"] - # Whenever a partner with a mailing_contacts change email we update his mailchimp data - if "email" in vals and not self.env.context.get("import_from_mailchimp"): - # Remove the hold the partner from the mailing_contact - mailing_contacts.write({"partner_ids": [(3, self.id)]}) - # If the partner was the last in this mailing_contact we don't need it anymore - # Keep the previous mailchimp_list_id before we potentially delete it - mailchimp_list_id = mailing_contacts.subscription_list_ids.mapped('list_id').mapped('mailchimp_list_id') - if len(mailing_contacts.partner_ids) <= 0: - mailing_contacts.unlink() - # If the new email is not None, Export to MailChimp the new email address - if vals["email"]: - self.action_export_partner_mailchimp(mailchimp_list_id) + if "email" in vals and not vals["email"] and not self.env.context.get( + "import_from_mailchimp"): + # In this case we don't need anymore the mailchimp contacts + mailing_contacts.unlink() if mailing_contact_vals: mailing_contacts.write(mailing_contact_vals) - return super().write(vals) @api.multi From 3f4e6c54bbbff2535c332e0f973cb88da6001c8f Mon Sep 17 00:00:00 2001 From: Raphael <15734398+TheRaphael0000@users.noreply.github.com> Date: Mon, 13 Dec 2021 09:13:35 +0100 Subject: [PATCH 15/16] CO-3840 : (#1436) - Set the default payment slip date interval to the same strategy everywhere - Remove useless import introduced from previous issue Co-authored-by: ecino --- report_compassion/wizards/print_sponsorship_bvr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/report_compassion/wizards/print_sponsorship_bvr.py b/report_compassion/wizards/print_sponsorship_bvr.py index af1afe7f0..06729409c 100644 --- a/report_compassion/wizards/print_sponsorship_bvr.py +++ b/report_compassion/wizards/print_sponsorship_bvr.py @@ -54,7 +54,7 @@ def default_start(self): today = date.today() start = today.replace(day=1, month=1) # Exception in December, we want to print for next year. - if today.month == 12 and today.day > 10: + if today.month == 12 and today.day >= 15: start = start.replace(year=today.year + 1) return start.replace(day=1) @@ -63,7 +63,7 @@ def default_stop(self): today = date.today() stop = today.replace(day=31, month=12) # Exception in December, we want to print for next year. - if today.month == 12 and today.day > 10: + if today.month == 12 and today.day >= 15: stop = stop.replace(year=today.year + 1) return stop From 6e63915288c1ab38aa1e73d3c7d69104ae062962 Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Mon, 13 Dec 2021 15:51:03 +0100 Subject: [PATCH 16/16] CO-3832 Allow empty transaction ids --- sponsorship_switzerland/models/account_invoice.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sponsorship_switzerland/models/account_invoice.py b/sponsorship_switzerland/models/account_invoice.py index 8d6448958..470a7ded0 100644 --- a/sponsorship_switzerland/models/account_invoice.py +++ b/sponsorship_switzerland/models/account_invoice.py @@ -98,6 +98,7 @@ def action_invoice_open(self): for invoice in self: condition = [ ("transaction_id", "=", invoice.transaction_id), + ("transaction_id", "!=", False), ("state", "in", ["open", "paid"]), ("id", "!=", invoice.id), ]