Merge pull request #18 from hbrunn/7.0_lp1340813
authorPedro M. Baeza <pedro.baeza@gmail.com>
Wed, 12 Nov 2014 16:17:29 +0000 (17:17 +0100)
committerPedro M. Baeza <pedro.baeza@gmail.com>
Wed, 12 Nov 2014 16:17:29 +0000 (17:17 +0100)
[FIX] calling name_get can cause tracebacks when printing reports

addons/web/controllers/main.py

index 342f6e0..18e0947 100644 (file)
@@ -1766,12 +1766,20 @@ class Reports(openerpweb.Controller):
                     and action_context['active_ids']):
                 # Use built-in ORM method to get data from DB
                 m = req.session.model(action_context['active_model'])
-                r = m.name_get(action_context['active_ids'], context)
+                r = []
+                try:
+                    r = m.name_get(action_context['active_ids'], context)
+                except xmlrpclib.Fault:
+                    #we assume this went wrong because of incorrect/missing
+                    #_rec_name. We don't have access to _columns here to do
+                    # a proper check
+                    pass
                 # Parse result to create a better filename
                 item_names = [item[1] or str(item[0]) for item in r]
                 if action.get('name'):
                     item_names.insert(0, action['name'])
-                file_name = '-'.join(item_names)
+                if item_names:
+                    file_name = '-'.join(item_names)[:251]
         file_name = '%s.%s' % (file_name, report_struct['format'])
         # Create safe filename
         p = re.compile('[/:(")<>|?*]|(\\\)')