diff --git a/base_import_security_group/README.rst b/base_import_security_group/README.rst index febbf1f..120e33c 100644 --- a/base_import_security_group/README.rst +++ b/base_import_security_group/README.rst @@ -1,9 +1,32 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl - :alt: License: AGPL-3 +=================== +Optional CSV import +=================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github + :target: https://github.com/OCA/server-tools/tree/10.0/base_import_security_group + :alt: OCA/server-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-tools-10-0/server-tools-10-0-base_import_security_group + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/149/10.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| =============================================== -Group-based permissions for importing CSV files +Group-based permissions for importing CSV files =============================================== This module makes importing data from CSV and Excel files optional for each user, @@ -12,51 +35,49 @@ Any other user not belonging to such group will not have the "Import" button available anywhere. The action will even be blocked internally (to prevent XMLRPC access, for example). -Usage -===== +**Table of contents** -To allow a user to import data from CSV and Excel files, just follow this steps: - -* Go to *Settings/Users/Users* menu. -* Enter the user you want to allow. -* Within the "Access Rights" tab and "Technical Settings" group, check the - option "Allow importing CSV/Excel files". +.. contents:: + :local: Bug Tracker =========== -Bugs are tracked on `GitHub Issues -`_. In case of trouble, please -check there if your issue has already been reported. If you spotted it first, -help us smash it by providing detailed and welcomed feedback. +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* Alejandro Santana +* Onestein + Contributors ------------- +~~~~~~~~~~~~ * Alejandro Santana * Antonio Esposito -Do not contact contributors directly about support or help with technical issues. +Maintainers +~~~~~~~~~~~ -Maintainer ----------- +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit https://odoo-community.org. - -Icon ----- +This module is part of the `OCA/server-tools `_ project on GitHub. -Iconic fonts used in module icon are Font Awesome: http://fontawesome.io/ +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_import_security_group/__init__.py b/base_import_security_group/__init__.py index ca88ff9..0e8f3bc 100644 --- a/base_import_security_group/__init__.py +++ b/base_import_security_group/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2015 Anubía, soluciones en la nube,SL (http://www.anubia.es) # Copyright 2017 Onestein (http://www.onestein.eu) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/base_import_security_group/__manifest__.py b/base_import_security_group/__manifest__.py index ad35af7..81d0a4f 100644 --- a/base_import_security_group/__manifest__.py +++ b/base_import_security_group/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2015 Anubía, soluciones en la nube,SL (http://www.anubia.es) # Copyright 2017 Onestein (http://www.onestein.eu) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/base_import_security_group/models/__init__.py b/base_import_security_group/models/__init__.py index ca88ff9..0e8f3bc 100644 --- a/base_import_security_group/models/__init__.py +++ b/base_import_security_group/models/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2015 Anubía, soluciones en la nube,SL (http://www.anubia.es) # Copyright 2017 Onestein (http://www.onestein.eu) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/base_import_security_group/models/models.py b/base_import_security_group/models/models.py index bfef76e..8ff692d 100644 --- a/base_import_security_group/models/models.py +++ b/base_import_security_group/models/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2015 Anubía, soluciones en la nube,SL (http://www.anubia.es) # Copyright 2017 Onestein (http://www.onestein.eu) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). @@ -26,7 +25,7 @@ class Base(models.AbstractModel): raise_if_not_found=False ) if not allowed_group_id or current_user.has_group(allowed_group): - res = super(Base, self).load(fields=fields, data=data) + res = super().load(fields=fields, data=data) else: msg = ('User (ID: %s) is not allowed to import data ' 'in model %s.') % (self.env.uid, self._name) diff --git a/base_import_security_group/readme/CONTRIBUTORS.rst b/base_import_security_group/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..3561fc7 --- /dev/null +++ b/base_import_security_group/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Alejandro Santana +* Antonio Esposito \ No newline at end of file diff --git a/base_import_security_group/readme/DESCRIPTION.rst b/base_import_security_group/readme/DESCRIPTION.rst new file mode 100644 index 0000000..560010a --- /dev/null +++ b/base_import_security_group/readme/DESCRIPTION.rst @@ -0,0 +1,9 @@ +=============================================== +Group-based permissions for importing CSV files +=============================================== + +This module makes importing data from CSV and Excel files optional for each user, +allowing it only for those users belonging to a specific group. +Any other user not belonging to such group will not have the "Import" button +available anywhere. The action will even be blocked internally (to prevent +XMLRPC access, for example). \ No newline at end of file diff --git a/base_import_security_group/static/description/index.html b/base_import_security_group/static/description/index.html new file mode 100644 index 0000000..e2c0361 --- /dev/null +++ b/base_import_security_group/static/description/index.html @@ -0,0 +1,431 @@ + + + + + + +README.rst + + + +
+ + +
+

Optional CSV import

+ +

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runbot

+
+
+

Group-based permissions for importing CSV files

+

This module makes importing data from CSV and Excel files optional for each user, +allowing it only for those users belonging to a specific group. +Any other user not belonging to such group will not have the “Import” button +available anywhere. The action will even be blocked internally (to prevent +XMLRPC access, for example).

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+ +
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/server-tools project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/base_import_security_group/static/src/js/import.js b/base_import_security_group/static/src/js/import.js index 12f043f..f9c95db 100644 --- a/base_import_security_group/static/src/js/import.js +++ b/base_import_security_group/static/src/js/import.js @@ -1,30 +1,42 @@ odoo.define('web.ListImport', function (require) { "use strict"; - var core = require('web.core'); + + var KanbanController = require('web.KanbanController'); + var KanbanView = require('web.KanbanView'); + var ListController = require('web.ListController'); var ListView = require('web.ListView'); - var Model = require('web.Model'); - - ListView.prototype.defaults.import_enabled = false; - ListView.include(/** @lends instance.web.ListView# */{ - - load_list: function (data, grouped) { - - var self = this; - var Users = new Model('res.users'); - - var result = this._super.apply(this, arguments); - Users.call('has_group', ['base_import_security_group.group_import_csv']) - .then(function (result) { - var import_enabled = result; - self.options.import_enabled = import_enabled; - - if (import_enabled === false) { - if (self.$buttons) { - self.$buttons.find('.o_button_import').remove(); - } - } - }); - return result; - } + var session = require('web.session'); + + var ImportViewMixin = { + + init: function (viewInfo, params) { + + var self = this + var result = self._super.apply(self, arguments); + var base_group = 'base_import_security_group.group_import_csv'; + + session.user_has_group(base_group).then(function (result){ + var importEnabled = false + if (result){ + importEnabled = true; + } + self.controllerParams.importEnabled = importEnabled; + }); + }, + + }; + + ListView.include({ + init: function () { + this._super.apply(this, arguments); + ImportViewMixin.init.apply(this, arguments); + }, + }); + + KanbanView.include({ + init: function () { + this._super.apply(this, arguments); + ImportViewMixin.init.apply(this, arguments); + }, }); }); diff --git a/base_import_security_group/tests/__init__.py b/base_import_security_group/tests/__init__.py index f065a15..d561ac2 100644 --- a/base_import_security_group/tests/__init__.py +++ b/base_import_security_group/tests/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Onestein (http://www.onestein.eu) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/base_import_security_group/tests/test_base_import_security_group.py b/base_import_security_group/tests/test_base_import_security_group.py index 985fe93..d96a372 100644 --- a/base_import_security_group/tests/test_base_import_security_group.py +++ b/base_import_security_group/tests/test_base_import_security_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Onestein (http://www.onestein.eu) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). @@ -8,7 +7,7 @@ from odoo.tests import common class TestImportSecurityGroup(common.HttpCase): def setUp(self): - super(TestImportSecurityGroup, self).setUp() + super().setUp() self.Access = self.env['ir.model.access'] self.user_test = self.env.ref('base.user_demo')