@ -0,0 +1,141 @@ |
|||||
|
# Odoo Undo Redo |
||||
|
|
||||
|
[](https://www.odoo.com) |
||||
|
[](https://opensource.org/licenses/MIT) |
||||
|
[] |
||||
|
|
||||
|
## Overview |
||||
|
|
||||
|
Odoo Undo Redo is an open-source module which enables Undo/Redo globally across Odoo. |
||||
|
|
||||
|
|
||||
|
## Features |
||||
|
|
||||
|
- 🌐 **Track and Revert Changes made to Records Automatically using PostgreSQL Triggers. |
||||
|
- 📏 **Undo and Redo Operations Available Instantly From the Form View. |
||||
|
|
||||
|
## Screenshots |
||||
|
|
||||
|
Here are some glimpses of Odoo Undo Redo in action: |
||||
|
|
||||
|
### 1. Contacts module |
||||
|
|
||||
|
<div> |
||||
|
<tr> |
||||
|
<td align="center"> |
||||
|
<img src="static/description/assets/screenshots/1.png" alt="Feature 1" width="500" style="border: none;"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</div> |
||||
|
<div> |
||||
|
<tr> |
||||
|
<td align="center"> |
||||
|
<img src="static/description/assets/screenshots/2.png" alt="Feature 1" width="500" style="border: none;"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</div> |
||||
|
<div> |
||||
|
<tr> |
||||
|
<td align="center"> |
||||
|
<img src="static/description/assets/screenshots/3.png" alt="Feature 1" width="500" style="border: none;"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</div> |
||||
|
<div> |
||||
|
<tr> |
||||
|
<td align="center"> |
||||
|
<img src="static/description/assets/screenshots/4.png" alt="Feature 1" width="500" style="border: none;"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</div> |
||||
|
<div> |
||||
|
<tr> |
||||
|
<td align="center"> |
||||
|
<img src="static/description/assets/screenshots/5.png" alt="Feature 1" width="500" style="border: none;"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</div> |
||||
|
|
||||
|
### 2. Sales module |
||||
|
|
||||
|
<div> |
||||
|
<tr> |
||||
|
<td align="center"> |
||||
|
<img src="static/description/assets/screenshots/6.png" alt="Feature 1" width="500" style="border: none;"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</div> |
||||
|
<div> |
||||
|
<tr> |
||||
|
<td align="center"> |
||||
|
<img src="static/description/assets/screenshots/7.png" alt="Feature 1" width="500" style="border: none;"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</div> |
||||
|
<div> |
||||
|
<tr> |
||||
|
<td align="center"> |
||||
|
<img src="static/description/assets/screenshots/8.png" alt="Feature 1" width="500" style="border: none;"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</div> |
||||
|
|
||||
|
## Configuration |
||||
|
|
||||
|
* No additional configurations needed. |
||||
|
|
||||
|
## Installation |
||||
|
|
||||
|
Follow these steps to set up and run the app: |
||||
|
|
||||
|
1. **Clone the Repository** |
||||
|
```bash |
||||
|
git clone https://github.com/cybrosystech/Odoo-Undo-Redo.git |
||||
|
cd Odoo-Undo-Redo |
||||
|
|
||||
|
## Contributing |
||||
|
|
||||
|
We welcome contributions! Undo and Redo for one2many records is in progress. |
||||
|
If you're interested, feel free to contribute and enhance this functionality. To get started: |
||||
|
|
||||
|
1. Fork the repository. |
||||
|
|
||||
|
2. Create a new branch: |
||||
|
``` |
||||
|
git checkout -b feature/your-feature-name |
||||
|
``` |
||||
|
3. Make changes and commit: |
||||
|
``` |
||||
|
git commit -m "Add your message here" |
||||
|
``` |
||||
|
4. Push your changes: |
||||
|
``` |
||||
|
git push origin feature/your-feature-name |
||||
|
``` |
||||
|
5. Create a Pull Request on GitHub. |
||||
|
|
||||
|
--- |
||||
|
- Submit a pull request with a clear description of your changes. |
||||
|
|
||||
|
## License |
||||
|
|
||||
|
This project is licensed under the AGPL-3. Feel free to use, modify, and distribute it as needed. |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>` |
||||
|
|
||||
|
## Contact |
||||
|
|
||||
|
* Mail Contact : odoo@cybrosys.com |
||||
|
* Website : https://cybrosys.com |
||||
|
|
||||
|
|
||||
|
Maintainer |
||||
|
========== |
||||
|
 |
||||
|
https://cybrosys.com |
||||
|
|
||||
|
|
||||
|
This module is maintained by Cybrosys Technologies. |
||||
|
For support and more information, please visit https://www.cybrosys.com |
||||
@ -0,0 +1,23 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# 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 (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from . import models |
||||
|
from .hooks import post_init_hook, uninstall_hook |
||||
@ -0,0 +1,53 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# 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 (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
{ |
||||
|
'name': 'Undo and Redo', |
||||
|
'version': '18.0.1.0.0', |
||||
|
'category': 'Tools', |
||||
|
'summary': 'Module for undo and redo in Odoo', |
||||
|
'description': """This module adds global undo and |
||||
|
redo support in Odoo, letting users easily revert |
||||
|
or restore changes and deletions across all records |
||||
|
except one2many records.""", |
||||
|
'sequence': -333, |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': 'https://www.cybrosys.com', |
||||
|
'depends': ['web'], |
||||
|
'data': [ |
||||
|
'security/ir.model.access.csv', |
||||
|
], |
||||
|
'assets': { |
||||
|
'web.assets_backend': [ |
||||
|
'undo_redo/static/src/js/undo_redo.js', |
||||
|
'undo_redo/static/src/xml/formrenderer.xml', |
||||
|
], |
||||
|
}, |
||||
|
'post_init_hook': 'post_init_hook', |
||||
|
'uninstall_hook': 'uninstall_hook', |
||||
|
'images': ['static/description/banner.jpg'], |
||||
|
'license': 'AGPL-3', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
## Module <undo_redo> |
||||
|
|
||||
|
#### 03.12.2025 |
||||
|
#### Version 18.0.1.0.0 |
||||
|
##### ADD |
||||
|
|
||||
|
- Initial Commit for Undo And Redo |
||||
@ -0,0 +1,277 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# 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 (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
def post_init_hook(env): |
||||
|
|
||||
|
env.cr.execute(""" |
||||
|
CREATE OR REPLACE FUNCTION log_update_data() |
||||
|
RETURNS TRIGGER AS $$ |
||||
|
DECLARE |
||||
|
changed_fields JSONB = '{}'::JSONB; |
||||
|
old_row JSONB; |
||||
|
new_row JSONB; |
||||
|
column_name TEXT; |
||||
|
BEGIN |
||||
|
old_row = to_jsonb(OLD); |
||||
|
new_row = to_jsonb(NEW); |
||||
|
|
||||
|
FOR column_name IN SELECT jsonb_object_keys(old_row) |
||||
|
LOOP |
||||
|
IF old_row ->> column_name IS DISTINCT FROM new_row ->> column_name THEN |
||||
|
changed_fields = jsonb_set( |
||||
|
changed_fields, |
||||
|
array[column_name], |
||||
|
old_row -> column_name |
||||
|
); |
||||
|
END IF; |
||||
|
END LOOP; |
||||
|
|
||||
|
IF jsonb_typeof(changed_fields) != 'null' AND changed_fields != '{}'::JSONB THEN |
||||
|
BEGIN |
||||
|
INSERT INTO undo_redo (user_id, |
||||
|
table_name, |
||||
|
record_id, |
||||
|
updated_data,mode |
||||
|
) |
||||
|
VALUES ( |
||||
|
OLD.write_uid, |
||||
|
TG_TABLE_NAME, |
||||
|
OLD.id, |
||||
|
changed_fields,'undo' |
||||
|
); |
||||
|
EXCEPTION WHEN OTHERS THEN |
||||
|
RETURN NEW; |
||||
|
END; |
||||
|
END IF; |
||||
|
|
||||
|
RETURN NEW; |
||||
|
END; |
||||
|
$$ LANGUAGE plpgsql; |
||||
|
""") |
||||
|
env.cr.execute(""" |
||||
|
CREATE OR REPLACE FUNCTION log_delete_data() |
||||
|
RETURNS TRIGGER AS $$ |
||||
|
BEGIN |
||||
|
DELETE FROM undo_redo |
||||
|
WHERE record_id = OLD.id |
||||
|
AND table_name = TG_TABLE_NAME; |
||||
|
RETURN OLD; |
||||
|
END; |
||||
|
$$ LANGUAGE plpgsql; |
||||
|
""") |
||||
|
env.cr.execute(""" |
||||
|
DO $$ |
||||
|
DECLARE |
||||
|
rec RECORD; |
||||
|
BEGIN |
||||
|
FOR rec IN |
||||
|
SELECT n.nspname, c.relname |
||||
|
FROM pg_class c |
||||
|
JOIN pg_namespace n ON c.relnamespace = n.oid |
||||
|
WHERE c.relkind = 'r' |
||||
|
AND n.nspname NOT IN ('pg_catalog', 'information_schema') AND c.relname != 'undo_redo' |
||||
|
AND EXISTS ( |
||||
|
SELECT 1 |
||||
|
FROM information_schema.columns |
||||
|
WHERE table_schema = n.nspname |
||||
|
AND table_name = c.relname |
||||
|
AND column_name = 'id' |
||||
|
) |
||||
|
LOOP |
||||
|
EXECUTE format(' |
||||
|
CREATE TRIGGER capture_delete_dynamic |
||||
|
AFTER UPDATE ON %I.%I |
||||
|
FOR EACH ROW |
||||
|
EXECUTE FUNCTION log_update_data();', rec.nspname, rec.relname); |
||||
|
EXECUTE format(' |
||||
|
CREATE TRIGGER log_delete_trigger |
||||
|
AFTER DELETE ON %I.%I |
||||
|
FOR EACH ROW |
||||
|
EXECUTE FUNCTION log_delete_data();', |
||||
|
rec.nspname, rec.relname); |
||||
|
|
||||
|
END LOOP; |
||||
|
END $$; |
||||
|
""") |
||||
|
env.cr.execute(""" |
||||
|
CREATE OR REPLACE FUNCTION add_update_trigger_to_new_tables() |
||||
|
RETURNS VOID AS $$ |
||||
|
DECLARE |
||||
|
rec RECORD; |
||||
|
BEGIN |
||||
|
FOR rec IN |
||||
|
SELECT n.nspname, c.relname |
||||
|
FROM pg_class c |
||||
|
JOIN pg_namespace n ON c.relnamespace = n.oid |
||||
|
WHERE c.relkind = 'r' |
||||
|
AND n.nspname NOT IN ('pg_catalog', 'information_schema') |
||||
|
AND EXISTS ( |
||||
|
SELECT 1 |
||||
|
FROM information_schema.columns |
||||
|
WHERE table_schema = n.nspname |
||||
|
AND table_name = c.relname |
||||
|
AND column_name = 'id' |
||||
|
) |
||||
|
LOOP |
||||
|
IF NOT EXISTS ( |
||||
|
SELECT 1 |
||||
|
FROM pg_trigger |
||||
|
WHERE tgrelid = (SELECT oid FROM pg_class WHERE relname = rec.relname AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = rec.nspname)) |
||||
|
AND tgname = 'capture_delete_dynamic' |
||||
|
) THEN |
||||
|
IF rec.relname != 'undo_redo' THEN |
||||
|
EXECUTE format(' |
||||
|
CREATE TRIGGER capture_delete_dynamic |
||||
|
AFTER UPDATE ON %I.%I |
||||
|
FOR EACH ROW |
||||
|
EXECUTE FUNCTION log_update_data();', rec.nspname, rec.relname); |
||||
|
EXECUTE format(' |
||||
|
CREATE TRIGGER log_delete_trigger |
||||
|
AFTER DELETE ON %I.%I |
||||
|
FOR EACH ROW |
||||
|
EXECUTE FUNCTION log_delete_data();', |
||||
|
rec.nspname, rec.relname); |
||||
|
|
||||
|
END IF; |
||||
|
END IF; |
||||
|
END LOOP; |
||||
|
END; |
||||
|
$$ LANGUAGE plpgsql; |
||||
|
""") |
||||
|
env.cr.execute(""" |
||||
|
CREATE OR REPLACE FUNCTION trigger_on_table_creation() |
||||
|
RETURNS EVENT_TRIGGER AS $$ |
||||
|
BEGIN |
||||
|
PERFORM add_update_trigger_to_new_tables(); |
||||
|
END; |
||||
|
$$ LANGUAGE plpgsql; |
||||
|
""") |
||||
|
env.cr.execute(""" |
||||
|
CREATE EVENT TRIGGER auto_add_delete_triggers |
||||
|
ON ddl_command_end |
||||
|
WHEN TAG IN ('CREATE TABLE') |
||||
|
EXECUTE FUNCTION trigger_on_table_creation(); |
||||
|
""") |
||||
|
env.cr.execute(""" |
||||
|
CREATE OR REPLACE FUNCTION handle_log_reinsert() |
||||
|
RETURNS TRIGGER AS $$ |
||||
|
DECLARE |
||||
|
target_table TEXT; |
||||
|
column_list TEXT; |
||||
|
value_list TEXT; |
||||
|
column_count INT; |
||||
|
new_mode TEXT; |
||||
|
latest_id INT; |
||||
|
BEGIN |
||||
|
IF TG_TABLE_NAME = 'undo_redo' THEN |
||||
|
target_table := OLD.table_name; |
||||
|
|
||||
|
column_list := array_to_string( |
||||
|
array(SELECT jsonb_object_keys(OLD.updated_data)), |
||||
|
', ' |
||||
|
); |
||||
|
value_list := array_to_string( |
||||
|
array( |
||||
|
SELECT format('%L', OLD.updated_data->>key) |
||||
|
FROM jsonb_object_keys(OLD.updated_data) AS key |
||||
|
), |
||||
|
', ' |
||||
|
); |
||||
|
|
||||
|
new_mode := CASE OLD.mode |
||||
|
WHEN 'undo' THEN 'redo' |
||||
|
ELSE 'undo' |
||||
|
END; |
||||
|
column_count := array_length(string_to_array(column_list, ','), 1); |
||||
|
IF column_count > 1 THEN |
||||
|
EXECUTE format( |
||||
|
'UPDATE %I SET (%s) = (%s) WHERE id = %L', |
||||
|
target_table, |
||||
|
column_list, |
||||
|
value_list, |
||||
|
OLD.record_id |
||||
|
); |
||||
|
ELSIF column_count = 1 THEN |
||||
|
EXECUTE format( |
||||
|
'UPDATE %I SET %s = %s WHERE id = %L', |
||||
|
target_table, |
||||
|
column_list, |
||||
|
value_list, |
||||
|
OLD.record_id |
||||
|
); |
||||
|
END IF; |
||||
|
SELECT id INTO latest_id |
||||
|
FROM undo_redo |
||||
|
WHERE table_name = OLD.table_name |
||||
|
AND record_id = OLD.record_id |
||||
|
ORDER BY id DESC |
||||
|
LIMIT 1; |
||||
|
|
||||
|
UPDATE undo_redo |
||||
|
SET mode = new_mode |
||||
|
WHERE id = latest_id; |
||||
|
|
||||
|
RETURN OLD; |
||||
|
END IF; |
||||
|
END; |
||||
|
$$ LANGUAGE plpgsql; |
||||
|
|
||||
|
""") |
||||
|
env.cr.execute(""" |
||||
|
CREATE TRIGGER after_delete_trigger |
||||
|
AFTER DELETE ON undo_redo |
||||
|
FOR EACH ROW |
||||
|
EXECUTE FUNCTION handle_log_reinsert(); |
||||
|
""") |
||||
|
|
||||
|
def uninstall_hook(env): |
||||
|
env.cr.execute(""" |
||||
|
DROP EVENT TRIGGER IF EXISTS auto_add_delete_triggers; |
||||
|
""") |
||||
|
env.cr.execute(""" |
||||
|
DROP TRIGGER IF EXISTS after_delete_trigger ON undo_redo; |
||||
|
""") |
||||
|
env.cr.execute(""" |
||||
|
DO $$ |
||||
|
DECLARE |
||||
|
rec RECORD; |
||||
|
BEGIN |
||||
|
FOR rec IN |
||||
|
SELECT n.nspname, c.relname |
||||
|
FROM pg_class c |
||||
|
JOIN pg_namespace n ON c.relnamespace = n.oid |
||||
|
WHERE c.relkind = 'r' |
||||
|
AND n.nspname NOT IN ('pg_catalog', 'information_schema') |
||||
|
LOOP |
||||
|
EXECUTE format('DROP TRIGGER IF EXISTS capture_delete_dynamic ON %I.%I;', |
||||
|
rec.nspname, rec.relname); |
||||
|
EXECUTE format('DROP TRIGGER IF EXISTS log_delete_trigger ON %I.%I;', |
||||
|
rec.nspname, rec.relname); |
||||
|
END LOOP; |
||||
|
END $$; |
||||
|
""") |
||||
|
env.cr.execute(""" |
||||
|
DROP FUNCTION IF EXISTS log_update_data() CASCADE; |
||||
|
DROP FUNCTION IF EXISTS log_delete_data() CASCADE; |
||||
|
DROP FUNCTION IF EXISTS add_update_trigger_to_new_tables() CASCADE; |
||||
|
DROP FUNCTION IF EXISTS trigger_on_table_creation() CASCADE; |
||||
|
DROP FUNCTION IF EXISTS handle_log_reinsert() CASCADE; |
||||
|
""") |
||||
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# 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 (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from . import undo_redo |
||||
@ -0,0 +1,51 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# 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 (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from odoo import api, fields, models |
||||
|
|
||||
|
|
||||
|
class UndoRedo(models.TransientModel): |
||||
|
"""Transient model to temporarily store undo and redo logs for |
||||
|
record changes across all models.""" |
||||
|
_name = 'undo.redo' |
||||
|
_description = 'Undo Redo' |
||||
|
_transient_max_hours = 1 |
||||
|
_transient_max_count = 0 |
||||
|
|
||||
|
table_name = fields.Char(string="Name") |
||||
|
record_id = fields.Integer(string="Record Id") |
||||
|
updated_data = fields.Json("Updated Data") |
||||
|
mode = fields.Selection([ |
||||
|
('undo', 'Undo'), |
||||
|
('redo', 'Redo'), |
||||
|
], string="Mode") |
||||
|
user_id = fields.Many2one("res.users") |
||||
|
|
||||
|
@api.model |
||||
|
def get_data(self, table_name, record_id, mode="undo"): |
||||
|
"""Retrieve a list of undo/redo record IDs matching the given table |
||||
|
name,record ID, and operation mode. Most recent record comes first. |
||||
|
""" |
||||
|
undo_record = self.env['undo.redo'].search( |
||||
|
[('table_name', '=', table_name.replace(".", "_")), ('record_id', '=', record_id), ('mode', '=', mode)], |
||||
|
order='id DESC', |
||||
|
) |
||||
|
return undo_record.ids |
||||
|
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 628 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 210 KiB |
|
After Width: | Height: | Size: 209 KiB |
|
After Width: | Height: | Size: 109 KiB |
|
After Width: | Height: | Size: 495 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 624 B |
|
After Width: | Height: | Size: 136 KiB |
|
After Width: | Height: | Size: 214 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 310 B |
|
After Width: | Height: | Size: 929 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 542 B |
|
After Width: | Height: | Size: 576 B |
|
After Width: | Height: | Size: 733 B |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 417 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 911 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 600 B |
|
After Width: | Height: | Size: 673 B |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 462 B |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 926 B |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 878 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 653 B |
|
After Width: | Height: | Size: 800 B |
|
After Width: | Height: | Size: 905 B |
|
After Width: | Height: | Size: 189 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 839 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 427 B |
|
After Width: | Height: | Size: 627 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 988 B |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 875 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 80 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 565 B |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 781 KiB |
|
After Width: | Height: | Size: 87 KiB |
|
After Width: | Height: | Size: 751 KiB |
|
After Width: | Height: | Size: 712 KiB |
|
After Width: | Height: | Size: 816 KiB |
|
After Width: | Height: | Size: 725 KiB |
|
After Width: | Height: | Size: 155 KiB |
|
After Width: | Height: | Size: 155 KiB |
|
After Width: | Height: | Size: 155 KiB |
|
After Width: | Height: | Size: 155 KiB |
|
After Width: | Height: | Size: 151 KiB |
|
After Width: | Height: | Size: 114 KiB |