Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions child_compassion/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
major_revision,
project_compassion,
project_lifecycle_event,
report_childpack,
weekly_demand,
)
2 changes: 1 addition & 1 deletion child_compassion/models/child_compassion.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ def _compute_qr_code(self):
UTMs can be overridden through the context keys ``qr_utm_medium``,
``qr_utm_source`` and ``qr_utm_campaign``.
"""
base_url = self.get_base_url().rstrip("/")
utm_params = {
"utm_medium": self.env.context.get("qr_utm_medium") or "childpack_qr",
"utm_source": self.env.context.get("qr_utm_source") or "hold_campaign",
Expand All @@ -307,6 +306,7 @@ def _compute_qr_code(self):
utm_params["utm_campaign"] = utm_campaign
query = urlencode(utm_params)
for child in self:
base_url = child.get_base_url().rstrip("/")
url = f"{base_url}/my2/new-sponsorship/{child.id}?{query}"
qr = pyqrcode.create(url)
child.qr_code_data = qr.png_as_base64_str(15, (0, 84, 166))
Expand Down
48 changes: 48 additions & 0 deletions child_compassion/models/report_childpack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
##############################################################################
#
# Copyright (C) 2016-2026 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
#
# The licence is in the file __manifest__.py
#
##############################################################################
from odoo import api, models


class ReportChildpackFull(models.AbstractModel):
"""
Rendering context of the childpack reports.

The print wizard passes its options (lang, type, print_qr, ...) through the
``data`` dictionary. When that dictionary is set, the web client builds the
report URL without the record ids (see ``getReportUrl`` in web), so the
report is rendered with no ``docids`` at all and would print a blank page.
We therefore fall back on the ids the wizard stored in ``data['doc_ids']``.
"""

_name = "report.child_compassion.childpack_full"
_description = "Childpack report rendering context"

@api.model
def _get_report_values(self, docids, data=None):
data = dict(data or {})
docids = docids or data.get("doc_ids") or self.env.context.get("active_ids", [])
lang = data.get("lang")
docs = self.env["compassion.child"].browse(docids)
if lang:
docs = docs.with_context(lang=lang)
data.update(
{
"doc_ids": docs.ids,
"doc_model": "compassion.child",
"docs": docs,
}
)
return data


# pylint: disable=R7980
class ReportChildpackSmall(models.AbstractModel):
_inherit = "report.child_compassion.childpack_full"
_name = "report.child_compassion.childpack_small"
_description = "Small childpack report rendering context"
Loading