diff --git a/account_reconcile_compassion/__manifest__.py b/account_reconcile_compassion/__manifest__.py
index 9d1eea13d..a5543a4df 100644
--- a/account_reconcile_compassion/__manifest__.py
+++ b/account_reconcile_compassion/__manifest__.py
@@ -47,6 +47,7 @@
]},
"data": [
"data/statement_operation.xml",
+ "data/queue_job.xml",
"views/account_reconcile_compassion.xml",
"views/reconcile_fund_wizard_view.xml",
"views/reconcile_split_payment_wizard_view.xml",
diff --git a/account_reconcile_compassion/data/queue_job.xml b/account_reconcile_compassion/data/queue_job.xml
new file mode 100644
index 000000000..00f5478fe
--- /dev/null
+++ b/account_reconcile_compassion/data/queue_job.xml
@@ -0,0 +1,14 @@
+
+
+
+ reconcile_compassion
+
+
+
+
+
+
+ _process_reconciliation
+
+
+
\ No newline at end of file
diff --git a/account_reconcile_compassion/models/bank_statement_line.py b/account_reconcile_compassion/models/bank_statement_line.py
index fb5932a7d..b25ec4ba8 100644
--- a/account_reconcile_compassion/models/bank_statement_line.py
+++ b/account_reconcile_compassion/models/bank_statement_line.py
@@ -18,7 +18,6 @@
from odoo.exceptions import UserError
from odoo.tools import mod10r
from functools import reduce
-from odoo.addons.queue_job.job import job
logger = logging.getLogger(__name__)
@@ -61,7 +60,6 @@ def get_statement_line_for_reconciliation_widget(self):
##########################################################################
@api.multi
- @job(default_channel="root.bank_reconciliation")
def _process_reconciliation(
self, counterpart_aml_dicts=None, payment_aml_rec=None, new_aml_dicts=None
):
diff --git a/crowdfunding_compassion/controllers/homepage_controller.py b/crowdfunding_compassion/controllers/homepage_controller.py
index 6c561e3b8..dff209990 100644
--- a/crowdfunding_compassion/controllers/homepage_controller.py
+++ b/crowdfunding_compassion/controllers/homepage_controller.py
@@ -49,26 +49,33 @@ def _compute_homepage_context():
year = datetime.now().year
project_obj = request.env["crowdfunding.project"].sudo()
current_year_projects = project_obj.get_active_projects(year=year)
- active_funds = current_year_projects.mapped("product_id")
+ funds_used = current_year_projects.mapped("product_id")
+ active_funds = funds_used.search([("activate_for_crowdfunding", "=", True)])
+ active_funds_data = []
impact = {
"sponsorship": sponsorship_card_content()
}
- for fund in active_funds:
+ for fund in funds_used:
impact[fund.name] = {
"type": "fund",
"value": 0,
- "name": fund.crowdfunding_impact_text_active,
+ # "name": fund.crowdfunding_impact_text_active,
"text": fund.crowdfunding_impact_text_passive_singular,
"description": fund.crowdfunding_description,
"icon_image": fund.image_medium or SPONSOR_ICON,
+ }
+ for fund in active_funds:
+ active_funds_data.append({
+ "name": fund.crowdfunding_impact_text_active,
+ "description": fund.crowdfunding_description,
+ "icon_image": fund.image_medium or SPONSOR_ICON,
# the header is a small image so we can compress it to save space
"header_image":
compress_big_images(
fund.image_large,
max_width=400
) if fund.image_large else SPONSOR_HEADER,
-
- }
+ })
for project in current_year_projects:
impact["sponsorship"]["value"] += project.number_sponsorships_reached
@@ -76,8 +83,13 @@ def _compute_homepage_context():
if project_fund in impact:
impact[project_fund]["value"] += project.product_number_reached
- for fund in active_funds:
- if impact[fund.name]["value"] > 1:
+ for fund in funds_used:
+ impact_val = impact[fund.name]["value"]
+ large_impact = fund.impact_type == "large"
+ if large_impact and impact_val > 100:
+ impact[fund.name]["text"] = fund.crowdfunding_impact_text_passive_plural
+ impact[fund.name]["value"] = int(impact_val / 100)
+ elif not large_impact and impact_val > 1:
impact[fund.name]["text"] = fund.crowdfunding_impact_text_passive_plural
if impact["sponsorship"]["value"] > 1:
@@ -88,6 +100,7 @@ def _compute_homepage_context():
return {
"projects": current_year_projects[:8],
"impact": {k: v for k, v in impact.items() if v['value']},
+ "active_funds": active_funds_data,
"base_url": request.website.domain,
"subheading": subheading,
}
diff --git a/crowdfunding_compassion/controllers/project_controller.py b/crowdfunding_compassion/controllers/project_controller.py
index f253e4754..39b59b20b 100644
--- a/crowdfunding_compassion/controllers/project_controller.py
+++ b/crowdfunding_compassion/controllers/project_controller.py
@@ -114,25 +114,27 @@ def get_sponsorships_and_donations(self, sponsorship_ids, invoice_line_ids):
for sponsorship in sponsorship_ids
]
- donations = [
- {
+ donations = []
+ for donation in invoice_line_ids.filtered(lambda l: l.state == "paid"):
+ product = donation.product_id
+ quantity = donation.quantity
+ impact_text = product.crowdfunding_impact_text_passive_singular
+ if product.impact_type == "standard" and int(quantity) > 1:
+ impact_text = product.crowdfunding_impact_text_passive_plural
+ elif product.impact_type == "large" and quantity >= 100:
+ impact_text = product.crowdfunding_impact_text_passive_plural
+ quantity = int(quantity / 100)
+ donations.append({
"type": "donation",
"color": "grey",
- "text": f"{int(donation.quantity)} "
- f"{donation.product_id.crowdfunding_impact_text_passive_plural}"
- if int(donation.quantity) > 1 else
- f"{int(donation.quantity)} "
- f"{donation.product_id.crowdfunding_impact_text_passive_singular}",
- "image": donation.product_id.image_medium,
+ "text": f"{int(quantity)} {impact_text}",
+ "image": donation.product_id.image_small,
"benefactor": donation.invoice_id.partner_id.firstname,
"date": donation.invoice_id.create_date,
"time_ago": self.get_time_ago(donation.invoice_id.create_date),
"anonymous": donation.is_anonymous,
- "quantity": int(donation.quantity)
- }
- for donation in invoice_line_ids.filtered(
- lambda l: l.state == "paid")
- ]
+ "quantity": int(quantity)
+ })
return sponsorships, donations
def get_impact(self, sponsorships, donations):
diff --git a/crowdfunding_compassion/forms/project_creation_form.py b/crowdfunding_compassion/forms/project_creation_form.py
index b3213ff3e..f0e7526b2 100644
--- a/crowdfunding_compassion/forms/project_creation_form.py
+++ b/crowdfunding_compassion/forms/project_creation_form.py
@@ -250,6 +250,10 @@ def form_before_create_or_update(self, values, extra_values):
if not product_goal:
values["product_id"] = False
+ if product_goal and values["product_id"]:
+ product = self.env["product.product"].sudo().browse(values["product_id"])
+ if product.impact_type == "large":
+ extra_values["participant_product_number_goal"] = product_goal * 100
super().form_before_create_or_update(values, extra_values)
def _form_create(self, values):
diff --git a/crowdfunding_compassion/models/crowdfunding_project.py b/crowdfunding_compassion/models/crowdfunding_project.py
index 106e20854..c231d24e1 100644
--- a/crowdfunding_compassion/models/crowdfunding_project.py
+++ b/crowdfunding_compassion/models/crowdfunding_project.py
@@ -75,7 +75,7 @@ class CrowdfundingProject(models.Model):
number_sponsorships_reached = fields.Integer(
"Sponsorships reached", compute="_compute_number_sponsorships_reached")
product_crowdfunding_impact = fields.Char(
- related="product_id.crowdfunding_impact_text_passive_plural")
+ compute="_compute_impact_text")
color_sponsorship = fields.Char(compute="_compute_color_sponsorship")
color_product = fields.Char(compute="_compute_color_product")
color = fields.Integer(
@@ -193,6 +193,14 @@ def _compute_number_participants(self):
for project in self:
project.number_participants = len(project.participant_ids)
+ def _compute_impact_text(self):
+ for project in self:
+ product = project.product_id
+ project.product_crowdfunding_impact = \
+ product.crowdfunding_impact_text_passive_singular \
+ if product.impact_type == "large"\
+ else product.crowdfunding_impact_text_passive_plural
+
@api.model
def create(self, vals):
res = super().create(vals)
diff --git a/crowdfunding_compassion/models/product_template.py b/crowdfunding_compassion/models/product_template.py
index 4cf0c0765..d3eae01ff 100644
--- a/crowdfunding_compassion/models/product_template.py
+++ b/crowdfunding_compassion/models/product_template.py
@@ -8,23 +8,44 @@ class ProductTemplate(models.Model):
_inherit = "product.template"
activate_for_crowdfunding = fields.Boolean()
- crowdfunding_description = fields.Text(translate=True)
- crowdfunding_quantity_singular = fields.Char(translate=True, help="Ex: toilet")
- crowdfunding_quantity_plural = fields.Char(translate=True, help="Ex: toilets")
+ impact_type = fields.Selection([
+ ("standard", "Standard"),
+ ("large", "Large impact project")
+ ],
+ help="Use large impact if the project goals should be displayed in terms "
+ "of percentage.",
+ default="standard"
+ )
+ crowdfunding_description = fields.Text(
+ translate=True,
+ help="Description of the fund visible on Homepage"
+ )
+ crowdfunding_quantity_singular = fields.Char(
+ translate=True,
+ help="Visible when choosing donation quantity 1 or when "
+ "displaying project goal equivalence for 1 quantity.")
+ crowdfunding_quantity_plural = fields.Char(
+ translate=True,
+ help="Visible when choosing donation quantity or setting project goal "
+ "for large impact projects.")
crowdfunding_impact_text_active = fields.Char(
- translate=True, help="Ex: buildling toilets"
+ translate=True, help="Fund title on TOGETHER"
)
crowdfunding_impact_text_passive_singular = fields.Char(
- translate=True, help="Ex: toilet built"
+ translate=True,
+ help="Shown on barometers when impact is 1 or less."
)
crowdfunding_impact_text_passive_plural = fields.Char(
- translate=True, help="Ex: toilets built"
+ translate=True,
+ help="Shown on barometers when impact is more than 1."
)
fund_selector_pre_description = fields.Char(
- translate=True, help="Ex: I want to give access to toilets for"
+ translate=True,
+ help="Shown when setting the goal of a project, before the quantity field."
)
fund_selector_post_description = fields.Char(
- translate=True, help="Ex: children"
+ translate=True,
+ help="Shown when setting the goal of a project, after the quantity field."
)
image_large = fields.Binary(
"Large image", help="Image for header", attachment=True
diff --git a/crowdfunding_compassion/templates/crowdfunding_components.xml b/crowdfunding_compassion/templates/crowdfunding_components.xml
index fb66c43d8..4105dbce0 100644
--- a/crowdfunding_compassion/templates/crowdfunding_components.xml
+++ b/crowdfunding_compassion/templates/crowdfunding_components.xml
@@ -7,15 +7,21 @@
+
+
+
+
-
- out of
-
-
+
+
+ out of
+
+
+
@@ -50,12 +56,14 @@
+
sponsorship
-
+
+
@@ -120,10 +128,12 @@
+ sponsorship
-
+
+
@@ -315,19 +325,19 @@
-
-
+
+
+
-
- NAS Settings
-
-
-
-
-
-
-
diff --git a/partner_compassion/wizards/staff_notification_settings.py b/partner_compassion/wizards/staff_notification_settings.py
index 7958854ce..ecd1c0567 100644
--- a/partner_compassion/wizards/staff_notification_settings.py
+++ b/partner_compassion/wizards/staff_notification_settings.py
@@ -41,8 +41,6 @@ class StaffNotificationSettings(models.TransientModel):
domain=[("user_ids", "!=", False), ("user_ids.share", "=", False), ],
readonly=False,
)
- share_on_nas = fields.Text()
- store_path = fields.Text()
potential_advocate_fr = fields.Many2one(
"res.users", "Potential advocate FR", domain=[("share", "=", False)]
)
@@ -88,12 +86,6 @@ def set_values(self):
else 1
),
)
- self.env["ir.config_parameter"].sudo().set_param(
- "partner_compassion.share_on_nas", self.share_on_nas
- )
- self.env["ir.config_parameter"].sudo().set_param(
- "partner_compassion.store_path", self.store_path
- )
self.env["ir.config_parameter"].set_param(
"partner_communication_switzerland.potential_advocate_fr",
str(self.potential_advocate_fr.id or 0))
@@ -138,12 +130,6 @@ def get_values(self):
or 0
)
or False,
- "share_on_nas": str(
- param_obj.get_param("partner_compassion.share_on_nas", "")
- ),
- "store_path": str(
- param_obj.get_param("partner_compassion.store_path", "")
- ),
}
)
user_fr = self.env["ir.config_parameter"].get_param(
diff --git a/report_compassion/models/partner_communication.py b/report_compassion/models/partner_communication.py
index 190fb6ecb..607d7a61b 100644
--- a/report_compassion/models/partner_communication.py
+++ b/report_compassion/models/partner_communication.py
@@ -1,13 +1,12 @@
##############################################################################
#
-# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
+# Copyright (C) 2016-2022 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino
#
# The licence is in the file __manifest__.py
#
##############################################################################
-import base64
from odoo import api, models, fields
@@ -15,12 +14,8 @@ class PartnerCommunication(models.Model):
""" Add fields for retrieving values for communications.
Send a communication when a major revision is received.
"""
-
_inherit = "partner.communication.job"
- ##########################################################################
- # FIELDS #
- ##########################################################################
product_id = fields.Many2one("product.product", "QR Bill for fund", readonly=False)
display_pp = fields.Boolean(
string="Display PP",
@@ -28,71 +23,6 @@ class PartnerCommunication(models.Model):
default=True,
)
- ##########################################################################
- # PUBLIC METHODS #
- ##########################################################################
- @api.multi
- def send(self):
- """
- Change the report for communications to print with BVR
- Update the count of succes story prints when sending a receipt.
- :return: True
- """
- bvr_to_send = self.filtered(lambda j: j.send_mode == "digital" and j.product_id)
- bvr_to_print = self.filtered(
- lambda j: j.send_mode == "physical" and j.product_id
- )
- bvr_both = self.filtered(lambda j: j.send_mode == "both" and j.product_id)
-
- if bvr_both and self.env.context.get("origin") == "both_email":
- for bvr in bvr_both:
- # email part
- self._put_bvr_in_attachments(bvr)
-
- super(PartnerCommunication, bvr_both).send()
-
- if bvr_to_send:
- for bvr in bvr_to_send:
- self._put_bvr_in_attachments(bvr)
- super(PartnerCommunication, bvr_to_send).send()
-
- if bvr_to_print:
- super(PartnerCommunication, bvr_to_print).send()
-
- return super(
- PartnerCommunication, self - bvr_both - bvr_to_print - bvr_to_send
- ).send()
-
- def _put_bvr_in_attachments(self, bvr):
- pdf_download = self._generate_pdf_data(bvr)
- return self._create_and_add_attachment(bvr, pdf_download)
-
- def _create_and_add_attachment(self, bvr, datas):
- attachment = self.env["ir.attachment"].create(
- {"name": bvr.report_id.name, "type": "binary", "datas": datas}
- )
- comm_attachment = self.env["partner.communication.attachment"].create(
- {
- "name": bvr.report_id.name,
- "report_name": "report_compassion.partner_communication",
- "communication_id": bvr.id,
- "attachment_id": attachment.id,
- }
- )
- bvr.write({"attachment_ids": [(4, comm_attachment.id)]})
- return bvr
-
- def _generate_pdf_data(self, bvr):
- data = {
- "doc_ids": bvr.id,
- "product_id": bvr.product_id.id,
- }
- report_ref = self.env.ref("report_compassion.report_compassion_qr_slip")
- pdf_data = report_ref.with_context(
- must_skip_send_to_printer=True
- ).render_qweb_pdf(bvr.id, data=data)[0]
- return base64.encodebytes(pdf_data)
-
@api.model
def _get_default_vals(self, vals, default_vals=None):
if default_vals is None:
diff --git a/report_compassion/report/bvr_fund.xml b/report_compassion/report/bvr_fund.xml
index 6ec0aad2f..0820a5951 100644
--- a/report_compassion/report/bvr_fund.xml
+++ b/report_compassion/report/bvr_fund.xml
@@ -7,7 +7,7 @@
menu="False"
/>
-
+
@@ -17,6 +17,7 @@
display: none;
+
diff --git a/report_compassion/report/bvr_sponsorship.xml b/report_compassion/report/bvr_sponsorship.xml
index 7f74267c8..3a6a08dae 100644
--- a/report_compassion/report/bvr_sponsorship.xml
+++ b/report_compassion/report/bvr_sponsorship.xml
@@ -40,7 +40,7 @@
name="report_compassion.bvr_due"
/>
-
+