Skip to content

Commit 2fdbab3

Browse files
committed
[FIX] *: f-strings inside _() calls
On Jammy, babel does *not* cope well with f-strings as values inside `_()` calls: it uses `eval` to try and figure them out, which attempts to execute the f-string, which fails because the evaluation context is empty. This is likely fixed from Babel 2.11 onwards (python-babel/babel#915) but Jammy uses babel 2.8[^1]. https://runbot.odoo.com/odoo/runbot.build.error/97849 [^1]: This doesn't seem to trigger on Noble even though it uses 2.10, but locally it does trigger on 2.10.3 (installed via pip), so ubuntu might have backported the fix or something. X-original-commit: 51c169a
1 parent b411d73 commit 2fdbab3

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

addons/mail/models/discuss/discuss_channel.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,15 +1406,13 @@ def execute_command_help(self, **kwargs):
14061406
)
14071407
else:
14081408
if members := self.channel_member_ids.filtered(lambda m: not m.is_self):
1409+
member_names = html_escape(format_list(self.env, [f"%(member_{member.id})s" for member in members])) % {
1410+
f"member_{member.id}": member._get_html_link(for_persona=True)
1411+
for member in members
1412+
}
14091413
msg = _(
14101414
"You are in a private conversation with %(member_names)s.",
1411-
member_names=html_escape(
1412-
format_list(self.env, [f"%(member_{member.id})s" for member in members])
1413-
)
1414-
% {
1415-
f"member_{member.id}": member._get_html_link(for_persona=True)
1416-
for member in members
1417-
},
1415+
member_names=member_names,
14181416
)
14191417
else:
14201418
msg = _("You are alone in a private conversation.")
@@ -1449,13 +1447,13 @@ def execute_command_who(self, **kwargs):
14491447
list_params.append(_("more"))
14501448
else:
14511449
list_params.append(_("you"))
1450+
member_names = html_escape(format_list(self.env, list_params)) % {
1451+
f"member_{member.id}": member._get_html_link(for_persona=True)
1452+
for member in members
1453+
}
14521454
msg = _(
14531455
"Users in this channel: %(members)s.",
1454-
members=html_escape(format_list(self.env, list_params))
1455-
% {
1456-
f"member_{member.id}": member._get_html_link(for_persona=True)
1457-
for member in members
1458-
},
1456+
members=member_names,
14591457
)
14601458
else:
14611459
msg = _("You are alone in this channel.")

odoo/orm/fields_relational.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def _description_domain(self, env: Environment) -> str | list:
130130
_logger.warning(env._(
131131
"Couldn't generate a company-dependent domain for field %s. "
132132
"The model doesn't have a 'company_id' or 'company_ids' field, and isn't company-dependent either.",
133-
f'{self.model_name}.{self.name}'
133+
self.model_name + '.' + self.name,
134134
))
135135
return domain
136136
company_domain = env[self.comodel_name]._check_company_domain(companies=unquote(cids))

0 commit comments

Comments
 (0)