[FIX] calling name_get can cause tracebacks when printing reports
authorHolger Brunn <hbrunn@therp.nl>
Tue, 15 Jul 2014 08:04:35 +0000 (10:04 +0200)
committerHolger Brunn <hbrunn@therp.nl>
Tue, 15 Jul 2014 08:04:35 +0000 (10:04 +0200)
addons/web/controllers/main.py

index 7bd0b15..88ae25b 100644 (file)
@@ -1759,12 +1759,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)
         file_name = '%s.%s' % (file_name, report_struct['format'])
         # Create safe filename
         p = re.compile('[/:(")<>|?*]|(\\\)')