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

[FIX] tools: prevent IoT crash due to missing library #165067

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions odoo/tools/_monkeypatches.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import ast
import os
import logging
import num2words
from odoo import MIN_PY_VERSION
from .num2words_patch import Num2Word_AR_Fixed
from shutil import copyfileobj
from types import CodeType

_logger = logging.getLogger(__name__)

try:
import num2words
from .num2words_patch import Num2Word_AR_Fixed
except ImportError:
_logger.warning("num2words is not available, Arabic number to words conversion will not work")
lse-odoo marked this conversation as resolved.
Show resolved Hide resolved
num2words = None

from werkzeug.datastructures import FileStorage
from werkzeug.routing import Rule
from werkzeug.wrappers import Request, Response
Expand Down Expand Up @@ -72,4 +77,5 @@ def literal_eval(expr):
if MIN_PY_VERSION >= (3, 12):
raise RuntimeError("The num2words monkey patch is obsolete. Bump the version of the library to the latest available in the official package repository, if it hasn't already been done, and remove the patch.")

num2words.CONVERTER_CLASSES["ar"] = Num2Word_AR_Fixed()
if num2words:
num2words.CONVERTER_CLASSES["ar"] = Num2Word_AR_Fixed()