Skip to content

Commit 486b5f4

Browse files
xmo-odooyodalberth
authored andcommitted
[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. closes odoo#218803 Signed-off-by: Xavier Morel (xmo) <[email protected]>
1 parent ac0e3e4 commit 486b5f4

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
@@ -1284,15 +1284,13 @@ def execute_command_help(self, **kwargs):
12841284
)
12851285
else:
12861286
if members := self.channel_member_ids.filtered(lambda m: not m.is_self):
1287+
member_names = html_escape(format_list(self.env, [f"%(member_{member.id})s" for member in members])) % {
1288+
f"member_{member.id}": member._get_html_link(for_persona=True)
1289+
for member in members
1290+
}
12871291
msg = _(
12881292
"You are in a private conversation with %(member_names)s.",
1289-
member_names=html_escape(
1290-
format_list(self.env, [f"%(member_{member.id})s" for member in members])
1291-
)
1292-
% {
1293-
f"member_{member.id}": member._get_html_link(for_persona=True)
1294-
for member in members
1295-
},
1293+
member_names=member_names,
12961294
)
12971295
else:
12981296
msg = _("You are alone in a private conversation.")
@@ -1326,13 +1324,13 @@ def execute_command_who(self, **kwargs):
13261324
list_params.append(_("more"))
13271325
else:
13281326
list_params.append(_("you"))
1327+
member_names = html_escape(format_list(self.env, list_params)) % {
1328+
f"member_{member.id}": member._get_html_link(for_persona=True)
1329+
for member in members
1330+
}
13291331
msg = _(
13301332
"Users in this channel: %(members)s.",
1331-
members=html_escape(format_list(self.env, list_params))
1332-
% {
1333-
f"member_{member.id}": member._get_html_link(for_persona=True)
1334-
for member in members
1335-
},
1333+
members=member_names,
13361334
)
13371335
else:
13381336
msg = _("You are alone in this channel.")

odoo/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3112,7 +3112,7 @@ def _description_domain(self, env):
31123112
_logger.warning(env._(
31133113
"Couldn't generate a company-dependent domain for field %s. "
31143114
"The model doesn't have a 'company_id' or 'company_ids' field, and isn't company-dependent either.",
3115-
f'{self.model_name}.{self.name}'
3115+
self.model_name + '.' + self.name,
31163116
))
31173117
return domain
31183118
company_domain = env[self.comodel_name]._check_company_domain(companies=unquote(cids))

0 commit comments

Comments
 (0)