Merge remote-tracking branch 'odoo/7.0' into 7.0
[odoo/odoo.git] / openerp / report / render / rml2pdf / utils.py
index 656045c..94b3d9d 100644 (file)
@@ -1,26 +1,8 @@
 # -*- coding: utf-8 -*-
 ##############################################################################
 #
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
-#
-#    This program is free software: you can redistribute it and/or modify
-#    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 Affero General Public License for more details.
-#
-#    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/>.
-#
-##############################################################################
-
-# trml2pdf - An RML to PDF converter
 # Copyright (C) 2003, Fabien Pinckaers, UCL, FSA
+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -34,7 +16,9 @@
 #
 # You should have received a copy of the GNU Lesser General Public
 # License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+#
+##############################################################################
 
 import copy
 import locale
@@ -47,6 +31,8 @@ import openerp.tools as tools
 from openerp.tools.safe_eval import safe_eval as eval
 from openerp.tools.misc import ustr
 
+_logger = logging.getLogger(__name__)
+
 _regex = re.compile('\[\[(.+?)\]\]')
 
 def str2xml(s):
@@ -68,7 +54,7 @@ def _child_get(node, self=None, tagname=None):
                         except GeneratorExit:
                             continue
                         except Exception, e:
-                            logging.getLogger('report').warning('rml_except: "%s"',n.get('rml_except',''), exc_info=True)
+                            _logger.warning('rml_except: "%s"', n.get('rml_except',''), exc_info=True)
                             continue
                     if n.get('rml_tag'):
                         try:
@@ -80,7 +66,7 @@ def _child_get(node, self=None, tagname=None):
                         except GeneratorExit:
                             yield n
                         except Exception, e:
-                            logging.getLogger('report').warning('rml_tag: "%s"',n.get('rml_tag',''), exc_info=True)
+                            _logger.warning('rml_tag: "%s"', n.get('rml_tag',''), exc_info=True)
                             yield n
                     else:
                         yield n
@@ -91,7 +77,7 @@ def _child_get(node, self=None, tagname=None):
             except GeneratorExit:
                 continue
             except Exception, e:
-                logging.getLogger('report').warning('rml_except: "%s"',n.get('rml_except',''), exc_info=True)
+                _logger.warning('rml_except: "%s"', n.get('rml_except',''), exc_info=True)
                 continue
         if self and self.localcontext and n.get('rml_tag'):
             try:
@@ -100,11 +86,11 @@ def _child_get(node, self=None, tagname=None):
                 n2.tag = tag
                 n2.attrib.update(attr or {})
                 yield n2
-                tagname = ''
+                continue
             except GeneratorExit:
                 pass
             except Exception, e:
-                logging.getLogger('report').warning('rml_tag: "%s"',n.get('rml_tag',''), exc_info=True)
+                _logger.warning('rml_tag: "%s"', n.get('rml_tag',''), exc_info=True)
                 pass
         if (tagname is None) or (n.tag==tagname):
             yield n
@@ -179,7 +165,9 @@ def tuple_int_get(node, attr_name, default=None):
 def bool_get(value):
     return (str(value)=="1") or (value.lower()=='yes')
 
-def attr_get(node, attrs, dict={}):
+def attr_get(node, attrs, dict=None):
+    if dict is None:
+        dict = {}
     res = {}
     for name in attrs:
         if node.get(name):