From 021e055ad68248b59c991eeec077e3d07ee6e7a2 Mon Sep 17 00:00:00 2001 From: dochse Date: Thu, 16 Nov 2017 10:04:42 +0100 Subject: [PATCH 1/8] Update nl.po --- orbeon/i18n/nl.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orbeon/i18n/nl.po b/orbeon/i18n/nl.po index c14c3d3..9c41f6e 100644 --- a/orbeon/i18n/nl.po +++ b/orbeon/i18n/nl.po @@ -501,7 +501,7 @@ msgstr "Start persistence" #: model:ir.model.fields,field_description:orbeon.field_orbeon_builder_state #: model:ir.model.fields,field_description:orbeon.field_orbeon_runner_state msgid "State" -msgstr "Staat / Provincie" +msgstr "Status" #. module: orbeon #: model:ir.ui.view,arch_db:orbeon.orbeon_server_form From 3753276948627df3badcb188ef8edc8f5425b608 Mon Sep 17 00:00:00 2001 From: Stefaan Date: Thu, 23 Nov 2017 16:47:56 +0100 Subject: [PATCH 2/8] Added orbeon_report_qweb run report functionality --- .gitignore | 1 + orbeon_report_qweb/__manifest__.py | 2 + orbeon_report_qweb/models/__init__.py | 2 + .../models/orbeon_report_qweb_chooser.py | 43 ++++++++++++ orbeon_report_qweb/models/orbeon_runner.py | 68 +++++++++++++++++++ .../views/orbeon_builder_report_xml.xml | 16 +++++ orbeon_report_qweb/views/orbeon_runner.xml | 23 +++++++ .../views/qweb_report_chooser.xml | 20 ++++++ 8 files changed, 175 insertions(+) create mode 100644 orbeon_report_qweb/models/orbeon_report_qweb_chooser.py create mode 100644 orbeon_report_qweb/models/orbeon_runner.py create mode 100644 orbeon_report_qweb/views/orbeon_builder_report_xml.xml create mode 100644 orbeon_report_qweb/views/orbeon_runner.xml create mode 100644 orbeon_report_qweb/views/qweb_report_chooser.xml diff --git a/.gitignore b/.gitignore index ea202dc..0286a10 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ orbeon/services/persistence_server/*.cfg +*.pyc diff --git a/orbeon_report_qweb/__manifest__.py b/orbeon_report_qweb/__manifest__.py index 931f246..667675b 100644 --- a/orbeon_report_qweb/__manifest__.py +++ b/orbeon_report_qweb/__manifest__.py @@ -32,6 +32,8 @@ "views/ir_actions_report_xml.xml", "views/orbeon_builder.xml", "views/orbeon_runner.xml", + "views/qweb_report_chooser.xml", + "views/orbeon_builder_report_xml.xml" ], "application": False, "installable": True, diff --git a/orbeon_report_qweb/models/__init__.py b/orbeon_report_qweb/models/__init__.py index d455824..4bab872 100644 --- a/orbeon_report_qweb/models/__init__.py +++ b/orbeon_report_qweb/models/__init__.py @@ -21,3 +21,5 @@ from . import ir_actions_report_xml from . import orbeon_builder_report_xml from . import orbeon_builder +from . import orbeon_runner +from . import orbeon_report_qweb_chooser \ No newline at end of file diff --git a/orbeon_report_qweb/models/orbeon_report_qweb_chooser.py b/orbeon_report_qweb/models/orbeon_report_qweb_chooser.py new file mode 100644 index 0000000..7c42f58 --- /dev/null +++ b/orbeon_report_qweb/models/orbeon_report_qweb_chooser.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# open2bizz +# Copyright (C) 2017 open2bizz (open2bizz.nl). +# +# 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 . +# +############################################################################## +from odoo import fields, models, _, api, osv +from openerp.exceptions import Warning + + +import logging + +_logger = logging.getLogger(__name__) + + +class OrbeonReportQwebChooser(models.TransientModel): + _name = 'orbeon.report.qweb.chooser' + _description = "Choose QWEB report" + + report_xml_id = fields.Many2one( + 'ir.actions.report.xml', + string="Reports" + ) + + def run_report(self, context={}): + rep = self.env['orbeon.runner'].browse(context.get('orbeon_runner_id')) + return rep[0].run_qweb_report(self.report_xml_id.id) + + diff --git a/orbeon_report_qweb/models/orbeon_runner.py b/orbeon_report_qweb/models/orbeon_runner.py new file mode 100644 index 0000000..ba4dbcc --- /dev/null +++ b/orbeon_report_qweb/models/orbeon_runner.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# open2bizz +# Copyright (C) 2017 open2bizz (open2bizz.nl). +# +# 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 . +# +############################################################################## +from odoo import fields, models, _, api, osv +from openerp.exceptions import Warning + + +import logging + +_logger = logging.getLogger(__name__) + + +class OrbeonRunner(models.Model): + _inherit = ['orbeon.runner'] + + def run_qweb_report(self, report_id): + rep = self.env['ir.actions.report.xml'].browse(report_id) + data = { + 'ids': [self.id], + 'model': 'orbeon.runner', + 'form': [self.id], + 'context':{} + } + return { + 'type' : 'ir.actions.report.xml', + 'report_name' : rep.report_name, + 'datas' : data, + } + + + + @api.multi + def report_button(self, context=None): + if self.builder_id.report_xml_ids: + if len(self.builder_id.report_xml_ids) > 1: + ids = [rec.ir_actions_report_xml_id.id for rec in self.builder_id.report_xml_ids ] + context.update({ 'rep_ids' : ids, 'orbeon_runner_id' : self.id }) + return { + 'name': 'Choose report', + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'orbeon.report.qweb.chooser', + 'type': 'ir.actions.act_window', + 'target': 'new', + 'context': context + } + else: + return self.run_qweb_report(self.builder_id.report_xml_ids[0].ir_actions_report_xml_id.id ) + + + diff --git a/orbeon_report_qweb/views/orbeon_builder_report_xml.xml b/orbeon_report_qweb/views/orbeon_builder_report_xml.xml new file mode 100644 index 0000000..fe88a9e --- /dev/null +++ b/orbeon_report_qweb/views/orbeon_builder_report_xml.xml @@ -0,0 +1,16 @@ + + + + orbeon.builder.report.xml.form + orbeon.builder.report.xml + form + +
+ + + + +
+
+
+
diff --git a/orbeon_report_qweb/views/orbeon_runner.xml b/orbeon_report_qweb/views/orbeon_runner.xml new file mode 100644 index 0000000..fed0461 --- /dev/null +++ b/orbeon_report_qweb/views/orbeon_runner.xml @@ -0,0 +1,23 @@ + + + + + + orbeon.runner_form.kanban + orbeon.runner + + + + + + + + + + + + + + + + diff --git a/orbeon_report_qweb/views/qweb_report_chooser.xml b/orbeon_report_qweb/views/qweb_report_chooser.xml new file mode 100644 index 0000000..516aab0 --- /dev/null +++ b/orbeon_report_qweb/views/qweb_report_chooser.xml @@ -0,0 +1,20 @@ + + + + orbeon.report.qweb.report.chooser.form + orbeon.report.qweb.chooser + form + +
+ + + +
+
+ +
+
+
+
From 7144bbe2a972437df97f51cec9584eafc87ee97d Mon Sep 17 00:00:00 2001 From: Stefaan Date: Fri, 24 Nov 2017 10:26:07 +0100 Subject: [PATCH 3/8] Do not show button when no reports are available --- orbeon_report_qweb/models/orbeon_runner.py | 9 +++++++++ orbeon_report_qweb/views/orbeon_runner.xml | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/orbeon_report_qweb/models/orbeon_runner.py b/orbeon_report_qweb/models/orbeon_runner.py index ba4dbcc..29639a6 100644 --- a/orbeon_report_qweb/models/orbeon_runner.py +++ b/orbeon_report_qweb/models/orbeon_runner.py @@ -29,6 +29,15 @@ class OrbeonRunner(models.Model): _inherit = ['orbeon.runner'] + + builder_reports_count = fields.Integer( + compute='_builder_reports_count', + string='Builder reports count' + ) + + @api.one + def _builder_reports_count(self): + self.builder_reports_count = len(self.builder_id.report_xml_ids) def run_qweb_report(self, report_id): rep = self.env['ir.actions.report.xml'].browse(report_id) diff --git a/orbeon_report_qweb/views/orbeon_runner.xml b/orbeon_report_qweb/views/orbeon_runner.xml index fed0461..cd8d3ac 100644 --- a/orbeon_report_qweb/views/orbeon_runner.xml +++ b/orbeon_report_qweb/views/orbeon_runner.xml @@ -10,8 +10,10 @@ + + - + From 55121941cf18cf5732b354c1df7d87d249d5d651 Mon Sep 17 00:00:00 2001 From: Stefaan Date: Wed, 29 Nov 2017 11:06:16 +0100 Subject: [PATCH 4/8] Fix PDF not working --- orbeon/models/orbeon_runner.py | 3 ++- .../persistence_server/orbeon_handlers.py | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/orbeon/models/orbeon_runner.py b/orbeon/models/orbeon_runner.py index cd6b229..fb7990f 100644 --- a/orbeon/models/orbeon_runner.py +++ b/orbeon/models/orbeon_runner.py @@ -134,7 +134,8 @@ def _get_url(self): return rec.url server_url = rec.builder_id.server_id.url - base_path = 'fr/orbeon/runner' + #base_path = 'fr/orbeon/runner' + base_path = 'fr/b!%s!%s/runner' % (rec.builder_id.id, rec.id) base_url = "%s/%s" % (server_url, base_path) if isinstance(rec.id, models.NewId): diff --git a/orbeon/services/persistence_server/orbeon_handlers.py b/orbeon/services/persistence_server/orbeon_handlers.py index 09b9b0d..d117997 100644 --- a/orbeon/services/persistence_server/orbeon_handlers.py +++ b/orbeon/services/persistence_server/orbeon_handlers.py @@ -181,19 +181,23 @@ def __init__(self, app, form, data_type, path=(), args={}, data=None): super(RunnerHandler, self).__init__(app, form, data_type, path, args, data) self.model = 'orbeon.runner' - self.form_doc_id = path[5] if len(path) > 5 else None + self.form_doc_id = path[2].split('!')[2] self.form_data_id = path[6] if len(path) > 6 else None def read(self): """Get Orbeon-Runner data by read (i.e. HTTP GET)""" if self.data_type == 'form': - # Builder form data (definition) - form_doc_id = self.args.get('document') - record = self.xmlrpc.runner_search_read_builder( - [[("id", "=", form_doc_id)]], - ["xml"], - ) + if not self.args.get('document'): + record = self.xmlrpc.runner_search_read_data( + [[("id", "=", self.form_doc_id)]], + ["xml"], + ) + else: + record = self.xmlrpc.runner_search_read_builder( + [[("id", "=", self.form_doc_id)]], + ["xml"], + ) return record.get("xml") elif self.data_type == 'data' and self.form_data_id == 'data.xml': # Runner form data From 28bd80cef7e8c45040963a8fe93edee1e6cd259d Mon Sep 17 00:00:00 2001 From: Stefaan Date: Wed, 6 Dec 2017 14:27:48 +0100 Subject: [PATCH 5/8] Fix problem with no layout in PDF --- .../persistence_server/orbeon_handlers.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/orbeon/services/persistence_server/orbeon_handlers.py b/orbeon/services/persistence_server/orbeon_handlers.py index d117997..1b4e9db 100644 --- a/orbeon/services/persistence_server/orbeon_handlers.py +++ b/orbeon/services/persistence_server/orbeon_handlers.py @@ -186,18 +186,11 @@ def __init__(self, app, form, data_type, path=(), args={}, data=None): def read(self): """Get Orbeon-Runner data by read (i.e. HTTP GET)""" - if self.data_type == 'form': - if not self.args.get('document'): - record = self.xmlrpc.runner_search_read_data( - [[("id", "=", self.form_doc_id)]], - ["xml"], - ) - else: - record = self.xmlrpc.runner_search_read_builder( - [[("id", "=", self.form_doc_id)]], - ["xml"], - ) + record = self.xmlrpc.runner_search_read_builder( + [[("id", "=", self.form_doc_id)]], + ["xml"], + ) return record.get("xml") elif self.data_type == 'data' and self.form_data_id == 'data.xml': # Runner form data From 03efacf35e86dbd85f941c316f7d5f3da87c88c8 Mon Sep 17 00:00:00 2001 From: Stefaan Date: Tue, 12 Dec 2017 19:32:46 +0100 Subject: [PATCH 6/8] Add Single Signon, Odoo acts as proxy to Orbeon --- orbeon/__init__.py | 1 + orbeon/controllers/__init__.py | 21 ++++++++++ orbeon/controllers/orbeon.py | 69 +++++++++++++++++++++++++++++++++ orbeon/models/orbeon_builder.py | 2 +- orbeon/models/orbeon_runner.py | 4 +- orbeon/models/orbeon_server.py | 15 +------ orbeon/views/orbeon_server.xml | 1 - 7 files changed, 94 insertions(+), 19 deletions(-) create mode 100644 orbeon/controllers/__init__.py create mode 100644 orbeon/controllers/orbeon.py diff --git a/orbeon/__init__.py b/orbeon/__init__.py index cfe98f6..1765baf 100644 --- a/orbeon/__init__.py +++ b/orbeon/__init__.py @@ -21,3 +21,4 @@ import models import services import tests +import controllers diff --git a/orbeon/controllers/__init__.py b/orbeon/controllers/__init__.py new file mode 100644 index 0000000..adf71d0 --- /dev/null +++ b/orbeon/controllers/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# open2bizz +# Copyright (C) 2016 open2bizz (open2bizz.nl). +# +# 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 . +# +############################################################################## +from . import orbeon diff --git a/orbeon/controllers/orbeon.py b/orbeon/controllers/orbeon.py new file mode 100644 index 0000000..3582bee --- /dev/null +++ b/orbeon/controllers/orbeon.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +############################################################################## +# Copyright (c) 2016 - Open2bizz +# Author: Open2bizz +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# A copy of the GNU General Public License is available at: +# . +# +############################################################################## +import requests +from urlparse import urlparse +from werkzeug.wrappers import Response +from odoo import http +import base64 +from odoo.tools import config +import logging +logger = logging.getLogger(__name__) + +class Orbeon(http.Controller): + orbeon_base_route = 'orbeon' + + @http.route('/%s/' % orbeon_base_route, type='http', auth="user", csrf=False) + def render_orbeon_page(self, path, redirect=None, **kw): + orbeon_server = http.request.env["orbeon.server"].search_read([], ['url']) + if len(orbeon_server) == 0: + return 'Orbeon server not found' + else : + orbeon_server = orbeon_server[0] + o = urlparse(orbeon_server['url']) + + odoo_session = http.request.session + + orbeon_headers = ['cookie'] + in_headers = { name : value for (name, value) in http.request.httprequest.headers.items() + if name.lower() in orbeon_headers} + + in_headers.update({'Openerp-Server' : 'localhost'}) + in_headers.update({'Openerp-Port' : str(config.get('xmlrpc_port'))}) + in_headers.update({'Openerp-Database' : odoo_session.get('db') }) + in_headers.update({'Authorization' : 'Basic %s' % base64.b64encode("%s:%s" % (odoo_session.get('login'), odoo_session.get('password')) ) } ) + + logger.debug('Calling Orbeon on url %s with header %s' % (o.netloc, in_headers)) + + resp = requests.request( + method=http.request.httprequest.method, + url=http.request.httprequest.url.replace('localhost:%s' % config.get('xmlrpc_port'), o.netloc), + headers=in_headers, + data=http.request.httprequest.get_data(), + #cookies=http.request.httprequest.cookies, + allow_redirects=False) + + excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection' + , 'openerp-server', 'openerp-port', 'openerp-database', 'authorization' ] + headers = [(name, value) for (name, value) in resp.raw.headers.items() + if name.lower() not in excluded_headers] + + response = Response(resp.content, resp.status_code, headers) + return response + \ No newline at end of file diff --git a/orbeon/models/orbeon_builder.py b/orbeon/models/orbeon_builder.py index c846674..4e0d9dd 100644 --- a/orbeon/models/orbeon_builder.py +++ b/orbeon/models/orbeon_builder.py @@ -291,7 +291,7 @@ def _get_url(self): else: builder_id = self.id - builder_url = "%s/%s" % (self.server_id.url, "fr/orbeon/builder") + builder_url = "/orbeon/%s" % ("fr/orbeon/builder") get_mode = {STATE_NEW: 'edit'} url = "%s/%s/%i" % (builder_url, get_mode.get(self.state, 'view'), builder_id) diff --git a/orbeon/models/orbeon_runner.py b/orbeon/models/orbeon_runner.py index fb7990f..f474d45 100644 --- a/orbeon/models/orbeon_runner.py +++ b/orbeon/models/orbeon_runner.py @@ -133,10 +133,8 @@ def _get_url(self): if isinstance(rec.id, models.NewId) and not rec.builder_id.id: return rec.url - server_url = rec.builder_id.server_id.url - #base_path = 'fr/orbeon/runner' base_path = 'fr/b!%s!%s/runner' % (rec.builder_id.id, rec.id) - base_url = "%s/%s" % (server_url, base_path) + base_url = "/orbeon/%s" % (base_path) if isinstance(rec.id, models.NewId): url = "%s/new" % base_url diff --git a/orbeon/models/orbeon_server.py b/orbeon/models/orbeon_server.py index f8bf920..6d86a75 100644 --- a/orbeon/models/orbeon_server.py +++ b/orbeon/models/orbeon_server.py @@ -69,13 +69,9 @@ class OrbeonServer(models.Model): ) url = fields.Char( "URL", + help='URL relative to Odoo server, the Odoo server will open the URL and proxy the response', required=True, ) - summary_url = fields.Char( - "Summary URL", - compute="_set_summary_url", - store=True, - ) description = fields.Text( "Description" ) @@ -138,15 +134,6 @@ def __init__(self, pool, cr): self._autostart_persistence_servers(pool, cr) return res - @api.one - @api.depends("url") - def _set_summary_url(self): - if self.url: - url = "%s/fr/orbeon/builder/summary" % self.url - else: - url = "Enter URL" - self.summary_url = url - @api.constrains("name") def constraint_unique_name(self): cur_record = self.search([("name", "=", self.name)]) diff --git a/orbeon/views/orbeon_server.xml b/orbeon/views/orbeon_server.xml index 89692e7..ed700eb 100644 --- a/orbeon/views/orbeon_server.xml +++ b/orbeon/views/orbeon_server.xml @@ -26,7 +26,6 @@ - From 3d5e09555b79112d5507d2a51e88e1624765b250 Mon Sep 17 00:00:00 2001 From: Stefaan Date: Tue, 12 Dec 2017 20:36:57 +0100 Subject: [PATCH 7/8] Fix problem if web client and odoo not both on localhost --- orbeon/controllers/orbeon.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/orbeon/controllers/orbeon.py b/orbeon/controllers/orbeon.py index 3582bee..8dd0738 100644 --- a/orbeon/controllers/orbeon.py +++ b/orbeon/controllers/orbeon.py @@ -50,10 +50,11 @@ def render_orbeon_page(self, path, redirect=None, **kw): in_headers.update({'Authorization' : 'Basic %s' % base64.b64encode("%s:%s" % (odoo_session.get('login'), odoo_session.get('password')) ) } ) logger.debug('Calling Orbeon on url %s with header %s' % (o.netloc, in_headers)) + curl = urlparse(http.request.httprequest.url)._replace(netloc=o.netloc) resp = requests.request( method=http.request.httprequest.method, - url=http.request.httprequest.url.replace('localhost:%s' % config.get('xmlrpc_port'), o.netloc), + url=curl.geturl(), headers=in_headers, data=http.request.httprequest.get_data(), #cookies=http.request.httprequest.cookies, From d4c621156fb0d740e4bb7f353844e3227d950bc4 Mon Sep 17 00:00:00 2001 From: Stefaan Date: Mon, 18 Dec 2017 15:31:53 +0100 Subject: [PATCH 8/8] Fix open form button on form view --- orbeon/views/orbeon_runner.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orbeon/views/orbeon_runner.xml b/orbeon/views/orbeon_runner.xml index 4dbdd9d..1ccc61c 100644 --- a/orbeon/views/orbeon_runner.xml +++ b/orbeon/views/orbeon_runner.xml @@ -8,7 +8,7 @@
-