Skip to content

Commit

Permalink
Merge pull request #1508 from CompassionCH/devel
Browse files Browse the repository at this point in the history
2022.5
  • Loading branch information
ecino authored Mar 29, 2022
2 parents 36c43f7 + 2513e8a commit a4c6a14
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 20 deletions.
4 changes: 2 additions & 2 deletions muskathlon/data/mail_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
${partner.salutation},
<br/>
<br/>
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
Expand All @@ -62,7 +62,7 @@
</ul>
% 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
<a href="${muskathlon.website_url}" style="color: skyblue; text-decoration: underline;">on your sport profile page</a>.
% endif
<br/>
Expand Down
4 changes: 3 additions & 1 deletion muskathlon/models/event_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions muskathlon/reports/muskathlon_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion muskathlon/templates/muskathlon_my_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</td>
<td>
<t t-esc="report.amount"/>
CHF
<t t-esc="report.currency_id.symbol" />
</td>
</tr>
</t>
Expand Down
8 changes: 5 additions & 3 deletions partner_communication_switzerland/models/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@ class PartnerCommunication(models.Model):
readonly=False,
)

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")

if self.config_id == sponsorship_reminder_2:
related_contracts = self.get_objects()
for contract in related_contracts:
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):
"""
Adds duplex printing option for Konica Minolta depending on page count.
Expand All @@ -61,7 +79,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
Expand Down Expand Up @@ -195,6 +213,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
Expand Down
6 changes: 3 additions & 3 deletions partner_communication_switzerland/static/html/signature.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
<td style="margin:0.1px;padding:0 5px 0 0"><img
src="https://img.newoldstamp.com/i/ib/005eb8/icon105/phone.png?t=2e"
alt="" valign="middle" style="display:block" height="14"></td>
<td style="margin:0.1px;font-family:Arial"><a href="{phone_link}"
style="text-decoration:none;color:#000000;font-size:13px"
target="_blank">{phone}</a></td>
<td style="margin:0.1px;font-family:Arial">
<a href="{phone_link}" style="text-decoration:none;color:#000000;font-size:13px" target="_blank">{phone}</a>
<span style="text-decoration:none;color:#000000;font-size:13px"> {office_hours}</span></td>
<td class="work_mobile" style="margin:0.1px;padding:0 5px;font-family:Arial">|</td>
<td class="work_mobile" style="margin:0.1px;padding:0 5px 0 0"><img
src="https://img.newoldstamp.com/i/ib/005eb8/icon105/phone.png?t=2e"
Expand Down
11 changes: 11 additions & 0 deletions sbc_switzerland/models/advocate_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import logging
from odoo import api, fields, models
from . import translate_connector
from datetime import datetime


_logger = logging.getLogger(__name__)
Expand All @@ -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")
Expand Down
1 change: 1 addition & 0 deletions sbc_switzerland/views/advocate_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<field name="inherit_id" ref="partner_compassion.advocate_details_tree" />
<field name="arch" type="xml">
<field name="engagement_ids" position="after">
<field name="nb_translated_letters_this_year"/>
<field name="nb_translated_letters"/>
</field>
</field>
Expand Down
1 change: 0 additions & 1 deletion website_compassion/controllers/my_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]
Expand Down
6 changes: 6 additions & 0 deletions website_compassion/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ msgstr "Briefe<br/>"
msgid "<span>Make a donation</span>"
msgstr "Ein Geschenk machen<br/>"

#. 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 "<span>Open contributions</span>"
Expand Down
8 changes: 7 additions & 1 deletion website_compassion/i18n/fr_CH.po
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,13 @@ msgstr "<span>Lettres</span>"
#. module: website_compassion
#: model_terms:ir.ui.view,arch_db:website_compassion.my_children_gift_history
msgid "<span>Make a donation</span>"
msgstr "<span>Faire un don</span>"
msgstr "<span>Faire un cadeau</span>"

#. 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
Expand Down
6 changes: 6 additions & 0 deletions website_compassion/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ msgstr "<span>Lettere</span>"
msgid "<span>Make a donation</span>"
msgstr "Fai una donazione<br/>"

#. 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 "<span>Open contributions</span>"
Expand Down
2 changes: 1 addition & 1 deletion website_compassion/template/my_account_my_children.xml
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
<label><t t-esc="line.product_id.name"/></label>
</div>
<div class="col-4">
<label><t t-esc="line.get_date('create_date', 'date_full')"/></label>
<label><t t-esc="line.get_date('last_payment', 'date_full')"/></label>
</div>
<div class="col-4">
<label><t t-esc="int(line.price_total)"/> <t t-esc="line.invoice_id.currency_id.name"/></label>
Expand Down
2 changes: 1 addition & 1 deletion website_event_compassion/data/group_visit_emails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
<br/>
<br/>
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:
</p>
<ul>
<li>
Expand Down
2 changes: 1 addition & 1 deletion website_event_compassion/models/event_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
6 changes: 4 additions & 2 deletions website_event_compassion/templates/event_page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@
<t t-if="amount_inside">
<div t-attf-class="progress-amount #{ barometer_amount_class }">
<t t-esc="'{:n}'.format(barometer.amount_raised or 0).replace(',', '\'')"/>/<t
t-esc="'{:n}'.format(barometer.amount_objective or 0).replace(',', '\'')"/>CHF
t-esc="'{:n}'.format(barometer.amount_objective or 0).replace(',', '\'')"/>
<span t-field="barometer.user_id.company_id.currency_id.symbol" />
</div>
</t>
</div>
<t t-if="not amount_inside">
<div t-attf-class="#{ barometer_amount_class }">
<t t-esc="'{:n}'.format(barometer.amount_raised or 0).replace(',', '\'')"/>/<t
t-esc="'{:n}'.format(barometer.amount_objective or 0).replace(',', '\'')"/>CHF
t-esc="'{:n}'.format(barometer.amount_objective or 0).replace(',', '\'')"/>
<span t-field="barometer.user_id.company_id.currency_id.symbol" />
</div>
</t>
</template>
Expand Down

0 comments on commit a4c6a14

Please sign in to comment.