Remove forbidden chars from imported names
issue9829 review318821002
This commit is contained in:
1 parent
6544c572a8
commit
81ce1da6d6
1 file changed
+11
-2
@@ -37,6 +37,14 @@ def _get_language_codes():
|
||||
yield l.code
|
||||
|
||||
|
||||
def _remove_forbidden_chars(name):
|
||||
from trytond.model.fields import Char
|
||||
for c in Char.forbidden_chars:
|
||||
if c in name:
|
||||
name.replace(c, ' ')
|
||||
return name.strip()
|
||||
|
||||
|
||||
def get_currencies():
|
||||
Currency = Model.get('currency.currency')
|
||||
return {c.code: c for c in Currency.find([])}
|
||||
@@ -54,7 +62,7 @@ def update_currencies(currencies):
|
||||
record = currencies[code]
|
||||
else:
|
||||
record = Currency(code=code)
|
||||
record.name = currency.name
|
||||
record.name = _remove_forbidden_chars(currency.name)
|
||||
record.numeric_code = currency.numeric
|
||||
record.symbol = codes.get_symbol(currency.alpha_3) or currency.alpha_3
|
||||
records.append(record)
|
||||
@@ -78,7 +86,8 @@ def translate_currencies(currencies):
|
||||
records = []
|
||||
for currency in _progress(pycountry.currencies):
|
||||
record = Currency(currencies[currency.alpha_3].id)
|
||||
record.name = gnutranslation.gettext(currency.name)
|
||||
record.name = _remove_forbidden_chars(
|
||||
gnutranslation.gettext(currency.name))
|
||||
records.append(record)
|
||||
Currency.save(records)
|
||||
|
||||
|
||||
Reference in new issue
Block a user