-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1353 from CompassionCH/devel
2021-06-10 Release
- Loading branch information
Showing
42 changed files
with
699 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
mass_mailing_switzerland/migrations/12.0.2.1.0/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
|
||
def migrate(cr, version): | ||
if not version: | ||
return | ||
|
||
cr.execute(""" | ||
INSERT INTO mass_mailing_contact_partner_rel | ||
SELECT partner_id, id AS mass_mailing_contact_id | ||
FROM mail_mass_mailing_contact | ||
WHERE partner_id IS NOT NULL; | ||
""") | ||
|
||
# Attach other existing partners with same email | ||
cr.execute(""" | ||
INSERT INTO mass_mailing_contact_partner_rel | ||
SELECT p.id AS partner_id, m.id AS mass_mailing_contact_id | ||
FROM res_partner p JOIN mail_mass_mailing_contact m | ||
ON p.email = m.email AND p.id != m.partner_id | ||
WHERE p.contact_type = 'standalone' | ||
AND p.email IS NOT NULL | ||
""") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
############################################################################## | ||
# | ||
# Copyright (C) 2021 Compassion CH (http://www.compassion.ch) | ||
# Releasing children from poverty in Jesus' name | ||
# @author: Emanuel Cino <[email protected]> | ||
# | ||
# The licence is in the file __manifest__.py | ||
# | ||
############################################################################## | ||
from odoo import fields, models | ||
|
||
|
||
class MailchimpMergeFields(models.Model): | ||
_inherit = "mailchimp.merge.fields" | ||
|
||
# Allows to use fields from mail.mass_mailing.contact records in merge fields | ||
field_id = fields.Many2one(domain=[ | ||
('model_id.model', 'in', ['res.partner', 'mail.mass_mailing.contact']), | ||
('ttype', 'not in', ['one2many', 'many2one', 'many2many'])] | ||
) | ||
|
||
def get_value(self, mailing_contact): | ||
contact_fields = self.filtered( | ||
lambda f: f.field_id.model == "mail.mass_mailing.contact") | ||
partner_fields = self - contact_fields | ||
res = super(MailchimpMergeFields, partner_fields).get_value(mailing_contact) | ||
for custom_field in contact_fields: | ||
if custom_field.field_id and hasattr( | ||
self, custom_field.field_id.name): | ||
value = getattr(self, custom_field.field_id.name) | ||
else: | ||
value = '' | ||
res.update({custom_field.tag: value or ''}) | ||
return res |
Oops, something went wrong.