[MIG] web_disable_group_export: Migration to 11.0

pull/1775/head
David 2018-07-16 12:07:52 +02:00 committed by Kévin Roche
parent 0a0fb990db
commit e6bd62d9a7
12 changed files with 135 additions and 51 deletions

View File

@ -1,11 +1,30 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
========================
Web Disable Export Group
========================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/11.0/web_disable_export_group
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-11-0/web-11-0-web_disable_export_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/162/11.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
In the standard Odoo the UI option 'Export' that is present in the 'Action' menu
of any list view is always enabled (for every user).
@ -14,22 +33,66 @@ to the Export Data group.
Admin user can always use the export option.
**Table of contents**
Usage
=====
.. contents::
:local:
Configuration
=============
Enable the group "Export Data group" to the users who are allowed to
make use of the option 'Export'.
Usage
=====
Every user without *Export Data* permission won't have the option available.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/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 <https://github.com/OCA/web/issues/new?body=module:%20web_disable_export_group%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Original code from module web_disable_export by Noviat,
reviewed and modified by Onestein.
Authors
~~~~~~~
* Onestein
* Tecnativa
Contributors
------------
~~~~~~~~~~~~
* `Onestein <https://www.onestein.nl>`_:
* Dennis Sluijk <d.sluijk@onestein.nl>
* Andrea Stirpe <a.stirpe@onestein.nl>
* `Tecnativa <https://www.tecnativa.com>`_:
* David Vidal <david.vidal@tecnativa.com>
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
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/web <https://github.com/OCA/web/tree/11.0/web_disable_export_group>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -1,3 +1 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models

View File

@ -1,15 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Onestein (<http://www.onestein.eu>)
# Copyright 2018 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Web Disable Export Group',
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'license': 'AGPL-3',
'author': 'Onestein',
'website': 'http://www.onestein.eu',
'author': 'Onestein, '
'Tecnativa, '
'Odoo Community Association (OCA)',
'website': 'http://www.github.com/OCA/web',
'category': 'Web',
'depends': ['web'],
'depends': [
'web',
],
'data': [
'security/groups.xml',
'templates/assets.xml',

View File

@ -0,0 +1 @@
from . import ir_http

View File

@ -0,0 +1,18 @@
# Copyright 2018 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
from odoo.http import request
class Http(models.AbstractModel):
_inherit = 'ir.http'
def session_info(self):
res = super(Http, self).session_info()
user = request.env.user
res.update({
'group_export_data': user and user.has_group(
'web_disable_export_group.group_export_data'),
})
return res

View File

@ -0,0 +1,2 @@
Enable the group "Export Data group" to the users who are allowed to
make use of the option 'Export'.

View File

@ -0,0 +1,8 @@
* `Onestein <https://www.onestein.nl>`_:
* Dennis Sluijk <d.sluijk@onestein.nl>
* Andrea Stirpe <a.stirpe@onestein.nl>
* `Tecnativa <https://www.tecnativa.com>`_:
* David Vidal <david.vidal@tecnativa.com>

View File

@ -0,0 +1,7 @@
In the standard Odoo the UI option 'Export' that is present in the 'Action' menu
of any list view is always enabled (for every user).
This module makes the option 'Export' enabled only for the users that belong
to the Export Data group.
Admin user can always use the export option.

View File

@ -0,0 +1 @@
Every user without *Export Data* permission won't have the option available.

View File

@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016 Onestein
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).-->
<odoo>
<record id="group_export_data" model="res.groups">

View File

@ -1,41 +1,21 @@
/* Copyright 2016 Onestein
Copyright 2018 Tecnativa - David Vidal
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */
odoo.define("web_disable_export_group", function(require) {
"use strict";
var core = require("web.core");
var Sidebar = require("web.Sidebar");
var _t = core._t;
var Model = require("web.Model");
var session = require("web.session");
var _t = core._t;
Sidebar.include({
add_items: function(section_code, items) {
var self = this;
var _super = this._super;
if (session.is_superuser) {
_super.apply(this, arguments);
} else {
var model_res_users = new Model("res.users");
model_res_users.call("has_group", ["web_disable_export_group.group_export_data"]).done(function(can_export) {
if (!can_export) {
var export_label = _t("Export");
var new_items = items;
if (section_code === "other") {
new_items = [];
for (var i = 0; i < items.length; i++) {
console.log("items[i]: ", items[i]);
if (items[i]["label"] !== export_label) {
new_items.push(items[i]);
}
}
}
if (new_items.length > 0) {
_super.call(self, section_code, new_items);
}
} else {
_super.call(self, section_code, items);
}
});
}
_addItems: function (sectionCode, items) {
var _items = items;
if (!session.is_superuser && sectionCode === 'other' && items.length && !session.group_export_data) {
_items = _.reject(_items, {label:_t("Export")});
}
this._super(sectionCode, _items);
},
});
});

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016 Onestein
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).-->
<odoo>
<template id="assets_backend" name="web_disable_export_group assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/web_disable_export_group/static/src/js/disable_export_group.js"></script>