Skip to content

Commit

Permalink
[11.0][MIG] dbfilter_from_header
Browse files Browse the repository at this point in the history
updates were made in OCA#1137 by @TimLai125

and small lint fixes by @yelizariev

Signed-off-by: Carmen Bianca Bakker <[email protected]>
  • Loading branch information
Ivan Yelizariev authored and remytms committed Oct 29, 2024
1 parent e6d6a96 commit 47ecee6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
3 changes: 2 additions & 1 deletion dbfilter_from_header/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ a server-wide module.
This can be done with the ``load`` parameter in ``/etc/odoo.conf`` or with the
``--load`` command-line parameter

``load = "web, web_kanban, dbfilter_from_header"``
``load = "web, dbfilter_from_header"``

Configuration
=============
Expand Down Expand Up @@ -62,6 +62,7 @@ Contributors
* Sandy Carter <[email protected]>
* Fabio Vilchez <[email protected]>
* Jos De Graeve <[email protected]>
* Lai Tim Siu (Quaritle Limited) <[email protected]>

Maintainer
----------
Expand Down
20 changes: 1 addition & 19 deletions dbfilter_from_header/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,2 @@
# -*- coding: utf-8 -*-
# © 2013 Therp BV
# © 2014 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import re
from odoo import http

db_filter_org = http.db_filter


def db_filter(dbs, httprequest=None):
dbs = db_filter_org(dbs, httprequest)
httprequest = httprequest or http.request.httprequest
db_filter_hdr = httprequest.environ.get('HTTP_X_ODOO_DBFILTER')
if db_filter_hdr:
dbs = [db for db in dbs if re.match(db_filter_hdr, db)]
return dbs

http.db_filter = db_filter
from . import override
4 changes: 2 additions & 2 deletions dbfilter_from_header/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
# © 2013 Therp BV
# © 2014 ACSONE SA/NV
# Copyright 2018 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "dbfilter_from_header",
"summary": "Filter databases with HTTP headers",
"version": "10.0.1.0.0",
"version": "11.0.1.0.0",
"author": "Therp BV,Odoo Community Association (OCA)",
"license": "AGPL-3",
"complexity": "normal",
Expand Down
6 changes: 2 additions & 4 deletions dbfilter_from_header/i18n/dbfilter_from_header.pot
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Translation of OpenERP Server.
# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-03-14 17:40+0000\n"
"PO-Revision-Date: 2014-03-14 17:40+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down
21 changes: 21 additions & 0 deletions dbfilter_from_header/override.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# © 2013 Therp BV
# © 2014 ACSONE SA/NV
# Copyright 2018 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import re
from odoo import http

db_filter_org = http.db_filter


def db_filter(dbs, httprequest=None):
dbs = db_filter_org(dbs, httprequest)
httprequest = httprequest or http.request.httprequest
db_filter_hdr = httprequest.environ.get('HTTP_X_ODOO_DBFILTER')
if db_filter_hdr:
dbs = [db for db in dbs if re.match(db_filter_hdr, db)]
return dbs


http.db_filter = db_filter

0 comments on commit 47ecee6

Please sign in to comment.