Add issue8776 - [trytond] Add slugify tool
This commit is contained in:
parent
db27d2f44a
commit
5e65aa5c87
|
@ -0,0 +1,29 @@
|
|||
diff --git a/trytond/trytond/tools/misc.py b/trytond/trytond/tools/misc.py
|
||||
index ee2763c9..300b5a72 100644
|
||||
--- a/trytond/trytond/tools/misc.py
|
||||
+++ b/trytond/trytond/tools/misc.py
|
||||
@@ -12,6 +12,8 @@ import types
|
||||
import io
|
||||
import warnings
|
||||
import importlib
|
||||
+import re
|
||||
+import unicodedata
|
||||
|
||||
from sql import Literal
|
||||
from sql.operators import Or
|
||||
@@ -272,3 +274,15 @@ def rstrip_wildcard(string, wildcard='%', escape='\\'):
|
||||
if new_string[-1] == escape:
|
||||
return string
|
||||
return new_string
|
||||
+
|
||||
+
|
||||
+_slugify_strip_re = re.compile(r'[^\w\s-]')
|
||||
+_slugify_hyphenate_re = re.compile(r'[-\s]+')
|
||||
+
|
||||
+
|
||||
+def slugify(value, hyphenate='-'):
|
||||
+ if not isinstance(value, str):
|
||||
+ value = str(value)
|
||||
+ value = unicodedata.normalize('NFKD', value)
|
||||
+ value = str(_slugify_strip_re.sub('', value).strip())
|
||||
+ return _slugify_hyphenate_re.sub(hyphenate, value)
|
5
series
5
series
|
@ -1,10 +1,11 @@
|
|||
babi_multiprocess.diff # [trytond] babi multiprocess
|
||||
trytond_test_database.diff # [trytond] avoid errors on upgrades from version 3.4
|
||||
logging_jsonrpc_exeption.diff # [trytond] logging JSONRPC Exception
|
||||
issue8776.diff # [trytond] Add slugify tool
|
||||
|
||||
account_payment_view.diff # [account_payment]
|
||||
account_payment_sepa_locale.diff # [account_payment_sepa]
|
||||
|
||||
|
||||
issue3932.diff # [account] rule account move and account move line by company
|
||||
|
||||
issue6253.diff # [account_invoice] add invoice type criteria
|
||||
|
@ -97,4 +98,4 @@ issue10382.diff # [stock_split] Decimals of quantity move exceed the total digit
|
|||
issue10338.diff # [bank] Search on rec_name of other model in search_rec_name
|
||||
issue9146.diff # [account_stock_landed_cost] Use field digits on secondary unit
|
||||
|
||||
stock_lot_sled_ca_locale.diff # [stock_lot_sled] Fix wrong translation [#044921]
|
||||
stock_lot_sled_ca_locale.diff # [stock_lot_sled] Fix wrong translation [#044921]
|
||||
|
|
Loading…
Reference in New Issue