diff --git a/partner_communication_switzerland/models/partner_communication.py b/partner_communication_switzerland/models/partner_communication.py
index 6b9f71835..15a10e0b7 100644
--- a/partner_communication_switzerland/models/partner_communication.py
+++ b/partner_communication_switzerland/models/partner_communication.py
@@ -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
@@ -250,20 +249,21 @@ 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
}
@@ -271,7 +271,7 @@ def get_christmas_fund_bvr(self):
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):
"""
@@ -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)
diff --git a/partner_communication_switzerland/models/partner_communication_config.py b/partner_communication_switzerland/models/partner_communication_config.py
index 8910d6138..b77197862 100644
--- a/partner_communication_switzerland/models/partner_communication_config.py
+++ b/partner_communication_switzerland/models/partner_communication_config.py
@@ -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
diff --git a/partner_communication_switzerland/views/communication_test_case_view.xml b/partner_communication_switzerland/views/communication_test_case_view.xml
index 8826a4ab2..43aefc711 100644
--- a/partner_communication_switzerland/views/communication_test_case_view.xml
+++ b/partner_communication_switzerland/views/communication_test_case_view.xml
@@ -75,6 +75,9 @@
+
+
+