[MERGE] with trunk
[odoo/odoo.git] / addons / hr_payroll / report / rml_parse.py
index 2fc04bb..b8a1791 100755 (executable)
@@ -6,23 +6,25 @@
 #    $Id$
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    it under the terms of the GNU Affero General Public License as published by
 #    the Free Software Foundation, either version 3 of the License, or
 #    (at your option) any later version.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
+from time import strptime
+
 from report import report_sxw
 import re
 from lxml import etree
-from time import strptime
+
 
 class rml_parse(report_sxw.rml_parse):
     def __init__(self, cr, uid, name, context):
@@ -30,16 +32,16 @@ class rml_parse(report_sxw.rml_parse):
         self.localcontext.update({
             'comma_me': self.comma_me,
             'format_date': self._get_and_change_date_format_for_swiss,
-            'strip_name' : self._strip_name,
-            'explode_name' : self._explode_name,
+            'strip_name': self._strip_name,
+            'explode_name': self._explode_name,
         })
 
     def comma_me(self,amount):
         if not amount:
             amount = 0.0
-        if  type(amount) is float :
+        if  type(amount) is float:
             amount = str('%.2f'%amount)
-        else :
+        else:
             amount = str(amount)
         if (amount == '0'):
              return ' '
@@ -63,7 +65,7 @@ class rml_parse(report_sxw.rml_parse):
     def _get_and_change_date_format_for_swiss (self,date_to_format):
         date_formatted=''
         if date_to_format:
-            date_formatted = strptime (date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y')
+            date_formatted = strptime(date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y')
         return date_formatted
 
     def _explode_name(self,chaine,length):
@@ -101,6 +103,16 @@ class rml_parse(report_sxw.rml_parse):
             return Stringer
         return Stringer
 
+    def explode_this(self,chaine,length):
+        chaine = chaine.rstrip()
+        ast = list(chaine)
+        i = length
+        while i <= len(ast):
+            ast.insert(i,'\n')
+            i = i + length
+        chaine = str("".join(ast))
+        return chaine
+
     def repair_string(self,chaine):
         ast = list(chaine)
         UnicodeAst = []
@@ -132,10 +144,10 @@ class rml_parse(report_sxw.rml_parse):
         head_dom = etree.XML(rml_head)
         for tag in head_dom:
             found = rml_dom.find('.//'+tag.tag)
-            if found is not None and len(found):
+            if found is not None and found:
                 if tag.get('position'):
                     found.append(tag)
-                else :
+                else:
                     found.getparent().replace(found,tag)
         return True