Marcel Cojocaru
6 years ago
8 changed files with 257 additions and 0 deletions
-
60web_database_rollback/README.rst
-
21web_database_rollback/__init__.py
-
39web_database_rollback/__openerp__.py
-
19web_database_rollback/controllers/__init__.py
-
46web_database_rollback/controllers/main.py
-
45web_database_rollback/static/src/js/db_rollback.js
-
15web_database_rollback/static/src/xml/db_rollback.xml
-
12web_database_rollback/view/db_rollback.xml
@ -0,0 +1,60 @@ |
|||||
|
================================================= |
||||
|
Revert the changes done on the database |
||||
|
================================================= |
||||
|
|
||||
|
This module allows to revert the database state prior to a certain moment chosen by the user. |
||||
|
It is useful when you test something in Odoo and afterwards want to go back to the initial database state. |
||||
|
|
||||
|
Usage |
||||
|
===== |
||||
|
|
||||
|
On the right side of the systray there are two buttons: Activate and Rollback |
||||
|
Press the Activate button (it will turn green), do any changes/actions in odoo (products, pickings, sale orders, etc) and save them. |
||||
|
If you want to undo all the changes, press Rollback button. |
||||
|
The database state will revert to the state prior to pressing Activate button. |
||||
|
|
||||
|
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. |
||||
|
|
||||
|
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. |
||||
|
The Rollback button will revert to the real odoo cursor. So in case the results seen are the ones you expect and want to keep them in the database, you have to press Rollback and do the same actions again in Odoo. |
||||
|
|
||||
|
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 smash it by providing detailed and welcomed feedback. |
||||
|
|
||||
|
Credits |
||||
|
======= |
||||
|
|
||||
|
Images |
||||
|
------ |
||||
|
|
||||
|
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. |
||||
|
|
||||
|
Contributors |
||||
|
------------ |
||||
|
|
||||
|
* Marcel Cojocaru <marcel.cojocaru@gmail.com> |
||||
|
|
||||
|
Do not contact contributors directly about support or help with technical issues. |
||||
|
|
||||
|
Maintainer |
||||
|
---------- |
||||
|
|
||||
|
.. 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. |
@ -0,0 +1,21 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Authors: Cojocaru Marcel (marcel.cojocaru@gmail.com) |
||||
|
# Copyright (c) 2019 Cojocaru Aurelian Marcel PFA |
||||
|
# |
||||
|
# 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/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
from . import controllers |
@ -0,0 +1,39 @@ |
|||||
|
# -*- encoding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Odoo, Open Source Management Solution |
||||
|
# This module copyright (C) 2014 Therp BV (<http://therp.nl>). |
||||
|
# |
||||
|
# 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/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
{ |
||||
|
'name': 'Database Rollback', |
||||
|
'version': '8.0.1.0.0', |
||||
|
'category': 'web', |
||||
|
'author': "Cojocaru Marcel", |
||||
|
'website': '', |
||||
|
'license': 'AGPL-3', |
||||
|
'depends': [ |
||||
|
'web', |
||||
|
], |
||||
|
'data': [ |
||||
|
'view/db_rollback.xml', |
||||
|
], |
||||
|
'qweb': [ |
||||
|
'static/src/xml/db_rollback.xml', |
||||
|
], |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
# -*- encoding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# 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/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
|
||||
|
from . import main |
@ -0,0 +1,46 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Authors: Cojocaru Marcel (marcel.cojocaru@gmail.com) |
||||
|
# Copyright (c) 2019 Cojocaru Aurelian Marcel PFA |
||||
|
# |
||||
|
# 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/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
import openerp |
||||
|
import openerp.http as http |
||||
|
from openerp.http import request |
||||
|
|
||||
|
|
||||
|
class DBRollbackController(http.Controller): |
||||
|
@http.route( |
||||
|
'/web_database_rollback/activate', |
||||
|
type='json', auth='none') |
||||
|
def activate(self): |
||||
|
registry = openerp.modules.registry.RegistryManager.get( |
||||
|
request.session.db) |
||||
|
if registry.test_cr == None: |
||||
|
registry.enter_test_mode() |
||||
|
registry.clear_caches() |
||||
|
|
||||
|
@http.route( |
||||
|
'/web_database_rollback/rollback', |
||||
|
type='json', auth='none') |
||||
|
def rollback(self): |
||||
|
registry = openerp.modules.registry.RegistryManager.get( |
||||
|
request.session.db) |
||||
|
if registry.test_cr != None: |
||||
|
registry.leave_test_mode() |
||||
|
registry.clear_caches() |
||||
|
|
@ -0,0 +1,45 @@ |
|||||
|
// Copyright (C) 2019 Cojocaru Aurelian Marcel PFA
|
||||
|
// @author Marcel Cojocaru <marcel.cojocari@gmail.com>
|
||||
|
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
|
||||
|
openerp.web_database_rollback = function (instance) { |
||||
|
|
||||
|
instance.web_database_rollback.RollbackButtonsWidget = instance.web.Widget.extend({ |
||||
|
|
||||
|
template:'web_database_rollback.ButtonsWidget', |
||||
|
|
||||
|
renderElement: function() { |
||||
|
var self = this; |
||||
|
this._super(); |
||||
|
this.$el.show(); |
||||
|
this.$el.find('.activate').on('click', function(ev) { |
||||
|
self.$el.find('.activate').css("background-color", "green").css("color", "white"); |
||||
|
var func = '/web_database_rollback/activate'; |
||||
|
self.rpc(func, {}).done(function(res) { |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
this.$el.find('.rollback').on('click', function(ev) { |
||||
|
self.$el.find('.activate').css("background-color", "buttonface").css("color", "#777"); |
||||
|
var func = '/web_database_rollback/rollback'; |
||||
|
self.rpc(func, {}).done(function(res) { |
||||
|
}); |
||||
|
}); |
||||
|
}, |
||||
|
}); |
||||
|
|
||||
|
instance.web.UserMenu.include({ |
||||
|
do_update: function () { |
||||
|
this._super(); |
||||
|
var self = this; |
||||
|
this.update_promise.done(function () { |
||||
|
if (!_.isUndefined(self.rollbackButtons)) { |
||||
|
return; |
||||
|
} |
||||
|
self.rollbackButtons = new instance.web_database_rollback.RollbackButtonsWidget(self); |
||||
|
self.rollbackButtons.prependTo(instance.webclient.$('.oe_systray')); |
||||
|
}); |
||||
|
}, |
||||
|
}); |
||||
|
|
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<template> |
||||
|
|
||||
|
<t t-name="web_database_rollback.ButtonsWidget"> |
||||
|
<div> |
||||
|
<button class="activate oe_button" string="Activate" style="width: 60px; height: 15px; font-size: 9px;"> |
||||
|
<span>Activate</span> |
||||
|
</button> |
||||
|
<button class="rollback oe_button" string="Rollback" style="width: 60px; height: 15px; font-size: 9px;"> |
||||
|
<span>Rollback</span> |
||||
|
</button> |
||||
|
</div> |
||||
|
</t> |
||||
|
|
||||
|
</template> |
@ -0,0 +1,12 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<openerp> |
||||
|
<data> |
||||
|
|
||||
|
<template id="assets_backend" name="web_db_rollback assets" inherit_id="web.assets_backend"> |
||||
|
<xpath expr="." position="inside"> |
||||
|
<script type="text/javascript" src="/web_database_rollback/static/src/js/db_rollback.js"></script> |
||||
|
</xpath> |
||||
|
</template> |
||||
|
|
||||
|
</data> |
||||
|
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue