← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~therp-nl/ocb-web/7.0_lp1340813 into lp:ocb-web

 

Holger Brunn (Therp) has proposed merging lp:~therp-nl/ocb-web/7.0_lp1340813 into lp:ocb-web.

Requested reviews:
  OpenERP Community Backports (ocb)
Related bugs:
  Bug #1340813 in OpenERP Community Backports (Web): "[6.1][7.0] regression: Printing reports from models with incorrect/missing _rec_name causes a traceback"
  https://bugs.launchpad.net/ocb-web/+bug/1340813

For more details, see:
https://code.launchpad.net/~therp-nl/ocb-web/7.0_lp1340813/+merge/226488
-- 
https://code.launchpad.net/~therp-nl/ocb-web/7.0_lp1340813/+merge/226488
Your team OpenERP Community Backports is requested to review the proposed merge of lp:~therp-nl/ocb-web/7.0_lp1340813 into lp:ocb-web.
=== modified file 'addons/web/controllers/main.py'
--- addons/web/controllers/main.py	2014-05-19 12:41:22 +0000
+++ addons/web/controllers/main.py	2014-07-11 16:28:12 +0000
@@ -1759,12 +1759,20 @@
                     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('[/:(")<>|?*]|(\\\)')


Follow ups