Skip to content

Commit

Permalink
Bug fix in S2B letter composition
Browse files Browse the repository at this point in the history
  • Loading branch information
ecino committed Jan 27, 2020
1 parent 5b43fe4 commit b696b08
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sbc_compassion/models/correspondence.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,11 @@ def _get_translation_boxes(self):
"".join((p.english_text or "").split()))
else:
source = 'english_text'
# Avoid capturing translations that are the same text as the
# original text.
pages = pages.filtered(source).filtered(
lambda p: "".join((p.english_text or "").split()) !=
"".join((p.original_text or "").split()))
if not getattr(self, source):
return text_boxes

Expand All @@ -618,7 +623,7 @@ def _get_translation_boxes(self):
text_boxes.extend([
t.strip() for t in text.split(BOX_SEPARATOR)])

return text_boxes
return source, text_boxes

@api.model
def process_commkit(self, commkit_data):
Expand Down Expand Up @@ -745,7 +750,7 @@ def generate_original_pdf(self):
).encode('utf8')

image_data = self.mapped('original_attachment_ids.datas') or []
translation_boxes = self._get_translation_boxes()
source, translation_boxes = self._get_translation_boxes()
return self.template_id.generate_pdf(
pdf_name, (header, ''), {'Original': [self.original_text],
'Translation': translation_boxes},
Expand Down

0 comments on commit b696b08

Please sign in to comment.