Skip to content

Commit

Permalink
Merge branch '14.0' into T1794-Remove-unwanted-template-from-SDS
Browse files Browse the repository at this point in the history
  • Loading branch information
jordyBSK authored Sep 4, 2024
2 parents 1619d3d + f21e779 commit 9dd3d00
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 37 deletions.
16 changes: 16 additions & 0 deletions interaction_resume/models/crm_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ class CrmRequest(models.Model):
def _get_interaction_data(self, partner_id):
res = []
for claim in self:
if claim.description:
res.append(
{
"partner_id": partner_id,
"res_model": self._name,
"res_id": claim.id,
"direction": "in",
"date": claim.create_date,
"email": claim.email_from or claim.partner_id.email,
"communication_type": "Support",
"subject": claim.name,
"body": html2plaintext(claim.description).replace("\n\n", "\n"),
"has_attachment": bool(claim.message_attachment_count),
"tracking_status": "delivered",
}
)
messages = claim.message_ids.filtered(
lambda m: m.message_type in ("email", "comment")
and (m.author_id.id == partner_id or partner_id in m.partner_ids.ids)
Expand Down
2 changes: 1 addition & 1 deletion interaction_resume/models/other_interaction.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import models, fields
from odoo import fields, models
from odoo.tools import html2plaintext


Expand Down
5 changes: 3 additions & 2 deletions partner_auto_match/models/res_partner_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def match_values_to_partner(self, vals, match_update=False, match_create=True):
continue

# Postprocess partner (either update or create it depending on context options)
if len(partner) == 1 and match_update:
if partner and len(partner) == 1 and match_update:
self.update_partner(partner, vals)
if not partner and match_create:
partner = self._create_partner(vals)
Expand Down Expand Up @@ -107,7 +107,8 @@ def update_partner(self, partner, vals, async_mode=True, delay=1):
@api.model
def _preprocess_vals(self, vals):
"""Transform, if needed and before matching, the infos received"""
pass
if "name" in vals:
vals["name"] = vals["name"].strip(" -")

@api.model
def _process_update_vals(self, partner, vals):
Expand Down
13 changes: 9 additions & 4 deletions partner_communication/wizards/mail_compose_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ def _get_mail_values(self, template, res_ids):
}
)
)

# Fetch template values.
wizard.write(
wizard.onchange_template_id(template.id, "mass_mail", False, False)["value"]
)
return wizard.get_mail_values(res_ids)
write_data = wizard.onchange_template_id(
template.id, "mass_mail", False, False
)["value"]
values = wizard.get_mail_values(res_ids)

wizard.write(write_data)

return values
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class CommunicationRevision(models.Model):
body_html = fields.Html(
compute="_compute_body_html", inverse="_inverse_body_html", sanitize=False
)
raw_template_edit_mode = fields.Boolean()
simplified_text = fields.Html(sanitize=False)
user_id = fields.Many2one(
"res.users",
Expand Down Expand Up @@ -573,7 +572,6 @@ def onchange_compare_lang(self):

def reload_text(self):
self.keyword_ids.unlink()
self.raw_template_edit_mode = False
if self.body_html:
self.with_context(no_update=True).simplified_text = self._simplify_text()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,12 @@
<group>
<group>
<field
name="raw_template_edit_mode"
invisible="1"
/>
<field
name="proposition_text"
groups="base.group_erp_manager"
/>
</group>
<group>
<field
name="body_html"
widget="ace"
attrs="{'readonly': [('raw_template_edit_mode','!=',True)]}"
/>
<field name="body_html" widget="ace" />
</group>
</group>
</sheet>
Expand Down
4 changes: 3 additions & 1 deletion sbc_compassion/migrations/14.0.1.0.2/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
@openupgrade.migrate()
def migrate(env, version):
if version:
letters = env["correspondence"].search([("read_url", "=", False), ("uuid", "!=", False)])
letters = env["correspondence"].search(
[("read_url", "=", False), ("uuid", "!=", False)]
)
letters.with_delay()._compute_read_url()
3 changes: 0 additions & 3 deletions sbc_compassion/models/correspondence.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,6 @@ def enrich_letter(self, vals):

def process_letter(self):
"""Method called when new B2S letter is Published."""
base_url = (
self.env["ir.config_parameter"].sudo().get_param("web.external.url", "")
)
self.download_attach_letter_image(letter_type="final_letter_url")
return True

Expand Down
29 changes: 29 additions & 0 deletions sbc_translation/data/mail_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,35 @@
</field>
</record>

<template id="translation_issue_log">
<p>
<b>Issue type</b>:
<span t-field="record.translation_issue" />
</p>
<span t-field="record.translation_issue_comments" />
</template>

<template id="translation_comments_update">
<p>
Comments updated
</p>
<ul>
<li t-foreach="comments" t-as="comment">
Page
<t t-esc="comment['page_index']"/>
paragraph
<t t-esc="comment['paragraph_index']"/>:
<t t-esc="comment['old']" />
<span
class="o_Message_trackingValueSeparator o_Message_trackingValueItem fa fa-long-arrow-right"
title="Changed"
role="img"
/>
<t t-esc="comment['new']" />
</li>
</ul>
</template>

<template id="comments_reply">
<p t-raw="reply" />
<hr />
Expand Down
63 changes: 49 additions & 14 deletions sbc_translation/models/correspondence.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ def get_translation_issue_list(self):
@api.onchange("new_translator_id")
def onchange_new_translator_id(self):
"""
When a translator is set, the letter should always be on "in progress" status to ensure that the letter can
be found under the translator's saved letters in the Translation Platform.
When a translator is set, the letter should always be on "in progress" status to ensure that the letter can
be found under the translator's saved letters in the Translation Platform.
"""
if self.new_translator_id:
self.translation_status = "in progress"
Expand Down Expand Up @@ -233,7 +233,8 @@ def calculate_translation_priority(self):

# Dynamically get the list of priority keys from the selection field definition
priorities = [
int(priority[0]) for priority in self._fields["translation_priority"].selection
int(priority[0])
for priority in self._fields["translation_priority"].selection
]

# Handle the case where scanned_date is not set
Expand All @@ -242,10 +243,15 @@ def calculate_translation_priority(self):
)

# Calculate the difference in weeks between the current date and the scanned date.
calculated_priority = min((fields.Date.today() - letter_date).days // 7, len(priorities) - 1)
calculated_priority = min(
(fields.Date.today() - letter_date).days // 7, len(priorities) - 1
)

# If the user had manually set a higher priority, we stick to it
if self.translation_priority and int(self.translation_priority) >= calculated_priority:
if (
self.translation_priority
and int(self.translation_priority) >= calculated_priority
):
return self.translation_priority

return str(calculated_priority)
Expand Down Expand Up @@ -308,12 +314,18 @@ def raise_translation_issue(self, issue_type, body_html):
TP API for translator to raise an issue with the letter
"""
self.ensure_one()

self.write(
{"translation_issue": issue_type, "translation_issue_comments": body_html}
)
self.assign_supervisor()
# template = self.env.ref("sbc_translation.translation_issue_notification").sudo()
# self.sudo().message_post_with_template(template.id, author_id=self.env.user.partner_id.id)

html = self.env["ir.qweb"]._render(
"sbc_translation.translation_issue_log", {"record": self}
)

self._message_log(body=html)

return True

def reply_to_comments(self, body_html):
Expand Down Expand Up @@ -344,10 +356,9 @@ def reply_to_issue(self, body_html):
"reply": body_html,
},
)
return self.write({
'translation_issue': False,
'translation_issue_comments': False
})
return self.write(
{"translation_issue": False, "translation_issue_comments": False}
)

def mark_comments_read(self):
return self.write({"unread_comments": False})
Expand Down Expand Up @@ -377,6 +388,7 @@ def save_translation(self, letter_elements, translator_id=None):
page_index = 0
paragraph_index = 0
current_page = self.page_ids[page_index]
comments_updates = []
if not translator_id:
# Don't overwrite current translator if any.
if self.new_translator_id:
Expand All @@ -389,6 +401,7 @@ def save_translation(self, letter_elements, translator_id=None):
"new_translator_id": translator_id,
"translation_status": "in progress",
}

for element in letter_elements:
if element.get("type") == "pageBreak":
page_index += 1
Expand All @@ -404,10 +417,33 @@ def save_translation(self, letter_elements, translator_id=None):
if self.translation_language_id.code_iso == "eng":
# Copy translation text into english text field
paragraph_vals["english_text"] = element.get("content")

if (
current_page.paragraph_ids[paragraph_index].comments
!= paragraph_vals["comments"]
):
comments_updates.append(
{
"page_index": page_index + 1,
"paragraph_index": paragraph_index + 1,
"old": current_page.paragraph_ids[paragraph_index].comments,
"new": paragraph_vals["comments"],
}
)

current_page.paragraph_ids[paragraph_index].write(paragraph_vals)
paragraph_index += 1
if element.get("comments"):
letter_vals["unread_comments"] = True

if len(comments_updates) > 0:
html = self.env["ir.qweb"]._render(
"sbc_translation.translation_comments_update",
{"comments": comments_updates},
)

self._message_log(body=html)

self.write(letter_vals)
return True

Expand Down Expand Up @@ -540,8 +576,8 @@ def get_translated_elements(self):
"content": paragraph.translated_text,
"comments": paragraph.comments,
"source": paragraph.english_text
or paragraph.original_text
or "",
or paragraph.original_text
or "",
}
)
if i < len(self.page_ids) - 1:
Expand All @@ -566,7 +602,6 @@ def update_translation_priority_cron(self):

# Update priority for each letters
for letter in letters_to_translate:

current_priority = letter.translation_priority
new_priority = letter.calculate_translation_priority()

Expand Down
1 change: 0 additions & 1 deletion sponsorship_compassion/models/contract_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,3 @@ def _should_skip_invoice_generation(self, invoicing_date, contract=None):
and self.invoice_suspended_until > invoicing_date
)
return bool(existing_invoices) or is_suspended

0 comments on commit 9dd3d00

Please sign in to comment.