Skip to content

Commit bd084ea

Browse files
authored
Merge pull request #274 from itpp-labs/14.0-database_expiration
[14.0] database_expiration
2 parents 689f7e7 + 4348fde commit bd084ea

File tree

26 files changed

+394
-0
lines changed

26 files changed

+394
-0
lines changed

database_block/README.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.. image:: https://itpp.dev/images/infinity-readme.png
2+
:alt: Tested and maintained by IT Projects Labs
3+
:target: https://itpp.dev
4+
5+
.. image:: https://img.shields.io/badge/license-MIT-blue.svg
6+
:target: https://opensource.org/licenses/MIT
7+
:alt: License: MIT
8+
9+
==================
10+
Block backend UI
11+
==================
12+
13+
This technical module allows blocking backend access and display the message
14+
15+
In order to do that, dependent module need to override ``ir.http`` 's session_info method and return
16+
dictionary with following keys:
17+
18+
* ``database_block_message`` - the displayed message itself. Can be HTML
19+
* ``database_block_is_warning`` - if true, backend is not blocked, but displayed message is shown as warning (``web_responsive`` must be installed in order for warning to be displayed)
20+
21+
Questions?
22+
==========
23+
24+
To get an assistance on this module contact us by email :arrow_right: help@itpp.dev
25+
26+
Contributors
27+
============
28+
* `Eugene Molotov <https://it-projects.info/team/em230418>`__:
29+
30+
31+
Further information
32+
===================
33+
34+
Odoo Apps Store: https://apps.odoo.com/apps/modules/14.0/database_block/
35+
36+
37+
Notifications on updates: `via Atom <https://github.com/itpp-labs/access-addons/commits/14.0/database_block.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/itpp-labs/access-addons/commits/14.0/database_block.atom>`_
38+
39+
Tested on `Odoo 14.0 <https://github.com/odoo/odoo/commit/829ae7b7e2941b6bb7af73a6d3d78b4ef1abf453>`_

database_block/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

database_block/__manifest__.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2020 Eugene Molotov <https://it-projects.info/team/em230418>
2+
# License MIT (https://opensource.org/licenses/MIT).
3+
4+
{
5+
"name": """Block backend UI""",
6+
"summary": """This technical module allows blocking backend access and display the message""",
7+
"category": "Extra Tools",
8+
"images": [],
9+
"version": "14.0.1.0.0",
10+
"application": False,
11+
"author": "IT-Projects LLC, Eugene Molotov",
12+
"support": "help@itpp.dev",
13+
"website": "https://twitter.com/OdooFree",
14+
"license": "Other OSI approved licence", # MIT
15+
"depends": ["web"],
16+
"external_dependencies": {"python": [], "bin": []},
17+
"data": ["views/assets.xml"],
18+
"demo": [],
19+
"qweb": ["static/src/xml/apps.xml"],
20+
"post_load": None,
21+
"pre_init_hook": None,
22+
"post_init_hook": None,
23+
"uninstall_hook": None,
24+
"auto_install": False,
25+
"installable": True,
26+
}

database_block/doc/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
`1.0.0`
2+
-------
3+
4+
- **Init version**

database_block/doc/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
==================
2+
Block backend UI
3+
==================
4+
5+
Installation
6+
============
7+
8+
* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way

database_block/models/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License MIT (https://opensource.org/licenses/MIT).
2+
3+
from . import ir_http

database_block/models/ir_http.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2020 Eugene Molotov <https://it-projects.info/team/em230418>
2+
# License MIT (https://opensource.org/licenses/MIT).
3+
4+
from odoo import SUPERUSER_ID, models
5+
6+
7+
class IrHttp(models.AbstractModel):
8+
9+
_inherit = "ir.http"
10+
11+
def session_info(self):
12+
res = super(IrHttp, self).session_info()
13+
14+
res["database_block_show_message_in_apps_menu"] = bool(
15+
self.env["ir.module.module"]
16+
.with_user(SUPERUSER_ID)
17+
.search(
18+
[("name", "=", "web_responsive"), ("state", "=", "installed")],
19+
limit=1,
20+
)
21+
)
22+
23+
return res
6.87 KB
Loading
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.dropdown-menu > .database_block_message {
2+
width: 100%;
3+
text-align: center;
4+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* Copyright 2020 Eugene Molotov <https://it-projects.info/team/em230418>
2+
License MIT (https://opensource.org/licenses/MIT). */
3+
odoo.define("database_block.main", function (require) {
4+
"use strict";
5+
6+
var AppsMenu = require("web.AppsMenu");
7+
8+
AppsMenu.include({
9+
start: function () {
10+
this._super.apply(this, arguments);
11+
12+
if (odoo.session_info.database_block_message) {
13+
$(".database_block_message").html(
14+
odoo.session_info.database_block_message
15+
);
16+
17+
if (!odoo.session_info.database_block_is_warning) {
18+
$(".o_action_manager").block({
19+
message: $(".block_ui.database_block_message").html(
20+
odoo.session_info.database_block_message
21+
),
22+
});
23+
$("header").css("z-index", $.blockUI.defaults.baseZ + 20);
24+
}
25+
26+
if (odoo.session_info.database_block_show_message_in_apps_menu) {
27+
$(".dropdown-menu > .database_block_message").show();
28+
}
29+
}
30+
},
31+
});
32+
});

0 commit comments

Comments
 (0)