Merge pull request #1424 from odoo-dev/saas-5-handlemissingjs-nse
[FIX] Do not raise 500 error when an asset is missing Note: those features are already present in master but could not be backported because the asset bundles are now completely different since the sass and less support where added. If a forward porting occurs, you can drop this merge and keep master's version
This commit is contained in:
@@ -662,7 +662,7 @@ class DateTimeConverter(osv.AbstractModel):
|
||||
|
||||
if options and options.get('hide_seconds'):
|
||||
pattern = pattern.replace(":ss", "").replace(":s", "")
|
||||
|
||||
|
||||
return babel.dates.format_datetime(value, format=pattern, locale=locale)
|
||||
|
||||
class TextConverter(osv.AbstractModel):
|
||||
@@ -771,7 +771,7 @@ class MonetaryConverter(osv.AbstractModel):
|
||||
|
||||
lang_code = context.get('lang') or 'en_US'
|
||||
lang = self.pool['res.lang']
|
||||
formatted_amount = lang.format(cr, uid, [lang_code],
|
||||
formatted_amount = lang.format(cr, uid, [lang_code],
|
||||
fmt, Currency.round(cr, uid, display, record[field_name]),
|
||||
grouping=True, monetary=True)
|
||||
|
||||
@@ -1120,7 +1120,10 @@ class WebAsset(object):
|
||||
except ValueError:
|
||||
self.last_modified = datetime.datetime.strptime(attach[0]['__last_update'], server_format)
|
||||
except Exception:
|
||||
raise KeyError("Could not find asset '%s' for '%s' addon" % (self.url, module))
|
||||
self._missingAsset(module)
|
||||
|
||||
def _missingAsset(self, module):
|
||||
raise KeyError("Could not find asset '%s' for '%s' addon" % (self.url, module))
|
||||
|
||||
@openerp.tools.func.lazy_property
|
||||
def content(self):
|
||||
@@ -1147,6 +1150,11 @@ class JavascriptAsset(WebAsset):
|
||||
else:
|
||||
return '<script type="text/javascript" charset="utf-8">%s</script>' % self.source
|
||||
|
||||
def _missingAsset(self, module):
|
||||
self.source = "console.error('Missing javascript asset: %s');" % self.url
|
||||
self.url = None
|
||||
self.last_modified = datetime.datetime.now()
|
||||
|
||||
class StylesheetAsset(WebAsset):
|
||||
rx_import = re.compile(r"""@import\s+('|")(?!'|"|/|https?://)""", re.U)
|
||||
rx_url = re.compile(r"""url\s*\(\s*('|"|)(?!'|"|/|https?://|data:)""", re.U)
|
||||
@@ -1197,6 +1205,20 @@ class StylesheetAsset(WebAsset):
|
||||
else:
|
||||
return '<style type="text/css">%s</style>' % self.source
|
||||
|
||||
def _missingAsset(self, module):
|
||||
self.source = """
|
||||
body:before {
|
||||
background: #ffc;
|
||||
width: 100%%;
|
||||
font-size: 14px;
|
||||
font-family: monospace;
|
||||
white-space: pre;
|
||||
content: "Missing stylesheet asset: %s";
|
||||
}
|
||||
""" % self.url
|
||||
self.url = None
|
||||
self.last_modified = datetime.datetime.now()
|
||||
|
||||
def rjsmin(script):
|
||||
""" Minify js with a clever regex.
|
||||
Taken from http://opensource.perlig.de/rjsmin
|
||||
|
||||
Reference in New Issue
Block a user