Skip to content
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

[11.0][mrp_multi_level] Cannot install mrp_multi_level without 'en_GB.UTF-8' locale #326

Closed
katyukha opened this issue Dec 19, 2018 · 2 comments

Comments

@katyukha
Copy link

Hello!

I have tried to install mrp_multi_level and got following error:

odoo_1  | Traceback (most recent call last):
odoo_1  |   File "/opt/odoo/odoo/odoo/tools/safe_eval.py", line 350, in safe_eval
odoo_1  |     return unsafe_eval(c, globals_dict, locals_dict)
odoo_1  |   File "", line 1, in <module>
odoo_1  |   File "/opt/odoo/custom_addons/mrp_multi_level/wizards/mrp_multi_level.py", line 773, in run_mrp_multi_level
odoo_1  |     self._mrp_final_process()
odoo_1  |   File "/opt/odoo/custom_addons/mrp_multi_level/wizards/mrp_multi_level.py", line 741, in _mrp_final_process
odoo_1  |     self._init_mrp_inventory(mrp_product)
odoo_1  |   File "/opt/odoo/custom_addons/mrp_multi_level/wizards/mrp_multi_level.py", line 683, in _init_mrp_inventory
odoo_1  |     group['mrp_date:day'])
odoo_1  |   File "/opt/odoo/custom_addons/mrp_multi_level/wizards/mrp_multi_level.py", line 649, in _convert_group_date_to_default
odoo_1  |     locale.setlocale(locale.LC_TIME, 'en_GB.UTF-8')
odoo_1  |   File "/opt/odoo/venv/lib/python3.6/locale.py", line 598, in setlocale
odoo_1  |     return _setlocale(category, locale)
odoo_1  | locale.Error: unsupported locale setting
odoo_1  | 
odoo_1  | During handling of the above exception, another exception occurred:
odoo_1  | 
odoo_1  | Traceback (most recent call last):
odoo_1  |   File "/opt/odoo/odoo/odoo/addons/base/ir/ir_cron.py", line 102, in _callback
odoo_1  |     self.env['ir.actions.server'].browse(server_action_id).run()
odoo_1  |   File "/opt/odoo/odoo/odoo/addons/base/ir/ir_actions.py", line 554, in run
odoo_1  |     res = func(action, eval_context=eval_context)
odoo_1  |   File "/opt/odoo/odoo/odoo/addons/base/ir/ir_actions.py", line 430, in run_action_code_multi
odoo_1  |     safe_eval(action.sudo().code.strip(), eval_context, mode="exec", nocopy=True)  # nocopy allows to return 'action'
odoo_1  |   File "/opt/odoo/odoo/odoo/tools/safe_eval.py", line 373, in safe_eval
odoo_1  |     pycompat.reraise(ValueError, ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr)), exc_info[2])
odoo_1  |   File "/opt/odoo/odoo/odoo/tools/pycompat.py", line 86, in reraise
odoo_1  |     raise value.with_traceback(tb)
odoo_1  |   File "/opt/odoo/odoo/odoo/tools/safe_eval.py", line 350, in safe_eval
odoo_1  |     return unsafe_eval(c, globals_dict, locals_dict)
odoo_1  |   File "", line 1, in <module>
odoo_1  |   File "/opt/odoo/custom_addons/mrp_multi_level/wizards/mrp_multi_level.py", line 773, in run_mrp_multi_level
odoo_1  |     self._mrp_final_process()
odoo_1  |   File "/opt/odoo/custom_addons/mrp_multi_level/wizards/mrp_multi_level.py", line 741, in _mrp_final_process
odoo_1  |     self._init_mrp_inventory(mrp_product)
odoo_1  |   File "/opt/odoo/custom_addons/mrp_multi_level/wizards/mrp_multi_level.py", line 683, in _init_mrp_inventory
odoo_1  |     group['mrp_date:day'])
odoo_1  |   File "/opt/odoo/custom_addons/mrp_multi_level/wizards/mrp_multi_level.py", line 649, in _convert_group_date_to_default
odoo_1  |     locale.setlocale(locale.LC_TIME, 'en_GB.UTF-8')
odoo_1  |   File "/opt/odoo/venv/lib/python3.6/locale.py", line 598, in setlocale
odoo_1  |     return _setlocale(category, locale)
odoo_1  | ValueError: <class 'locale.Error'>: "unsupported locale setting" while evaluating
odoo_1  | 'model.run_mrp_multi_level()'

Is it really required to install en_GB locale to make this module work?

May be it would be good to fallback to default locale?

Or even use locale based on user's lang?


Related #290

@LoisRForgeFlow
Copy link
Contributor

Yes, it is, it is also used in standard Odoo in some pos modules if I remember correctly. Plus, the locale is available by default in almost any linux distribution, so I don't think this is a very big deal, isn't it?

If you find a better solution without using en_GB localte please propose it in a PR. Thanks.

@katyukha
Copy link
Author

Hello again. Thanks for response.

It seems that default locale for Odoo is en_US. en_GB locale used only in pos_sale addon and in PO files.

For example, what i have found via grep "en_US":

../../odoo/addons/mail/models/mail_template.py:        return format_datetime(ts, format or 'medium', locale=env.context.get("lang") or 'en_US')
../../odoo/addons/mail/models/mail_template.py:    lang = env['res.lang']._lang_get(env.context.get('lang') or 'en_US')
../../odoo/addons/website_event/controllers/main.py:        month = babel.dates.get_month_names('abbreviated', locale=event.env.context.get('lang') or 'en_US')[start_date.month]
../../odoo/addons/calendar/models/calendar.py:            result = babel.dates.format_date(date=date, format='MMMM y', locale=self._context.get('lang') or 'en_US')

My case (when i spotted this error) is that we have docker image with only en_US locale installed that is used for continuous integration. And module fails to install without en_GB locale. I know that i can add this locale to our docker image, but not sure that it is good idea for Odoo addon to depend on system locale. At least this dependency have to be mentioned in addon readme / description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants