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
2 changes: 1 addition & 1 deletion sbc_compassion/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# pylint: disable=C8101
{
"name": "Sponsor to Participant communication",
"version": "18.0.1.0.7",
"version": "18.0.1.0.8",
"category": "Compassion",
"summary": "SBC - Supporter to Participant Communication",
"sequence": 150,
Expand Down
16 changes: 16 additions & 0 deletions sbc_compassion/data/child_layouts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,20 @@
eval="[(4, ref('b2s_additional_page_box_1'))]"
/>
</record>
<!-- GMC S10 stationery (e.g. XX-C-1S10-2): no translation area on page 2 -->
<record id="b2s_l1_s10" model="correspondence.template">
<field name="name">B2S - S10</field>
<field name="type">b2s</field>
<field name="layout">CH-A-1S11-1</field>
<field name="additional_page_id" ref="b2s_additional_page" />
</record>
<record id="b2s_l1_s10_p1" model="correspondence.template.page">
<field name="template_id" ref="b2s_l1_s10" />
<field name="page_index">1</field>
<field name="text_box_ids" eval="[(4, ref('b2s_l1_box_1'))]" />
</record>
<record id="b2s_l1_s10_p2" model="correspondence.template.page">
<field name="template_id" ref="b2s_l1_s10" />
<field name="page_index">2</field>
</record>
</odoo>
30 changes: 30 additions & 0 deletions sbc_compassion/migrations/18.0.1.0.8/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import logging

from openupgradelib import openupgrade

_logger = logging.getLogger(__name__)


@openupgrade.migrate()
def migrate(env, version):
# T3646: S10 letters printing their translation over page 2's printed text
l1 = env.ref("sbc_compassion.b2s_l1")
messages = env["gmc.message"].search([("content", "like", "-1S10-")])
messages = messages.filtered(lambda m: m.action_id.model == "correspondence")
letter_ids = [
int(letter_id)
for message in messages
for letter_id in (message.object_ids or str(message.object_id)).split(",")
if letter_id.strip().isdigit()
Comment on lines +12 to +18

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Migration changes unrelated letters. The search matches an entire message, then collects every ID in its object_ids. But process_commkit supports a Responses batch and returns all its letter IDs. If a batch contains both S10 and ordinary L1 letters, ordinary L1 letters with page-2 translations also get moved to the S10 layout. Their valid page-2 translation area is removed, and their text moves to an extra page when composed. Parse each response's Template and match only its own letter before changing template_id.

]
letters = env["correspondence"].search(
[("id", "in", letter_ids), ("template_id", "=", l1.id)]
)
letters = letters.filtered(
lambda letter: any(
len((paragraph.translated_text or "").strip()) >= 5
for paragraph in letter.page_ids[1:2].paragraph_ids
)
)
_logger.info("Move %s letters to the S10 layout", len(letters))
letters.write({"template_id": env.ref("sbc_compassion.b2s_l1_s10").id})
5 changes: 4 additions & 1 deletion sbc_compassion/models/correspondence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,10 @@ def json_to_data(self, json, mapping_name=None):
odoo_data = super().json_to_data(json, mapping_name)
odoo_data["is_compassion_moment"] = template_name == COMPASSION_MOMENT_TEMPLATE

if not template_name.startswith("CH"):
if "-1S10-" in template_name:
# Stationery without translation area on page 2
odoo_data["template_id"] = self.env.ref("sbc_compassion.b2s_l1_s10").id
elif not template_name.startswith("CH"):
template = self.env["correspondence.template"].search(
[("name", "like", "L" + template_name[5]), ("name", "like", "B2S")],
limit=1,
Expand Down
Loading