Skip to content

Commit ae015d9

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 2afbe61 commit ae015d9

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
@@ -1419,15 +1419,13 @@ def execute_command_help(self, **kwargs):
14191419
)
14201420
else:
14211421
if members := self.channel_member_ids.filtered(lambda m: not m.is_self):
1422+
member_names = html_escape(format_list(self.env, [f"%(member_{member.id})s" for member in members])) % {
1423+
f"member_{member.id}": member._get_html_link(for_persona=True)
1424+
for member in members
1425+
}
14221426
msg = _(
14231427
"You are in a private conversation with %(member_names)s.",
1424-
member_names=html_escape(
1425-
format_list(self.env, [f"%(member_{member.id})s" for member in members])
1426-
)
1427-
% {
1428-
f"member_{member.id}": member._get_html_link(for_persona=True)
1429-
for member in members
1430-
},
1428+
member_names=member_names,
14311429
)
14321430
else:
14331431
msg = _("You are alone in a private conversation.")
@@ -1462,13 +1460,13 @@ def execute_command_who(self, **kwargs):
14621460
list_params.append(_("more"))
14631461
else:
14641462
list_params.append(_("you"))
1463+
member_names = html_escape(format_list(self.env, list_params)) % {
1464+
f"member_{member.id}": member._get_html_link(for_persona=True)
1465+
for member in members
1466+
}
14651467
msg = _(
14661468
"Users in this channel: %(members)s.",
1467-
members=html_escape(format_list(self.env, list_params))
1468-
% {
1469-
f"member_{member.id}": member._get_html_link(for_persona=True)
1470-
for member in members
1471-
},
1469+
members=member_names,
14721470
)
14731471
else:
14741472
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
@@ -141,7 +141,7 @@ def _description_domain(self, env: Environment) -> str | list:
141141
_logger.warning(env._(
142142
"Couldn't generate a company-dependent domain for field %s. "
143143
"The model doesn't have a 'company_id' or 'company_ids' field, and isn't company-dependent either.",
144-
f'{self.model_name}.{self.name}'
144+
self.model_name + '.' + self.name,
145145
))
146146
return domain
147147
company_domain = env[self.comodel_name]._check_company_domain(companies=unquote(cids))

0 commit comments

Comments
 (0)