changeset 75e45071896f in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset&node=75e45071896f
description:
        Add option to remove leading and trailing white spaces from char

        issue7914
        review340511008
diffstat:

 tryton/gui/window/view_form/model/field.py |  10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diffs (20 lines):

diff -r 99beee9b9337 -r 75e45071896f tryton/gui/window/view_form/model/field.py
--- a/tryton/gui/window/view_form/model/field.py        Sun Sep 18 12:27:39 
2022 +0200
+++ b/tryton/gui/window/view_form/model/field.py        Mon Sep 19 21:25:55 
2022 +0200
@@ -202,6 +202,16 @@
 class CharField(Field):
     _default = ''
 
+    def set(self, record, value):
+        if self.attrs.get('strip') and value:
+            if self.attrs['strip'] == 'leading':
+                value = value.lstrip()
+            elif self.attrs['strip'] == 'trailing':
+                value = value.rstrip()
+            else:
+                value = value.strip()
+        super().set(record, value)
+
     def get(self, record):
         return super(CharField, self).get(record) or self._default
 

Reply via email to