From 5baa77b998ce34b0e637f24c34e010fa71d0c44b Mon Sep 17 00:00:00 2001 From: NoeBerdoz Date: Mon, 8 Jun 2026 17:45:29 +0200 Subject: [PATCH 1/2] [MIG] T3067: website_sponsorship burst related changes - partner_salutation: add is_shown_on_public_forms on res.partner.title with a - curation column; seed Mister and Madam via a post-migration (version 18.0.1.1.0). - sponsorship_compassion: host legal_agreement_date on res.partner (moved out of the deleted website_sponsorship) and show it on the partner form. --- partner_salutation/__manifest__.py | 2 +- .../migrations/18.0.1.1.0/post-migration.py | 41 +++++++++++++++++++ .../models/res_partner_title.py | 5 +++ .../views/res_partner_title_view.xml | 1 + sponsorship_compassion/models/res_partner.py | 2 + .../views/res_partner_view.xml | 1 + 6 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 partner_salutation/migrations/18.0.1.1.0/post-migration.py diff --git a/partner_salutation/__manifest__.py b/partner_salutation/__manifest__.py index 89fab6de8..acd8721dc 100644 --- a/partner_salutation/__manifest__.py +++ b/partner_salutation/__manifest__.py @@ -30,7 +30,7 @@ { "name": "Compassion Partner Communications", "summary": "Adds a salutation field on partners", - "version": "18.0.1.0.0", + "version": "18.0.1.1.0", "development_status": "Production/Stable", "category": "Partner Management", "website": "https://github.com/CompassionCH/compassion-modules", diff --git a/partner_salutation/migrations/18.0.1.1.0/post-migration.py b/partner_salutation/migrations/18.0.1.1.0/post-migration.py new file mode 100644 index 000000000..02da4976f --- /dev/null +++ b/partner_salutation/migrations/18.0.1.1.0/post-migration.py @@ -0,0 +1,41 @@ +############################################################################## +# +# Copyright (C) 2026 Compassion CH (http://www.compassion.ch) +# Releasing children from poverty in Jesus' name +# @author: NoƩ Berdoz +# +# The licence is in the file __manifest__.py +# +############################################################################## +import logging + +from odoo import SUPERUSER_ID, api + +_logger = logging.getLogger(__name__) + +# Salutations offered on the public-facing forms by default. Curators adjust +# the set afterwards from the title list; this only sets the initial value. +DEFAULT_PUBLIC_TITLE_XMLIDS = [ + "base.res_partner_title_mister", + "base.res_partner_title_madam", +] + + +def migrate(cr, version): + """Set the initial value of res.partner.title.is_shown_on_public_forms. + + Runs once on the upgrade that introduces the field. Curators own the set + from then on, and later upgrades leave their choices untouched. + """ + env = api.Environment(cr, SUPERUSER_ID, {}) + titles = env["res.partner.title"] + for xmlid in DEFAULT_PUBLIC_TITLE_XMLIDS: + title = env.ref(xmlid, raise_if_not_found=False) + if title: + titles |= title + if titles: + titles.is_shown_on_public_forms = True + _logger.info( + "Seeded is_shown_on_public_forms on default public titles: %s", + titles.mapped("name"), + ) diff --git a/partner_salutation/models/res_partner_title.py b/partner_salutation/models/res_partner_title.py index 3defff7f9..088c17318 100644 --- a/partner_salutation/models/res_partner_title.py +++ b/partner_salutation/models/res_partner_title.py @@ -22,3 +22,8 @@ class ResPartnerTitle(models.Model): plural = fields.Boolean() order_index = fields.Integer() + is_shown_on_public_forms = fields.Boolean( + help="If set, this salutation is offered in the public-facing forms " + "(sponsorship wizard, donation, project creation). When unset, the " + "salutation stays usable in the backend but is hidden from those forms.", + ) diff --git a/partner_salutation/views/res_partner_title_view.xml b/partner_salutation/views/res_partner_title_view.xml index 8559ee851..563ae7386 100644 --- a/partner_salutation/views/res_partner_title_view.xml +++ b/partner_salutation/views/res_partner_title_view.xml @@ -8,6 +8,7 @@ + diff --git a/sponsorship_compassion/models/res_partner.py b/sponsorship_compassion/models/res_partner.py index 0f353d03b..43d2d9635 100644 --- a/sponsorship_compassion/models/res_partner.py +++ b/sponsorship_compassion/models/res_partner.py @@ -40,6 +40,7 @@ class ResPartner(models.Model): required=True, ) global_id = fields.Char("Global ID", copy=False) + legal_agreement_date = fields.Datetime("Date of legal agreement", tracking=True) contracts_fully_managed = fields.One2many( "recurring.contract", compute="_compute_related_contracts", @@ -464,6 +465,7 @@ def _random_str(): "title": False, "country_id": False, "uuid": False, + "legal_agreement_date": False, } ) partner.env["mail.mail"].search([("recipient_ids", "=", partner.id)]).unlink() diff --git a/sponsorship_compassion/views/res_partner_view.xml b/sponsorship_compassion/views/res_partner_view.xml index dbfe0cdae..c13ca66d1 100644 --- a/sponsorship_compassion/views/res_partner_view.xml +++ b/sponsorship_compassion/views/res_partner_view.xml @@ -14,6 +14,7 @@ + From 75147758c150d984ac4146127d245367e2f0d348 Mon Sep 17 00:00:00 2001 From: NoeBerdoz Date: Tue, 16 Jun 2026 10:42:00 +0200 Subject: [PATCH 2/2] [MIG] T3067: fix tests on v18 --- sponsorship_compassion/tests/test_project_compassion.py | 3 ++- thankyou_letters/tests/test_thankyou_config.py | 4 ++-- thankyou_letters/tests/test_thankyou_letters.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sponsorship_compassion/tests/test_project_compassion.py b/sponsorship_compassion/tests/test_project_compassion.py index 7a439346b..e01af83d0 100644 --- a/sponsorship_compassion/tests/test_project_compassion.py +++ b/sponsorship_compassion/tests/test_project_compassion.py @@ -6,9 +6,10 @@ import random from unittest.mock import patch +from dateutil.relativedelta import relativedelta + from odoo import fields from odoo.tests import TransactionCase -from odoo.tools import relativedelta PROJECT_COMPASSION_ADDON = ( "odoo.addons.child_compassion.models.project_compassion.CompassionProject" diff --git a/thankyou_letters/tests/test_thankyou_config.py b/thankyou_letters/tests/test_thankyou_config.py index 257f3df7d..3486058de 100644 --- a/thankyou_letters/tests/test_thankyou_config.py +++ b/thankyou_letters/tests/test_thankyou_config.py @@ -7,10 +7,10 @@ # ############################################################################## -from odoo.tests import SavepointCase +from odoo.tests import TransactionCase -class TestThankYouLetters(SavepointCase): +class TestThankYouLetters(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/thankyou_letters/tests/test_thankyou_letters.py b/thankyou_letters/tests/test_thankyou_letters.py index 128f21746..1f6f1d52a 100644 --- a/thankyou_letters/tests/test_thankyou_letters.py +++ b/thankyou_letters/tests/test_thankyou_letters.py @@ -9,12 +9,12 @@ import logging import time -from odoo.tests import SavepointCase +from odoo.tests import TransactionCase logger = logging.getLogger(__name__) -class TestThankYouLetters(SavepointCase): +class TestThankYouLetters(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass()