Browse Source

[ADD] web_database_rollback: feedback fixes

pull/51/head
Marcel Cojocaru 6 years ago
parent
commit
a3582df40d
  1. 2
      web_database_rollback/README.rst
  2. 26
      web_database_rollback/controllers/main.py
  3. 37
      web_database_rollback/i18n/web_database_rollback.po
  4. 8
      web_database_rollback/static/src/js/db_rollback.js

2
web_database_rollback/README.rst

@ -15,7 +15,7 @@ The database state will revert to the state prior to pressing Activate button.
The number of Odoo workers has to be 0. The number of Odoo workers has to be 0.
Note that when you press Rollback button, all the chanages done by other users will be lost.
Note that when you press Rollback button, all the changes done by other users will be lost.
Also note that, you always have to press Rollback button at the end of your testing/investigation session. Also note that, you always have to press Rollback button at the end of your testing/investigation session.
When you press the Activate button, the cursor used for accessing the db is test cursor. When you press the Activate button, the cursor used for accessing the db is test cursor.

26
web_database_rollback/controllers/main.py

@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
##############################################################################
# -*- encoding: utf-8 -*-
# #############################################################################
# #
# Authors: Cojocaru Marcel (marcel.cojocaru@gmail.com) # Authors: Cojocaru Marcel (marcel.cojocaru@gmail.com)
# Copyright (c) 2019 Cojocaru Aurelian Marcel PFA # Copyright (c) 2019 Cojocaru Aurelian Marcel PFA
# #
# This program is free software: you can redistribute it and/or modify # 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.
# 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, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -17,30 +17,36 @@
# You should have received a copy of the GNU Affero General Public License # 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/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
##############################################################################
#############################################################################
import openerp import openerp
import openerp.http as http import openerp.http as http
from openerp.http import request from openerp.http import request
import openerp.tools.config as config
from openerp import exceptions, _
class DBRollbackController(http.Controller): class DBRollbackController(http.Controller):
@http.route( @http.route(
'/web_database_rollback/activate', '/web_database_rollback/activate',
type='json', auth='none')
type='json', auth='user')
def activate(self): def activate(self):
if config['workers'] > 0:
raise exceptions.Warning(_('Number of workers in Odoo configuration file should be 0.'))
registry = openerp.modules.registry.RegistryManager.get( registry = openerp.modules.registry.RegistryManager.get(
request.session.db) request.session.db)
if registry.test_cr == None:
if registry.test_cr is None:
registry.enter_test_mode() registry.enter_test_mode()
registry.clear_caches() registry.clear_caches()
@http.route( @http.route(
'/web_database_rollback/rollback', '/web_database_rollback/rollback',
type='json', auth='none')
type='json', auth='user')
def rollback(self): def rollback(self):
registry = openerp.modules.registry.RegistryManager.get( registry = openerp.modules.registry.RegistryManager.get(
request.session.db) request.session.db)
if registry.test_cr != None:
if registry.test_cr is not None:
registry.leave_test_mode() registry.leave_test_mode()
registry.clear_caches() registry.clear_caches()

37
web_database_rollback/i18n/web_database_rollback.po

@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_database_rollback
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-02-16 19:19+0000\n"
"PO-Revision-Date: 2019-02-16 19:19+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: web_database_rollback
#. openerp-web
#: code:addons/web_database_rollback/static/src/xml/db_rollback.xml:7
#, python-format
msgid "Activate"
msgstr ""
#. module: web_database_rollback
#: code:addons/web_database_rollback/controllers/main.py:32
#, python-format
msgid "Number of workers in Odoo configuration file should be 0."
msgstr ""
#. module: web_database_rollback
#. openerp-web
#: code:addons/web_database_rollback/static/src/xml/db_rollback.xml:10
#, python-format
msgid "Rollback"
msgstr ""

8
web_database_rollback/static/src/js/db_rollback.js

@ -14,16 +14,12 @@ openerp.web_database_rollback = function (instance) {
this.$el.show(); this.$el.show();
this.$el.find('.activate').on('click', function(ev) { this.$el.find('.activate').on('click', function(ev) {
self.$el.find('.activate').css("background-color", "green").css("color", "white"); self.$el.find('.activate').css("background-color", "green").css("color", "white");
var func = '/web_database_rollback/activate';
self.rpc(func, {}).done(function(res) {
});
self.rpc('/web_database_rollback/activate', {}).done(function(res) {});
}); });
this.$el.find('.rollback').on('click', function(ev) { this.$el.find('.rollback').on('click', function(ev) {
self.$el.find('.activate').css("background-color", "buttonface").css("color", "#777"); self.$el.find('.activate').css("background-color", "buttonface").css("color", "#777");
var func = '/web_database_rollback/rollback';
self.rpc(func, {}).done(function(res) {
});
self.rpc('/web_database_rollback/rollback', {}).done(function(res) {});
}); });
}, },
}); });

Loading…
Cancel
Save