From 5b25319bbb6f4a5bc80c3403e231e03bc8258415 Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Tue, 22 Mar 2022 11:36:30 +0100 Subject: [PATCH 01/12] Create W&P communication after contract activation - To make sure all info is set before generating the communication --- partner_communication_switzerland/models/contracts.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/partner_communication_switzerland/models/contracts.py b/partner_communication_switzerland/models/contracts.py index e4f3c4609..176aae4f1 100644 --- a/partner_communication_switzerland/models/contracts.py +++ b/partner_communication_switzerland/models/contracts.py @@ -523,10 +523,12 @@ def contract_active(self): ).unlink() # Send sponsorship confirmation for write&pray sponsorships # that didn't get through waiting state (would already have the communication) - self.filtered( + wp = self.filtered( lambda s: s.type in ["SC", "SWP"] and s.state == "draft" - )._new_dossier() - return super().contract_active() + ) + super().contract_active() + wp._new_dossier() + return True @api.multi def contract_terminated(self): From 0d0da02f1fd01612686ac217a4875b0d2e397551 Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Tue, 22 Mar 2022 12:20:36 +0100 Subject: [PATCH 02/12] Include gifts in MyCompassion donations view --- website_compassion/controllers/my_account.py | 1 - 1 file changed, 1 deletion(-) diff --git a/website_compassion/controllers/my_account.py b/website_compassion/controllers/my_account.py index fc34c681e..c28b58ae2 100644 --- a/website_compassion/controllers/my_account.py +++ b/website_compassion/controllers/my_account.py @@ -447,7 +447,6 @@ def my_donations(self, invoice_page='1', form_id=None, invoice_per_page=30, **kw invoice_search_criteria = [ ("partner_id", "=", partner.id), ("state", "=", "paid"), - ("invoice_category", "in", ["sponsorship", "fund", "other"]), ("type", "=", "out_invoice"), ("amount_total", "!=", 0), ] From 8fe770f3a44febeda6e40ba3d2f8f47b7958b528 Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Tue, 22 Mar 2022 12:34:36 +0100 Subject: [PATCH 03/12] FIX dates of gifts on MyCompassion children page --- website_compassion/template/my_account_my_children.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website_compassion/template/my_account_my_children.xml b/website_compassion/template/my_account_my_children.xml index dbb6e35d9..d3b9f5cc9 100644 --- a/website_compassion/template/my_account_my_children.xml +++ b/website_compassion/template/my_account_my_children.xml @@ -324,7 +324,7 @@
- +
From c9b5c96397748ec9e0a692d0e29efd035a1d3f01 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Tue, 22 Mar 2022 16:06:21 +0100 Subject: [PATCH 04/12] CO-3920: links to make a gift online from my account are wrong (#1502) * CO-3920 Fix make a gift button and translations * Update translations based on exported file from odoo --- website_compassion/i18n/de.po | 6 ++++++ website_compassion/i18n/fr_CH.po | 8 +++++++- website_compassion/i18n/it.po | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/website_compassion/i18n/de.po b/website_compassion/i18n/de.po index 233a5f035..f5ba31cb4 100644 --- a/website_compassion/i18n/de.po +++ b/website_compassion/i18n/de.po @@ -203,6 +203,12 @@ msgstr "Briefe
" msgid "Make a donation" msgstr "Ein Geschenk machen
" +#. module: website_compassion +#: code:addons/website_compassion/controllers/my_account.py:418 +#, python-format +msgid "https://compassion.ch/de/geschenkformular" +msgstr "https://compassion.ch/de/geschenkformular" + #. module: website_compassion #: model_terms:ir.ui.view,arch_db:website_compassion.my_donations_gift_history msgid "Open contributions" diff --git a/website_compassion/i18n/fr_CH.po b/website_compassion/i18n/fr_CH.po index 0abb1b6fe..a06052a10 100644 --- a/website_compassion/i18n/fr_CH.po +++ b/website_compassion/i18n/fr_CH.po @@ -202,7 +202,13 @@ msgstr "Lettres" #. module: website_compassion #: model_terms:ir.ui.view,arch_db:website_compassion.my_children_gift_history msgid "Make a donation" -msgstr "Faire un don" +msgstr "Faire un cadeau" + +#. module: website_compassion +#: code:addons/website_compassion/controllers/my_account.py:418 +#, python-format +msgid "https://compassion.ch/de/geschenkformular" +msgstr "https://compassion.ch/formulaire-pour-cadeau" #. module: website_compassion #: model_terms:ir.ui.view,arch_db:website_compassion.my_donations_gift_history diff --git a/website_compassion/i18n/it.po b/website_compassion/i18n/it.po index 2da4ed8f8..8e827e1c8 100644 --- a/website_compassion/i18n/it.po +++ b/website_compassion/i18n/it.po @@ -206,6 +206,12 @@ msgstr "Lettere" msgid "Make a donation" msgstr "Fai una donazione
" +#. module: website_compassion +#: code:addons/website_compassion/controllers/my_account.py:418 +#, python-format +msgid "https://compassion.ch/de/geschenkformular" +msgstr "https://compassion.ch/it/formulario-per-regalo" + #. module: website_compassion #: model_terms:ir.ui.view,arch_db:website_compassion.my_donations_gift_history msgid "Open contributions" From 3bee06b048b419e3c319d9c6c0fb7e77df561213 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Tue, 22 Mar 2022 16:09:58 +0100 Subject: [PATCH 05/12] Translated letters for current year per advocate (#1504) --- sbc_switzerland/models/advocate_details.py | 11 +++++++++++ sbc_switzerland/views/advocate_view.xml | 1 + 2 files changed, 12 insertions(+) diff --git a/sbc_switzerland/models/advocate_details.py b/sbc_switzerland/models/advocate_details.py index 076fb347d..edbc27460 100644 --- a/sbc_switzerland/models/advocate_details.py +++ b/sbc_switzerland/models/advocate_details.py @@ -10,6 +10,7 @@ import logging from odoo import api, fields, models from . import translate_connector +from datetime import datetime _logger = logging.getLogger(__name__) @@ -25,6 +26,16 @@ class AdvocateDetails(models.Model): nb_translated_letters = fields.Integer( compute="_compute_nb_translated_letters", store=True ) + nb_translated_letters_this_year = fields.Integer( + compute="_compute_nb_translated_letters_this_year", store=True + ) + + @api.multi + @api.depends("partner_id.translated_letter_ids") + def _compute_nb_translated_letters_this_year(self): + for advocate in self: + advocate.nb_translated_letters_this_year = len(advocate.translated_letter_ids.filtered( + lambda it: it.translate_date.year == datetime.now().year)) @api.multi @api.depends("partner_id.translated_letter_ids") diff --git a/sbc_switzerland/views/advocate_view.xml b/sbc_switzerland/views/advocate_view.xml index 1dbc17eb7..296aed386 100644 --- a/sbc_switzerland/views/advocate_view.xml +++ b/sbc_switzerland/views/advocate_view.xml @@ -19,6 +19,7 @@ + From 4941426738587a78ec231828c317b43a89f4619d Mon Sep 17 00:00:00 2001 From: guillaume Date: Wed, 23 Mar 2022 08:08:34 +0100 Subject: [PATCH 06/12] put back office hours in signature --- partner_communication_switzerland/static/html/signature.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/partner_communication_switzerland/static/html/signature.html b/partner_communication_switzerland/static/html/signature.html index 478c06761..a504fa78c 100644 --- a/partner_communication_switzerland/static/html/signature.html +++ b/partner_communication_switzerland/static/html/signature.html @@ -38,7 +38,7 @@ alt="" valign="middle" style="display:block" height="14"> {phone} + target="_blank">{phone} {office_hours} | Date: Mon, 28 Mar 2022 07:39:10 +0200 Subject: [PATCH 07/12] CO-3940: Assign call task to event ambassador if church rep (#1507) * Assign call task to event ambassador if church rep From the communication job, retrieves the linked records if and only if they're recurring contracts, iterate over them to find an eventual related event through origin. If an event is found, get the ambassador and find the related employee and its job. If he's a church rep, assign him the call task, otherwise assign it to the default user (previous behavior) --- .../__manifest__.py | 1 + .../models/partner_communication.py | 40 ++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/partner_communication_switzerland/__manifest__.py b/partner_communication_switzerland/__manifest__.py index 482c70d87..8bcc210e8 100644 --- a/partner_communication_switzerland/__manifest__.py +++ b/partner_communication_switzerland/__manifest__.py @@ -37,6 +37,7 @@ "depends": [ "report_compassion", "child_switzerland", + "hr_switzerland", "theme_compassion", "sms_939", # compassion-switzerland "auth_signup", # source/addons diff --git a/partner_communication_switzerland/models/partner_communication.py b/partner_communication_switzerland/models/partner_communication.py index 1606ab90f..636f3e189 100644 --- a/partner_communication_switzerland/models/partner_communication.py +++ b/partner_communication_switzerland/models/partner_communication.py @@ -52,6 +52,43 @@ class PartnerCommunication(models.Model): readonly=False, ) + def get_related_contracts(self): + self.ensure_one() + object_ids = list(map(int, self.object_ids.split(","))) + if self.model != "recurring.contract": + # We're only interested in recurring contract, if the records linked to this communication are + # not contracts (which should not happen in the context of sponsorships waiting reminder 2, + # then we return an empty set + return self.env['recurring.contract'] + return self.env['recurring.contract'].sudo().search([('id', "in", object_ids)]) + + + def schedule_call(self): + self.ensure_one() + user_id = self.user_id.id + sponsorship_reminder_2 = self.env.ref('partner_communication_switzerland.sponsorship_waiting_reminder_2') + + # Check if we're in a sponsorship reminder 2 + if self.config_id.name == sponsorship_reminder_2.name: + church_rep = self.env.ref('hr_switzerland.employee_tag_church_rep') + related_contracts = self.get_related_contracts() + for contract in related_contracts: + event = contract.origin_id.event_id + if event.user_id: + employee = self.env['hr.employee'].sudo().search([('user_id', '=', event.user_id.id)], limit=1) + # Event ambassador is a church rep + if employee.job_id.name == church_rep.name: + user_id = event.user_id.id + + self.activity_schedule( + 'mail.mail_activity_data_call', + summary="Call " + self.partner_id.name, + user_id=user_id, + note=f"Call {self.partner_id.name} at (phone) " + f"{self.partner_phone or self.partner_mobile} regarding " + f"the communication." + ) + def print_letter(self, print_name, **print_options): """ Adds duplex printing option for Konica Minolta depending on page count. @@ -61,7 +98,7 @@ def print_letter(self, print_name, **print_options): # Duplex if all documents have a pair page count sided_option = "2sided" for p_count in page_counts: - if (p_count % 2 != 0): + if p_count % 2 != 0: sided_option = "1Sided" break print_options["KMDuplex"] = sided_option @@ -195,6 +232,7 @@ def get_family_slip_attachment(self): attachments = sponsorships.get_bvr_gift_attachment(family, background) return attachments + def get_all_gift_bvr(self): """ attach all 3 gifts slip with background for sending by e-mail From a9f1831241059df100eb8476a23d1de803de352f Mon Sep 17 00:00:00 2001 From: Guillaume Date: Mon, 28 Mar 2022 14:21:36 +0200 Subject: [PATCH 08/12] CO-3922: Convert amount raised to company currency (#1505) * raised amount is computed using currencies conversion if available * reuse company rather than retrieving it from within the loop * remove dead code * Using an SQL query is not really possible if we convert * group by date too inneficient * reverse back to origin * try to reproduce SQL query using search terms * work in progress setup background job * adding a "cache" field in muskathlon event_registration.py * use price_subtotal_signed * fix price_subtotal_signed in root event registration and update currency field * pages show company currency * muskathlon email templates replace CHF * Update muskathlon/data/mail_template.xml Co-authored-by: ecino * remove force_compute Co-authored-by: ecino --- muskathlon/data/mail_template.xml | 4 ++-- muskathlon/models/event_registration.py | 4 +++- muskathlon/reports/muskathlon_report.py | 4 ++-- muskathlon/templates/muskathlon_my_details.xml | 2 +- website_event_compassion/data/group_visit_emails.xml | 2 +- website_event_compassion/models/event_registration.py | 2 +- website_event_compassion/templates/event_page.xml | 6 ++++-- 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/muskathlon/data/mail_template.xml b/muskathlon/data/mail_template.xml index 971f8e13c..45f0cbc87 100644 --- a/muskathlon/data/mail_template.xml +++ b/muskathlon/data/mail_template.xml @@ -42,7 +42,7 @@ ${partner.salutation},

- Compassion Switzerland is glad to inform you that you just received a donation of CHF ${donations[0]}.- + Compassion Switzerland is glad to inform you that you just received a donation of ${object.user_id.company_id.currency_id.symbol} ${donations[0]}.- % if donations[1]: for the ${donations[1]}. % endif @@ -62,7 +62,7 @@ % endif % if muskathlon: - You currently have raised CHF ${muskathlon.amount_raised}.- You can check your barometer at anytime + You currently have raised ${object.user_id.company_id.currency_id.symbol} ${muskathlon.amount_raised}.- You can check your barometer at anytime on your sport profile page. % endif
diff --git a/muskathlon/models/event_registration.py b/muskathlon/models/event_registration.py index cbe06a208..16f264a61 100644 --- a/muskathlon/models/event_registration.py +++ b/muskathlon/models/event_registration.py @@ -70,10 +70,11 @@ def _compute_step2_tasks(self): def _compute_amount_raised(self): # Use Muskathlon report to compute Muskathlon event donation m_reg = self.filtered("compassion_event_id.website_muskathlon") + pids = m_reg.mapped("partner_id").ids origins = m_reg.mapped("compassion_event_id.origin_id") self.env.cr.execute(""" - SELECT sum(il.price_subtotal) AS amount, il.user_id, il.event_id + SELECT sum(il.price_subtotal_signed) AS amount, il.user_id, il.event_id FROM account_invoice_line il WHERE il.state = 'paid' AND il.account_id = 2775 -- Muskathlon event @@ -94,6 +95,7 @@ def _compute_amount_raised(self): r["amount"] for r in results if r["user_id"] == registration.partner_id_id and r["event_id"] == registration.compassion_event_id.id)) + super(MuskathlonRegistration, (self - m_reg))._compute_amount_raised() def _compute_is_in_two_months(self): diff --git a/muskathlon/reports/muskathlon_report.py b/muskathlon/reports/muskathlon_report.py index 6153e5863..67feb22d7 100644 --- a/muskathlon/reports/muskathlon_report.py +++ b/muskathlon/reports/muskathlon_report.py @@ -23,14 +23,14 @@ class Muskathlon(models.Model): date_display = fields.Date(readonly=True) partner_id = fields.Many2one("res.partner", "Partner", readonly=True) partner_name = fields.Char(related="partner_id.display_name", readonly=True) - user_id = fields.Many2one("res.partner", "Ambassador", readonly=True) + user_id = fields.Many2one("res.partner", "Ambassador", readonly=True, index=True) amount = fields.Float("Amount", readonly=True) amount_cent = fields.Integer("Amount in currency (cents)", readonly=True) sent_to_4m = fields.Date("Date sent to 4M", readonly=True) payment_mode_id = fields.Many2one( "account.payment.mode", "Payment mode", readonly=True ) - event_id = fields.Many2one("crm.event.compassion", "Event", readonly=True) + event_id = fields.Many2one("crm.event.compassion", "Event", readonly=True, index=True) journal_id = fields.Many2one("account.journal", "Journal", readonly=True) # fields needed for csv exportation diff --git a/muskathlon/templates/muskathlon_my_details.xml b/muskathlon/templates/muskathlon_my_details.xml index 9bbc77e78..2db4de4dc 100644 --- a/muskathlon/templates/muskathlon_my_details.xml +++ b/muskathlon/templates/muskathlon_my_details.xml @@ -28,7 +28,7 @@ - CHF + diff --git a/website_event_compassion/data/group_visit_emails.xml b/website_event_compassion/data/group_visit_emails.xml index 370dd6475..e21b8e788 100644 --- a/website_event_compassion/data/group_visit_emails.xml +++ b/website_event_compassion/data/group_visit_emails.xml @@ -76,7 +76,7 @@ Your registration for the ${event.name} is progressing well. Thank you very much for your interest in Compassion's work to free more children from poverty every day, for a dignified and meaningful life.

- To confirm your registration, you only need to pay a deposit of CHF ${'%d' |format(registration.event_ticket_id.price)}.- You have the choice to make this payment: + To confirm your registration, you only need to pay a deposit of ${object.user_id.company_id.currency_id.symbol} ${'%d' |format(registration.event_ticket_id.price)}.- You have the choice to make this payment:

  • diff --git a/website_event_compassion/models/event_registration.py b/website_event_compassion/models/event_registration.py index c211316e4..c63489447 100644 --- a/website_event_compassion/models/event_registration.py +++ b/website_event_compassion/models/event_registration.py @@ -227,7 +227,7 @@ def _compute_amount_raised(self): ] ) ) - amount_raised = sum(invoice_lines.mapped("price_subtotal")) + amount_raised = sum(invoice_lines.mapped("price_subtotal_signed")) s_value = registration.event_id.sponsorship_donation_value if s_value: nb_sponsorships = ( diff --git a/website_event_compassion/templates/event_page.xml b/website_event_compassion/templates/event_page.xml index 84cd7c44c..be164a051 100644 --- a/website_event_compassion/templates/event_page.xml +++ b/website_event_compassion/templates/event_page.xml @@ -38,14 +38,16 @@
    /CHF + t-esc="'{:n}'.format(barometer.amount_objective or 0).replace(',', '\'')"/> +
/CHF + t-esc="'{:n}'.format(barometer.amount_objective or 0).replace(',', '\'')"/> +
From d0c6141771bbd8c3e6ddd8df154a50925bb4e5fd Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Mon, 28 Mar 2022 15:00:06 +0200 Subject: [PATCH 09/12] CO-3928 FIX formatting of signature --- .../static/html/signature.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/partner_communication_switzerland/static/html/signature.html b/partner_communication_switzerland/static/html/signature.html index a504fa78c..e6cee1f81 100644 --- a/partner_communication_switzerland/static/html/signature.html +++ b/partner_communication_switzerland/static/html/signature.html @@ -36,9 +36,9 @@ - {phone} {office_hours} + + {phone} + {office_hours} | Date: Mon, 28 Mar 2022 15:08:02 +0200 Subject: [PATCH 10/12] CO-3922 FIX barometer template --- website_event_compassion/templates/event_page.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website_event_compassion/templates/event_page.xml b/website_event_compassion/templates/event_page.xml index be164a051..86723ec48 100644 --- a/website_event_compassion/templates/event_page.xml +++ b/website_event_compassion/templates/event_page.xml @@ -39,7 +39,7 @@
/ - +
@@ -47,7 +47,7 @@
/ - +
From e69d76e52418ef92fd7d27ef6ba2c02be7366a97 Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Tue, 29 Mar 2022 10:00:23 +0200 Subject: [PATCH 11/12] CO-3940 Corrections - Change super method in order to reuse it --- .../models/partner_communication.py | 43 ++++++------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/partner_communication_switzerland/models/partner_communication.py b/partner_communication_switzerland/models/partner_communication.py index 636f3e189..c56ffc4a4 100644 --- a/partner_communication_switzerland/models/partner_communication.py +++ b/partner_communication_switzerland/models/partner_communication.py @@ -52,42 +52,23 @@ class PartnerCommunication(models.Model): readonly=False, ) - def get_related_contracts(self): - self.ensure_one() - object_ids = list(map(int, self.object_ids.split(","))) - if self.model != "recurring.contract": - # We're only interested in recurring contract, if the records linked to this communication are - # not contracts (which should not happen in the context of sponsorships waiting reminder 2, - # then we return an empty set - return self.env['recurring.contract'] - return self.env['recurring.contract'].sudo().search([('id', "in", object_ids)]) - - def schedule_call(self): self.ensure_one() user_id = self.user_id.id - sponsorship_reminder_2 = self.env.ref('partner_communication_switzerland.sponsorship_waiting_reminder_2') + sponsorship_reminder_2 = self.env.ref( + "partner_communication_switzerland.sponsorship_waiting_reminder_2") - # Check if we're in a sponsorship reminder 2 - if self.config_id.name == sponsorship_reminder_2.name: - church_rep = self.env.ref('hr_switzerland.employee_tag_church_rep') - related_contracts = self.get_related_contracts() + if self.config_id == sponsorship_reminder_2: + related_contracts = self.get_objects() for contract in related_contracts: - event = contract.origin_id.event_id - if event.user_id: - employee = self.env['hr.employee'].sudo().search([('user_id', '=', event.user_id.id)], limit=1) - # Event ambassador is a church rep - if employee.job_id.name == church_rep.name: - user_id = event.user_id.id - - self.activity_schedule( - 'mail.mail_activity_data_call', - summary="Call " + self.partner_id.name, - user_id=user_id, - note=f"Call {self.partner_id.name} at (phone) " - f"{self.partner_phone or self.partner_mobile} regarding " - f"the communication." - ) + ambassador = contract.origin_id.event_id.user_id + employee = self.env["hr.employee"].sudo().search([ + ("user_id", "=", ambassador.id)], limit=1) + # Event ambassador is a church rep + if employee.job_id.with_context(lang="en_US").name == "Church rep": + user_id = ambassador.id + + super(PartnerCommunication, self.sudo(user_id)).schedule_call() def print_letter(self, print_name, **print_options): """ From 2513e8a9c10bcaa465dead2dcc2ff53208db6d9c Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Tue, 29 Mar 2022 10:05:19 +0200 Subject: [PATCH 12/12] Remove unneeded dependency --- partner_communication_switzerland/__manifest__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/partner_communication_switzerland/__manifest__.py b/partner_communication_switzerland/__manifest__.py index 8bcc210e8..482c70d87 100644 --- a/partner_communication_switzerland/__manifest__.py +++ b/partner_communication_switzerland/__manifest__.py @@ -37,7 +37,6 @@ "depends": [ "report_compassion", "child_switzerland", - "hr_switzerland", "theme_compassion", "sms_939", # compassion-switzerland "auth_signup", # source/addons