Skip to content

Commit 28c61ac

Browse files
authored
Merge pull request #236 from em230418/13.0-modules_for_saas
commit is created by 👷‍♂️ Merge Bot: https://odoo-devops.readthedocs.io/en/latest/git/github-merge-bot.html
2 parents 5a137a1 + 184b960 commit 28c61ac

File tree

15 files changed

+179
-11
lines changed

15 files changed

+179
-11
lines changed

access_limit_max_users/README.rst

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.. image:: https://img.shields.io/badge/license-MIT-blue.svg
2+
:target: https://opensource.org/licenses/MIT
3+
:alt: License: MIT
4+
5+
=======================
6+
Limit number of users
7+
=======================
8+
9+
With this module you can limit number of users.
10+
11+
This module creates record with external id `access_limit_max_users.max_users_limit`
12+
that defines max amount of users can have current database. By default it is
13+
number of active users at moment of installation of this module.
14+
15+
Credits
16+
=======
17+
18+
Contributors
19+
------------
20+
* `Eugene Molotov <https://it-projects.info/team/em230418>`__:
21+
22+
Sponsors
23+
--------
24+
* `IT-Projects LLC <https://it-projects.info>`__
25+
26+
Maintainers
27+
-----------
28+
* `IT-Projects LLC <https://it-projects.info>`__
29+
30+
To get a guaranteed support
31+
you are kindly requested to purchase the module
32+
at `odoo apps store <https://apps.odoo.com/apps/modules/13.0/access_limit_max_users/>`__.
33+
34+
Thank you for understanding!
35+
36+
`IT-Projects Team <https://www.it-projects.info/team>`__
37+
38+
Further information
39+
===================
40+
41+
Demo: http://runbot.it-projects.info/demo/access-addons/13.0
42+
43+
HTML Description: https://apps.odoo.com/apps/modules/13.0/access_limit_max_users/
44+
45+
Usage instructions: `<doc/index.rst>`_
46+
47+
Changelog: `<doc/changelog.rst>`_
48+
49+
Notifications on updates: `via Atom <https://github.com/it-projects-llc/access-addons/commits/13.0/access_limit_max_users.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/it-projects-llc/access-addons/commits/13.0/access_limit_max_users.atom>`_
50+
51+
Tested on Odoo 13.0 991c3392708946fdf9973d18e8c29469fa21eed9

access_limit_max_users/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from odoo.api import Environment, SUPERUSER_ID
2+
3+
4+
def post_init_hook(cr, registry):
5+
env = Environment(cr, SUPERUSER_ID, {})
6+
env.ref("access_limit_max_users.max_users_limit").max_records = env[
7+
"res.users"
8+
].search_count([])
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2020 Eugene Molotov <https://it-projects.info/team/em230418>
2+
# License MIT (https://opensource.org/licenses/MIT).
3+
4+
{
5+
"name": """Limit number of users""",
6+
"summary": """With this module you can limit number of users""",
7+
"category": "Hidden",
8+
# "live_test_url": "http://apps.it-projects.info/shop/product/DEMO-URL?version=13.0",
9+
"images": [],
10+
"version": "13.0.1.0.0",
11+
"application": False,
12+
"author": "IT-Projects LLC, Eugene Molotov",
13+
"support": "apps@it-projects.info",
14+
"website": "https://apps.odoo.com/apps/modules/13.0/access_limit_max_users/",
15+
"license": "Other OSI approved licence", # MIT
16+
# "price": 9.00,
17+
# "currency": "EUR",
18+
"depends": ["access_limit_records_number"],
19+
"external_dependencies": {"python": [], "bin": []},
20+
"data": ["data/base_limit_records_number.xml"],
21+
"demo": [],
22+
"qweb": [],
23+
"post_load": None,
24+
"pre_init_hook": None,
25+
"post_init_hook": "post_init_hook",
26+
"uninstall_hook": None,
27+
"auto_install": False,
28+
"installable": True,
29+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!-- Copyright 2020 Eugene Molotov <https://it-projects.info/team/em230418>
3+
License MIT (https://opensource.org/licenses/MIT). -->
4+
<odoo>
5+
<record id="max_users_limit" model="base.limit.records_number">
6+
<field name="name">Limit number of users</field>
7+
<field name="model_id" ref="base.model_res_users" />
8+
<field name="max_records" eval="1" />
9+
</record>
10+
</odoo>
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**
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
=======================
2+
Limit number of users
3+
=======================
4+
5+
Installation
6+
============
7+
* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way
8+
9+
Usage
10+
=====
11+
12+
* Open menu ``[[ Settings ]] >> Users & Companies >> Users``
13+
* Click ``[Create]``
14+
* Fill in required fields. Usually they are `Name` and `Email Address`
15+
* RESULT: you will see exception message, that says that you cannot create more records.
4.84 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_base
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2020 Eugene Molotov <https://it-projects.info/team/em230418>
2+
# License MIT (https://opensource.org/licenses/MIT).
3+
from odoo.tests import common
4+
5+
6+
@common.tagged("post_install", "-at_install")
7+
class TestBase(common.TransactionCase):
8+
def test_max_users(self):
9+
admin_user = self.env.ref("base.user_admin")
10+
11+
users_count = self.env["res.users"].sudo().search_count([])
12+
max_users_allowed = self.env.ref(
13+
"access_limit_max_users.max_users_limit"
14+
).max_records
15+
16+
Users = self.env["res.users"].with_user(admin_user)
17+
18+
while users_count < max_users_allowed:
19+
Users.create({"name": "test_max_users_{}".format(users_count)})
20+
users_count += 1
21+
22+
# limit is reached
23+
with self.assertRaises(Exception):
24+
Users.create({"name": "test_max_users_{}".format(users_count)})

access_limit_records_number/README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Maintainers
2828
-----------
2929
* `IT-Projects LLC <https://it-projects.info>`__
3030

31-
To get a guaranteed support you are kindly requested to purchase the module at `odoo apps store <https://apps.odoo.com/apps/modules/11.0/access_limit_records_number/>`__.
31+
To get a guaranteed support you are kindly requested to purchase the module at `odoo apps store <https://apps.odoo.com/apps/modules/13.0/access_limit_records_number/>`__.
3232

3333
Thank you for understanding!
3434

@@ -37,12 +37,12 @@ Maintainers
3737
Further information
3838
===================
3939

40-
Demo: http://runbot.it-projects.info/demo/access-addons/11.0
40+
Demo: http://runbot.it-projects.info/demo/access-addons/13.0
4141

42-
HTML Description: https://apps.odoo.com/apps/modules/11.0/access_limit_records_number/
42+
HTML Description: https://apps.odoo.com/apps/modules/13.0/access_limit_records_number/
4343

4444
Usage instructions: `<doc/index.rst>`_
4545

4646
Changelog: `<doc/changelog.rst>`_
4747

48-
Tested on Odoo 11.0 cc031bd2264a7fcd8efbc9105902574111859c8b
48+
Tested on Odoo 13.0 991c3392708946fdf9973d18e8c29469fa21eed9

0 commit comments

Comments
 (0)