cam testenv blue bars (side and top), test background image for standard-frontend and qweb reports

develop
Joerg Boenisch 2016-04-25 10:13:25 +02:00
parent 8f3156e2b2
commit 5c6c645b13
13 changed files with 250 additions and 22 deletions

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 20014-2016 Camadeus GmbH (<http://www.camadeus.at>).
#
# This program is free software: you can redistribute it and/or modify
@ -20,5 +20,7 @@
##############################################################################
import controllers
import report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 20014-2016 Camadeus GmbH (<http://www.camadeus.at>).
#
# This program is free software: you can redistribute it and/or modify
@ -33,7 +33,7 @@ Test Environment
""",
'author': 'camadeus Consulting GmbH',
'website': 'http://www.camadeus.at',
'depends': ['web','base'],
'depends': ['report', 'web', 'base'],
'data': [
'views/cam_testenv.xml',
],

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 20014-2016 Camadeus GmbH (<http://www.camadeus.at>).
#
# This program is free software: you can redistribute it and/or modify

View File

@ -28,28 +28,29 @@ from openerp.addons.web import http
from openerp.addons.web.controllers.main import Home
from openerp.http import request
class Home_Debug(Home):
class Home_Debug(Home):
@http.route('/', type='http', auth="none")
def index(self, s_action=None, db=None, **kw):
# Check arguments
if openerp.tools.config.get('show_debug', False):
return http.local_redirect('/web?debug=1', query=request.params, keep_hash=True)
else:
return http.local_redirect('/web', query=request.params, keep_hash=True)
class WebClient(http.Controller):
_cp_path = "/web/testenv"
@http.jsonrequest
def testmode(self, req, db=False):
def testmode(self, req, db=False):
if not db and req and req.session:
db = req.session._db
if db:
h = req.httprequest.environ['HTTP_HOST'].split(':')[0]
d = h.split('.')[0]
d = h.split('.')[0]
r = openerp.tools.config.get('dbfilter_test', 'test.*').replace('%h', h).replace('%d', d)
try:
pattern_list = eval(r)
@ -57,12 +58,10 @@ class WebClient(http.Controller):
pattern_list = [pattern_list]
except:
pattern_list = [r]
for pattern in pattern_list:
if isinstance(pattern, str) and re.match(pattern, db):
if isinstance(pattern, str) and re.match(pattern, db):
return True
return False
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:

Binary file not shown.

View File

@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
#
# Odoo Extension Module
# Copyright (C) 2014-2016 Camadeus GmbH (<http://www.camadeus.at>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import re
import openerp
from openerp import models
import logging
_logger = logging.getLogger(__name__)
class Report(models.Model):
_inherit = "report"
def render(self, cr, uid, ids, template, values=None, context=None):
testmode = {'testmode': False}
r = openerp.tools.config.get('dbfilter_test', 'test.*')
try:
pattern_list = eval(r)
if not hasattr(pattern_list, '__iter__'):
pattern_list = [pattern_list]
except:
pattern_list = [r]
for pattern in pattern_list:
if isinstance(pattern, str) and re.match(pattern, cr.dbname):
testmode = {'testmode': True}
_logger.info('testmode enabled for reports')
if not values:
values = {}
values.update(testmode)
return super(Report, self).render(cr, uid, ids, template, values, context)

View File

@ -1,10 +1,20 @@
.test-mode-activated {
background-size: cover;
background-attachment: fixed;
.test-mode-activated .oe_view_manager_wrapper {
background-image: url("/cam_testenv/static/src/img/back-testenv.jpg");
background-size: cover;
background-attachment: fixed;
}
.test-mode-activated .oe_view_manager_body,
.test-mode-activated .oe_view_manager_wrapper > * {
opacity: 0.9;
background: rgba(255,255,255,.8) !important;
}
.test-mode-activated .oe_list_field {
opacity: 1;
}
.test-mode-activated .oe_leftbar > * ,
.test-mode-activated .oe_view_manager_header > *{
background: lightblue;
}
.test-mode-activated > * {
opacity: 0.9;
background-color: rgba(0,0,0,0);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="210mm"
height="297mm"
viewBox="0 0 744.09448819 1052.3622047"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="print_test.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.35"
inkscape:cx="-320.71429"
inkscape:cy="634.28571"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:snap-text-baseline="false"
inkscape:window-width="1863"
inkscape:window-height="1176"
inkscape:window-x="57"
inkscape:window-y="24"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1">
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:334.50509644px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:0.20114942;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
x="-541.57294"
y="739.65405"
id="text3336"
sodipodi:linespacing="125%"
transform="matrix(0.57726416,-0.80650188,0.81188871,0.59801083,0,0)"><tspan
sodipodi:role="line"
id="tspan3338"
x="-541.57294"
y="739.65405">Test</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="200mm"
height="234mm"
viewBox="0 0 708.66142 829.13385"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="print_test_n.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.35"
inkscape:cx="-320.71429"
inkscape:cy="634.28571"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:snap-text-baseline="false"
inkscape:window-width="1863"
inkscape:window-height="1176"
inkscape:window-x="57"
inkscape:window-y="24"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-223.22835)">
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:252.86198425px;line-height:125%;font-family:'Arial Black';-inkscape-font-specification:'Arial Black, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#dddddf;fill-opacity:0.94117647;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="-639.02655"
y="739.08575"
id="text3336"
sodipodi:linespacing="125%"
transform="matrix(0.55246707,-0.84270113,0.77701305,0.62485212,0,0)"><tspan
sodipodi:role="line"
id="tspan3338"
x="-639.02655"
y="739.08575">TEST</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -21,7 +21,7 @@ openerp.cam_testenv = function (openerp) {
// (should not change, but just in case...)
if (result) {
$("body").addClass("test-mode-activated");
$("body").css("background-image", "url(" + openerp.session.origin + "/cam_testenv/static/src/img/back-testenv.jpg" + ")");
// $("body").css("background-image", "url(" + openerp.session.origin + "/cam_testenv/static/src/img/back-testenv.jpg" + ")");
}
});
});

View File

@ -9,5 +9,34 @@
<script type="text/javascript" src="/cam_testenv/static/src/js/testenv.js"></script>
</xpath>
</template>
<template id="report.style">
body {
color: #000 !important;
word-wrap: break-word;
}
.border-black td {
border-top: 1px solid black !important;
}
.table-condensed > thead > tr > th {
border-bottom: 1px solid black !important;
}
.table-condensed > tbody > tr {
page-break-inside: avoid !important;
}
.zero_min_height {
min-height: 0px !important;
}
<t t-if="testmode">
div.page {
background-image: url("/cam_testenv/static/src/img/print_test_n.svg") !important;
background-repeat: repeat-y;
background-size: contain;
background-position: center center;
min-height: 234mm;
}
</t>
</template>
</data>
</openerp>