Skip to content

Commit

Permalink
CO-3962 Add fund product attachment for communications
Browse files Browse the repository at this point in the history
  • Loading branch information
ecino committed Apr 21, 2022
1 parent f5d86e7 commit 9f516fc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
19 changes: 10 additions & 9 deletions partner_communication_switzerland/models/partner_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ 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 All @@ -250,28 +249,29 @@ def get_all_gift_bvr(self):
gifts_to = sponsorships[0].gift_partner_id
if sponsorships and gifts_to == self.partner_id:
attachments = sponsorships.filtered(
lambda x: x.state not in ("terminated", "cancelled")).get_bvr_gift_attachment(all_gifts, background)
lambda x: x.state not in ("terminated", "cancelled")
).get_bvr_gift_attachment(all_gifts, background)
return attachments

def get_christmas_fund_bvr(self):
def get_fund_bvr(self):
"""
attach christmas fund slip with background for sending by e-mail
attach any fund slip with background for sending by e-mail
:return: dict {attachment_name: [report_name, pdf_data]}
"""
self.ensure_one()
background = self.send_mode and "physical" not in self.send_mode
product_id = self.env["product.product"].search([("default_code", "=", "noel")])
product = self.config_id.product_id
data = {
"product_id": product_id.id,
"product_ids": product_id.ids,
"product_id": product.id,
"product_ids": product.ids,
"background": background,
"doc_ids": self.partner_id.ids
}
report_name = "report_compassion.bvr_fund"
pdf = self._get_pdf_from_data(
data, self.env.ref("report_compassion.report_bvr_fund")
)
return {_("christmas fund.pdf"): [report_name, pdf]}
return {product.name + ".pdf": [report_name, pdf]}

def get_reminder_bvr(self):
"""
Expand Down Expand Up @@ -387,7 +387,8 @@ def get_child_picture_attachment(self):
else:
children = self.get_objects().mapped("child_id")
pdf = self._get_pdf_from_data(
{"doc_ids": children.ids}, self.env.ref("partner_communication_switzerland.report_child_picture")
{"doc_ids": children.ids}, self.env.ref(
"partner_communication_switzerland.report_child_picture")
)
name = children.get_list("local_id", 1, _("pictures")) + ".pdf"
res[name] = ("partner_communication_switzerland.child_picture", pdf)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,26 @@
#
##############################################################################
import random
import itertools

from odoo import api, models
from odoo import api, models, fields


class PartnerCommunication(models.Model):
_inherit = "partner.communication.config"

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

@api.onchange("product_id")
def onchange_product(self):
if self.product_id:
self.attachments_function = "get_fund_bvr"

@api.multi
def generate_test_cases_by_language_family_case(self, lang="de_DE", family_case="single", send_mode="digital"):
def generate_test_cases_by_language_family_case(self, lang="de_DE",
family_case="single",
send_mode="digital"):
"""
Generates example communications for our multiple cases in CH
depending on the language and the family case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
<xpath expr="//div[@name='button_box']/button[1]" position="before">
<button name="open_test_case_wizard" type="object" icon="fa-edit" string="Test cases"/>
</xpath>
<field name="attachments_function" position="before">
<field name="product_id"/>
</field>
</field>
</record>
</odoo>

0 comments on commit 9f516fc

Please sign in to comment.