[MIG] web_eradicate_duplicate to v10

This commit is contained in:
Alexis de Lattre
2018-02-09 14:54:58 +01:00
parent 953929cc4b
commit 1cae9ca021
3 changed files with 20 additions and 35 deletions

View File

@@ -1,37 +1,20 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Web Eradicate Duplicate module for Odoo
# Copyright (C) 2016 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# Copyright (C) 2016-2018 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Eradicate Duplicate',
'version': '8.0.0.1.0',
'version': '10.0.1.0.0',
'category': 'Tools',
'license': 'AGPL-3',
'summary': 'Remove More > Duplicate for all users except admin',
'summary': 'Remove Action > Duplicate for all users except admin',
'description': '''
Eradicate Duplicate
===================
This module is inspired by the module *web_hide_duplicate* of Aristobulo Meneses available on https://github.com/menecio/odoo-addons. The main difference is that it will remove the *More > Duplicate* button everywhere by default for all users except *admin*.
This module is inspired by the module *web_hide_duplicate* of Aristobulo Meneses available on https://github.com/menecio/odoo-addons (it seems this URL doesn't exist any more, so I don't know where the module is located now). The main difference is that it will remove the *Action > Duplicate* button everywhere by default for all users except *admin*.
It is possible to restore the duplicate feature on some form views by adding an attribute **duplicate_eradicate="false"** (you will find an example in a comment at the end of the file static/src/js/eradicate_duplicate.js).
@@ -41,5 +24,5 @@ This module has been written by Alexis de Lattre from Akretion
'author': 'Akretion',
'depends': ['web'],
'data': ['views/eradicate_duplicate.xml'],
'installable': False,
'installable': True,
}

View File

@@ -3,13 +3,17 @@
Inspired by the module web_hide_duplicate of Aristobulo Meneses
*/
openerp.web_eradicate_duplicate = function (instance) {
var _t = instance.web._t;
odoo.define('web.web_eradicate_duplicate', function(require) {
"use strict";
instance.web.FormView.include({
load_form: function(data) {
this._super(data);
// Remove More > Duplicate button for all users except admin
var core = require('web.core');
var FormView = require('web.FormView');
var _t = core._t;
FormView.include({
render_sidebar: function($node) {
this._super($node);
// Remove Action > Duplicate button for all users except admin
// or except if there is an attribute duplicate_eradicate="false"
// in the form view
if (
@@ -25,7 +29,7 @@ openerp.web_eradicate_duplicate = function (instance) {
}
}
});
};
});
/*

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<template id="assets_backend" name="eradicate_duplicate" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
@@ -8,5 +7,4 @@
</xpath>
</template>
</data>
</openerp>
</odoo>