-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[FIX] hr_recruitment: use context lang for partner creation #173212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] hr_recruitment: use context lang for partner creation #173212
Conversation
2a3b46d
to
0674671
Compare
0674671
to
77f4b70
Compare
test_layout_email_lang_template fails because template takes lang from mail.test.lang here: def render_inline_template(template_instructions, variables):
results = []
for string, expression in template_instructions:
results.append(string)
if expression:
result = safe_eval.safe_eval(expression, variables) <--- HERE lang is taken from the mail.test.lang object
if result:
results.append(str(result))
return ''.join(results) and adds it to the context here in odoo/addons/mail/models/mail_render_mixin.py Lines 573 to 584 in 677f7d0
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
when there is a parent partner, we are doing in the _onchange_parent_id_for_lang
:
odoo/odoo/addons/base/models/res_partner.py
Line 488 in 677f7d0
self.lang = self.parent_id.lang or self.env.context.get('default_lang') or self.env.lang |
(self.env.lang
is a shortcut to self.env.context.get('lang')
(that also has a check to see if this is a valid language))
so it seems ok to also have a similar fallback when there is no parent partner.
probably we should also handle the default_lang
with higher priority than context lang
, because currently this could be working like this and people could be using default_lang
with the context having another language.
sorry, looking more at it, I see that the lang should already defined in python at: so I'm not sure how this doesn't work, since we should already fallback on the context lang (self.env.lang) if there is no edit: oh maybe in this flow we don't use the default_get. If it's the case, then maybe:
|
dbd0e73
to
3bf513a
Compare
Experiment: Remove ir_default tz -> FailRemoving default timezone ir_default table with: diff --git a/odoo/addons/base/models/res_lang.py b/odoo/addons/base/models/res_lang.py
--- a/odoo/addons/base/models/res_lang.py
+++ b/odoo/addons/base/models/res_lang.py
@@ -202,7 +202,6 @@ class Lang(models.Model):
IrDefault = self.env['ir.default']
default_value = IrDefault._get('res.partner', 'lang')
if default_value is None:
- IrDefault.set('res.partner', 'lang', lang_code) ... solves the issue, because then default_get will grab language from the context. |
3bf513a
to
a6b6387
Compare
Experiment 2: reorder default_get lang -> works but too wideSo it doens't make sense that getting value base default get is first |
a6b6387
to
93cbc5d
Compare
Narrowing down......to hr_recruitment module, to the partner creation from email_from inverse |
477c411
to
627ec2e
Compare
a30035e
to
f3a63b2
Compare
f3a63b2
to
dc7de9f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
The fix seems to work, so aside from my comment, LGTM! :)
self.env['res.lang']._activate_lang('pl_PL') | ||
self.assertGreaterEqual(len(self.env['res.lang'].get_installed()), 2, "Need more langagues than 'pl_PL' installed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's best that you ensure that more than 2 languages are installed rather than having a check for it, and same for the default as well :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, thanks for having a look ;)
When partner is created from Applicant's email_from inverse, in a situation when job application is submitted, we should use context lang for him. Useful when submiting application for multi-lang website and becuase partner's lang is used to send appropriate translations of recruitment templates. [Reproduce Original Error] - Install website,hr_recruitment - Set couple of languages on the website (e.g., en_US as default, es_MX as the second language). - In incognito, using non-default language, apply for some position (url: /es_MX/jobs ) - BUG: The email sent to the applicant is in the default language opw-3984176
dc7de9f
to
fd6dc9d
Compare
robodoo delegate+ |
robodoo r+ |
When partner is created from Applicant's email_from inverse, in a situation when job application is submitted, we should use context lang for him. Useful when submiting application for multi-lang website and becuase partner's lang is used to send appropriate translations of recruitment templates. [Reproduce Original Error] - Install website,hr_recruitment - Set couple of languages on the website (e.g., en_US as default, es_MX as the second language). - In incognito, using non-default language, apply for some position (url: /es_MX/jobs ) - BUG: The email sent to the applicant is in the default language opw-3984176 closes #173212 Signed-off-by: Bertrand Dossogne (bedo) <bedo@odoo.com>
When partner is created from Applicant's email_from inverse, in a situation when job application is submitted, we should use context lang for him. Useful when submiting application for multi-lang website and becuase partner's lang is used to send appropriate translations of recruitment templates. [Reproduce Original Error] - Install website,hr_recruitment - Set couple of languages on the website (e.g., en_US as default, es_MX as the second language). - In incognito, using non-default language, apply for some position (url: /es_MX/jobs ) - BUG: The email sent to the applicant is in the default language opw-3984176 closes odoo#173212 Signed-off-by: Bertrand Dossogne (bedo) <bedo@odoo.com>
When partner is created from Applicant's email_from inverse, in a situation when job application is submitted, we should use context lang for him. Useful when submiting application for multi-lang website and becuase partner's lang is used to send appropriate translations of recruitment templates. [Reproduce Original Error] - Install website,hr_recruitment - Set couple of languages on the website (e.g., en_US as default, es_MX as the second language). - In incognito, using non-default language, apply for some position (url: /es_MX/jobs ) - BUG: The email sent to the applicant is in the default language opw-3984176 closes odoo#173212 Signed-off-by: Bertrand Dossogne (bedo) <bedo@odoo.com>
[FIX] hr_recruitment: use context lang for partner creation
When partner is created from Applicant's email_from inverse, in a situation when
job application is submitted, we should use context lang for him.
Useful when submiting application for multi-lang website and becuase
partner's lang is used to send appropriate translations of recruitment
templates.
[Reproduce Original Error]
opw-3984176