Skip to content

Commit

Permalink
Merge pull request #1521 from CompassionCH/devel
Browse files Browse the repository at this point in the history
2022.08
  • Loading branch information
ecino authored May 9, 2022
2 parents 3c6e0ca + a38ac37 commit a70b5e5
Show file tree
Hide file tree
Showing 43 changed files with 275 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def unreconcile(self):
{
"date_invoice": invoice.date_invoice,
"comment": self.comment
or "New invoice after " "payment attribution changed.",
or "New invoice after payment attribution changed.",
"invoice_line_ids": False,
}
)
Expand Down
4 changes: 2 additions & 2 deletions child_sync_wp/tools/wp_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def parse_response(self, response):
if not data:
break
if self.verbose:
_logger.info("body:", repr(data))
_logger.info("body: " + repr(data))
p.feed(data)

if stream is not response:
Expand Down Expand Up @@ -116,7 +116,7 @@ def upload_children(self, children):
"Child Upload partially failed."
+ str(count_insert)
+ " of "
+ len(children)
+ str(len(children))
)
else:
_logger.error("Child Upload failed.")
Expand Down
1 change: 0 additions & 1 deletion crm_switzerland/views/crm_phonecall.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@

<record id="crm_phone.crm_phonecall_action_open" model="ir.actions.act_window">
<field name="context">{'search_default_my_calls': 1, 'search_default_open': 1, 'default_state': 'open'}</field>
<!--<field name="search_view_id" ref="crm.phonecall.search"/>-->
</record>
</odoo>
5 changes: 5 additions & 0 deletions mass_mailing_switzerland/data/queue_job.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
<field name="method">action_export_to_mailchimp</field>
<field name="channel_id" ref="channel_mailchimp"/>
</record>
<record id="export_job_partner" model="queue.job.function">
<field name="model_id" ref="model_res_partner"/>
<field name="method">action_export_partner_mailchimp</field>
<field name="channel_id" ref="channel_mailchimp"/>
</record>
<record id="update_job" model="queue.job.function">
<field name="model_id" ref="model_mail_mass_mailing_contact"/>
<field name="method">action_update_to_mailchimp</field>
Expand Down
9 changes: 7 additions & 2 deletions mass_mailing_switzerland/models/mass_mailing_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,14 @@ def create(self, vals_list):

@api.multi
def write(self, values):
"""Override the email write to avoid allowing to change email"""
"""Merge with other potential existing contacts"""
if "email" in values:
del values["email"]
# Regroup same email contacts
other = self.search([("email", "=", values["email"]), ("id", "not in", self.ids)], limit=1)
if other:
other.write({"partner_ids": [(4, pid) for pid in self.partner_ids.ids]})
self.with_delay(eta=5).unlink()
return True
return super().write(values)

@api.multi
Expand Down
20 changes: 20 additions & 0 deletions mass_mailing_switzerland/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ def _compute_wp_formdata(self):
filter_data = {key: val for key, val in data.items() if val}
partner.wordpress_form_data = urlencode(filter_data)

@api.multi
def _compute_mailchimp_subscription_list_ids(self):
# Take subscriptions from all associated contacts
for partner in self:
partner.subscription_list_ids = partner.mapped("mass_mailing_contact_ids.subscription_list_ids")

@api.model
def create(self, vals):
if vals.get("opt_out"):
Expand Down Expand Up @@ -113,6 +119,20 @@ def write(self, vals):
mailing_contacts.write(mailing_contact_vals)
return super().write(vals)

def update_contact_email(self, email):
""" Override from mailchimp to manage contact merge or unmerge. """
for partner in self.filtered(lambda x: x.subscription_list_ids):
mailing_contacts = partner.mass_mailing_contact_ids
other_partners = mailing_contacts.mapped("partner_ids") - partner
if other_partners:
# Dissociate this partner from others inside the mass_mailing.contact
mailchimp_lists = mailing_contacts.mapped("subscription_list_ids.mailchimp_list_id")
mailing_contacts.write({"partner_ids": [(3, partner.id)]})
mailing_contacts.with_delay(eta=6).action_update_to_mailchimp()
partner.with_delay(eta=5).action_export_partner_mailchimp(mailchimp_lists)
else:
super(ResPartner, partner).update_contact_email(email)

@api.multi
def update_selected_child_for_mailchimp(self, child):
# Allows to force selecting one child for displaying in email templates.
Expand Down
11 changes: 5 additions & 6 deletions muskathlon/forms/trip_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,11 @@ def _form_validate_passport_expiration_date(self, value, **req_values):
valid = not old
except (ValueError, TypeError):
valid = False
finally:
if not valid:
message = _("Please enter a valid date")
if old:
message = _("Your passport must be renewed!")
return "passport_expiration_date", message
if not valid:
message = _("Please enter a valid date")
if old:
message = _("Your passport must be renewed!")
return "passport_expiration_date", message
# No error
return 0, 0

Expand Down
2 changes: 1 addition & 1 deletion muskathlon/templates/muskathlon_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<t t-set="object" t-value="event"/>
<t t-set="publish_edit" t-value="True"/>
</t>
<t t-call="theme_compassion.layout">
<t t-call="website_compassion.layout">
<div id="muskathlon_details">
<t t-set="background_color_class" t-value="'muskathlon_background_red'"/>
<t t-call="website_event_compassion.event_header"/>
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 @@ -2,7 +2,7 @@
<odoo>
<data>
<template id="my_details" name="Muskathlon my donations">
<t t-call="theme_compassion.layout">
<t t-call="website_compassion.layout">
<div class="container">
<h2>Donations</h2>
<table class="table table-striped">
Expand Down
2 changes: 1 addition & 1 deletion muskathlon/templates/muskathlon_order_material.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="my_muskathlon_order_material" name="Muskathlon order material">
<t t-call="theme_compassion.layout">
<t t-call="website_compassion.layout">
<t t-set="event" t-value="registration.compassion_event_id"/>

<!-- Modal for image of flyer in fullscreen -->
Expand Down
2 changes: 1 addition & 1 deletion muskathlon/templates/muskathlon_participant_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<meta property="og:image" t-att-content="image_url"/>
<meta property="og:type" content="fitness.course"/>
</t>
<t t-call="theme_compassion.layout">
<t t-call="website_compassion.layout">
<!-- Facebook social share feature -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
Expand Down
4 changes: 2 additions & 2 deletions muskathlon/templates/muskathlon_registration_form.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="new_registration_successful" name="Muskathlon registration success">
<t t-call="theme_compassion.layout">
<t t-call="website_compassion.layout">
<t t-set="head">
<meta name="robots" content="noindex" />
</t>
Expand Down Expand Up @@ -37,7 +37,7 @@
</div>
</template>
<template id="registration_failure" name="Muskathlon registration failure">
<t t-call="theme_compassion.layout">
<t t-call="website_compassion.layout">
<t t-set="title">Muskathlon Registration</t>
<div id="wrap">
<div class="container text-center">
Expand Down
1 change: 0 additions & 1 deletion partner_communication_switzerland/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"depends": [
"report_compassion",
"child_switzerland",
"theme_compassion",
"sms_939", # compassion-switzerland
"auth_signup", # source/addons
"recurring_contract", # compassion-accounting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<field name="model_id" ref="model_recurring_contract"/>
<field name="trigger">on_time</field>
<field name="trg_date_id" ref="recurring_contract.field_recurring_contract__create_date"/>
<field name="filter_domain">[('parent_id.sds_state','=','sub'),('state','=','draft'),('correspondent_id.lang','in',('de_DE','fr_CH'))]</field>
<field name="filter_domain">[('parent_id.sds_state','=','sub'),('state','=','draft')]</field>
<field name="trg_date_range">6</field>
<field name="trg_date_range_type">day</field>
<field name="state">code</field>
Expand All @@ -50,6 +50,19 @@ records.send_communication(env.ref('partner_communication_switzerland.planned_su
records.send_communication(env.ref('partner_communication_switzerland.config_onboarding_photo_by_post'), both=True)
</field>
</record>
<record id="sub_proposal_validation" model="base.automation">
<field name="name">Sponsorship SUB Proposal validation</field>
<field name="model_id" ref="model_recurring_contract"/>
<field name="trigger">on_time</field>
<field name="trg_date_id" ref="field_recurring_contract__sub_proposal_date"/>
<field name="filter_domain">[('parent_id','!=',False),('state','=','draft')]</field>
<field name="trg_date_range">14</field>
<field name="trg_date_range_type">day</field>
<field name="state">code</field>
<field name="code">
records.contract_waiting()
</field>
</record>

<!-- Rules for zoom sessions -->
<record id="zoom_session_attended_rule" model="base.automation">
Expand Down
4 changes: 4 additions & 0 deletions partner_communication_switzerland/models/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class RecurringContract(models.Model):
onboarding_start_date = fields.Date(help="Indicates when the first email of "
"the onboarding process was sent.",
copy=False)
sub_proposal_date = fields.Date(help="Trigger for automatic SUB sponsorship validation after 2 weeks")

@api.onchange("origin_id")
def _do_not_send_letter_to_transfer(self):
Expand Down Expand Up @@ -567,6 +568,9 @@ def action_cancel_draft(self):
]).unlink()
return True

def cancel_sub_validation(self):
return self.write({"sub_proposal_date": False})

##########################################################################
# PRIVATE METHODS #
##########################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ def send(self):
- Add to zoom session when zoom invitation is sent
- Set onboarding_start_date when first communication is sent
- Start onboarding new donor after first thank you letter is sent
- Prepare SUB validation after SUB proposal is sent
:return: True
"""
sms_jobs = self.filtered(lambda j: j.send_mode == "sms")
Expand Down Expand Up @@ -638,6 +639,10 @@ def send(self):
welcome_comms.get_objects().write({
"onboarding_start_date": datetime.today()
})
sub_proposal = self.env.ref("partner_communication_switzerland.planned_sub_dossier")
subs = self.filtered(lambda j: j.config_id == sub_proposal)
if subs:
subs.get_objects().write({"sub_proposal_date": fields.Date.today()})

return True

Expand Down Expand Up @@ -762,7 +767,7 @@ def get_sponsorship_payment_slip_attachments(self):

# Include all active sponsorships for Permanent Order
bv_sponsorships |= (
bv_sponsorships.filtered(lambda s: s.payment_mode_id == permanent_order)
sponsorships.filtered(lambda s: s.payment_mode_id == permanent_order)
.mapped("group_id.contract_ids")
.filtered(lambda s: s.state in ("active", "waiting"))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class PartnerCommunication(models.Model):
_inherit = "partner.communication.config"

product_id = fields.Many2one(
"product.template", "Fund Bill attachment",
"product.product", "Fund Bill attachment",
domain=[("categ_id.name", "=", "Fund")])

@api.onchange("product_id")
Expand Down
76 changes: 41 additions & 35 deletions partner_communication_switzerland/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,41 +179,47 @@ def _compute_no_physical_letter(self):

def _inverse_no_physical_letter(self):
for partner in self:
if partner.no_physical_letter:
vals = {
"nbmag": "no_mag" if partner.nbmag == "no_mag" else "email",
"tax_certificate": "no"
if partner.tax_certificate == "no" else "only_email",
"calendar": False,
"christmas_card": False
}
for _field in ["global_communication_delivery_preference",
"letter_delivery_preference",
"photo_delivery_preference",
"thankyou_preference"]:
value = getattr(partner, _field)
if "auto" in value or value == "both":
vals[_field] = "auto_digital_only"
elif value in ["physical", "digital"]:
vals[_field] = "digital_only"
partner.write(vals)
else:
vals = {
"calendar": True,
"christmas_card": True
}
for _field in ["global_communication_delivery_preference",
"letter_delivery_preference",
"photo_delivery_preference",
"thankyou_preference"]:
value = getattr(partner, _field)
if "only" in value:
vals[_field] = value.replace("_only", "")
if partner.nbmag == "no_mag":
vals["nbmag"] = "one"
if partner.tax_certificate == "only_email":
vals["tax_certificate"] = "default"
partner.write(vals)
partner.compute_inverse_no_physical_letter()

def compute_inverse_no_physical_letter(self):
self.ensure_one()
no_physical_letters = self.env.context.get("no_physical_letters", self.no_physical_letter)
if no_physical_letters:
vals = {
"nbmag": "no_mag" if self.nbmag == "no_mag" else "email",
"tax_certificate": "no"
if self.tax_certificate == "no" else "only_email",
"calendar": False,
"christmas_card": False
}
for _field in ["global_communication_delivery_preference",
"letter_delivery_preference",
"photo_delivery_preference",
"thankyou_preference"]:
value = getattr(self, _field)
if "auto" in value or value == "both":
vals[_field] = "auto_digital_only"
elif value in ["physical", "digital"]:
vals[_field] = "digital_only"
self.write(vals)
else:
vals = {
"calendar": True,
"christmas_card": True
}
for _field in ["global_communication_delivery_preference",
"letter_delivery_preference",
"photo_delivery_preference",
"thankyou_preference"]:
value = getattr(self, _field)
if "only" in value:
vals[_field] = value.replace("_only", "")
if self.nbmag == "no_mag":
vals["nbmag"] = "one"
if self.tax_certificate == "only_email":
vals["tax_certificate"] = "default"
self.write(vals)


def _compute_last_completed_tax_receipt(self):
for partner in self:
Expand Down
13 changes: 7 additions & 6 deletions partner_communication_switzerland/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def _compute_signature(self):
"it_IT": "https://www.facebook.com/compassionsvizzera/",
"en_US": "https://www.facebook.com/compassionsuisse/"
}
lang = self.env.lang or self._context.lang or "en_US"
for user in self:
employee = user.employee_ids[:1].with_context(bin_size=False)
photo = employee.image_small
Expand All @@ -69,22 +70,22 @@ def _compute_signature(self):
f"{user.preferred_name} {user.lastname}" if user.firstname else _(
"The team of Compassion"),
"email": user.email if user.firstname else "[email protected]",
"lang": self.env.lang,
"lang_short": self.env.lang[:2],
"lang": lang,
"lang_short": lang[:2],
"team": _("and the team of Compassion") if user.firstname else "",
"job_title": employee.job_title or "",
"office_hours": _("mo-thu: 8am-4pm<br/>fri 8am-12am"),
"company_name": user.company_id.address_name,
"phone_link": phone_link.get(self.env.lang),
"phone": phone.get(self.env.lang),
"phone_link": phone_link.get(lang),
"phone": phone.get(lang),
"mobile": employee.mobile_phone,
"mobile_link": (employee.mobile_phone or "").replace(
" ", "").replace("(0)", ""),
"facebook": facebook.get(self.env.lang),
"facebook": facebook.get(lang),
"photo": photo.decode(
"utf-8") if isinstance(photo, bytes) else photo,
}
if self.env.lang in ("fr_CH", "en_US"):
if lang in ("fr_CH", "en_US"):
template.remove("#bern")
else:
template.remove("#yverdon")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="new_donors_onboarding_unsubscribe_template" name="New Donors Onboarding - Unsubscribe">
<t t-call="theme_compassion.layout">
<t t-call="website.layout">
<t t-set="title">Unsubscribe from further mailing ?</t>
<div class="container">
<div class="pt-4 mb-4">
Expand All @@ -18,7 +18,7 @@
</template>

<template id="confirmation_onboarding_unsubscribe_template" name="Onboarding - Unsubscribe Confirmation">
<t t-call="theme_compassion.layout">
<t t-call="website.layout">
<t t-set="title">Unsubscribe Confirmation</t>
<div class="container">
<div class="pt-4 mb-4">
Expand Down
Loading

0 comments on commit a70b5e5

Please sign in to comment.