Riken Bhorania (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.0-bug-747284-rch into 
lp:openobject-addons/6.0.

Requested reviews:
  Jay Vora (OpenERP) (jvo-openerp)
Related bugs:
  Bug #747284 in OpenERP Addons: "[6.0] Webkit report missing error"
  https://bugs.launchpad.net/openobject-addons/+bug/747284

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-bug-747284-rch/+merge/64389

Hello Sir,

User friendly popup error message displayed when webkit report's path does not 
exist.

Since os.path.exists() does not accept boolen argument, there was improper 
error message displayed when someone try to open webkit report that was already 
deleted.

This fixes the issue.

Thanks,
Riken
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-bug-747284-rch/+merge/64389
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.0-bug-747284-rch.
=== modified file 'report_webkit/webkit_report.py'
--- report_webkit/webkit_report.py	2011-04-30 01:56:46 +0000
+++ report_webkit/webkit_report.py	2011-06-13 11:37:29 +0000
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 ##############################################################################
 #
-# Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com) 
+# Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com)
 # All Right Reserved
 #
 # Author : Nicolas Bessi (Camptocamp)
@@ -60,12 +60,12 @@
     """Custom class that use webkit to render HTML reports
        Code partially taken from report openoffice. Thanks guys :)
     """
-    
-    def __init__(self, name, table, rml=False, parser=False, 
+
+    def __init__(self, name, table, rml=False, parser=False,
         header=True, store=False):
         self.parser_instance = False
         self.localcontext={}
-        report_sxw.__init__(self, name, table, rml, parser, 
+        report_sxw.__init__(self, name, table, rml, parser,
             header, store)
 
     def get_lib(self, cursor, uid, company) :
@@ -81,7 +81,7 @@
                              ' http://code.google.com/p/wkhtmltopdf/downloads/list and set the'+
                              ' path to the executable on the Company form.'+
                              'Minimal version is 0.9.9')
-                            ) 
+                            )
         if os.path.isabs(path) :
             if (os.path.exists(path) and os.access(path, os.X_OK)\
                 and os.path.basename(path).startswith('wkhtmltopdf')):
@@ -118,7 +118,7 @@
             head_file = file( os.path.join(
                                   tmp_dir,
                                   str(time.time()) + '.head.html'
-                                 ), 
+                                 ),
                                 'w'
                             )
             head_file.write(header)
@@ -129,14 +129,14 @@
             foot_file = file(  os.path.join(
                                   tmp_dir,
                                   str(time.time()) + '.foot.html'
-                                 ), 
+                                 ),
                                 'w'
                             )
             foot_file.write(footer)
             foot_file.close()
             file_to_del.append(foot_file.name)
             command.extend(['--footer-html', foot_file.name])
-            
+
         if webkit_header.margin_top :
             command.extend(['--margin-top', str(webkit_header.margin_top).replace(',', '.')])
         if webkit_header.margin_bottom :
@@ -163,7 +163,7 @@
             status = subprocess.call(command, stderr=subprocess.PIPE) # ignore stderr
             if status :
                 raise except_osv(
-                                _('Webkit raise an error' ), 
+                                _('Webkit raise an error' ),
                                 status
                             )
         except Exception:
@@ -176,8 +176,8 @@
 
         os.unlink(out)
         return pdf
-    
-    
+
+
     def setLang(self, lang):
         if not lang:
             lang = 'en_US'
@@ -189,8 +189,8 @@
         res = ir_translation._get_source(self.parser_instance.cr, self.parser_instance.uid, self.name, 'report', self.localcontext.get('lang', 'en_US'), src)
         if not res :
             return src
-        return res 
- 
+        return res
+
     def formatLang(self, value, digits=None, date=False, date_time=False, grouping=True, monetary=False):
         """format using the know cursor, language from localcontext"""
         if digits is None:
@@ -199,7 +199,7 @@
             return ''
         pool_lang = self.pool.get('res.lang')
         lang = self.localcontext['lang']
-        
+
         lang_ids = pool_lang.search(self.parser_instance.cr, self.parser_instance.uid, [('code','=',lang)])[0]
         lang_obj = pool_lang.browse(self.parser_instance.cr, self.parser_instance.uid, lang_ids)
 
@@ -225,7 +225,7 @@
     # override needed to keep the attachments' storing procedure
     def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None):
         """generate the PDF"""
-        
+
         if context is None:
             context={}
 
@@ -247,7 +247,7 @@
 
         if report_xml.report_file :
             path = addons.get_module_resource(report_xml.report_file)
-            if os.path.exists(path) :
+            if path and os.path.exists(path) :
                 template = file(path).read()
         if not template and report_xml.report_webkit_data :
             template =  report_xml.report_webkit_data
@@ -266,7 +266,7 @@
 <html>
     <head>
         <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
-        <style type="text/css"> 
+        <style type="text/css">
             ${css}
         </style>
         <script>
@@ -290,7 +290,7 @@
             css = ''
         user = self.pool.get('res.users').browse(cursor, uid, uid)
         company= user.company_id
-        
+
         #default_filters=['unicode', 'entity'] can be used to set global filter
         body_mako_tpl = mako_template(template)
         helper = WebKitHelper(cursor, uid, report_xml.id, context)
@@ -366,11 +366,11 @@
         report_xml_ids = ir_obj.search(cursor, uid,
                 [('report_name', '=', self.name[7:])], context=context)
         if report_xml_ids:
-            
+
             report_xml = ir_obj.browse(
-                                        cursor, 
-                                        uid, 
-                                        report_xml_ids[0], 
+                                        cursor,
+                                        uid,
+                                        report_xml_ids[0],
                                         context=context
                                     )
             report_xml.report_rml = None

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to