diff --git a/README.rst b/README.rst new file mode 100644 index 00000000..76bd84f8 --- /dev/null +++ b/README.rst @@ -0,0 +1,46 @@ +=================== +Odoo 19 Remove Data +=================== + +This Module will help to remove transactional data from database + +Installation +============ + +To install this module, you need to: + +Download the module and add it to your Odoo addons folder. Afterward, log on to +your Odoo server and go to the Apps menu. Trigger the debug mode and update the +list by clicking on the "Update Apps List" link. Now install the module by +clicking on the install button. + +Upgrade +============ + +To upgrade this module, you need to: + +Download the module and add it to your Odoo addons folder. Restart the server +and log on to your Odoo server. Select the Apps menu and upgrade the module by +clicking on the upgrade button. + + +Configuration +============= + +There is Nothing to Configure + + +Credits +======= + +Contributors +------------ + +* Odoo Mates +* Sunpop.cn + + +Author & Maintainer +------------------- + +This module is maintained by the Odoo Mates \ No newline at end of file diff --git a/__init__.py b/__init__.py new file mode 100644 index 00000000..899bcc97 --- /dev/null +++ b/__init__.py @@ -0,0 +1,2 @@ +from . import models + diff --git a/__manifest__.py b/__manifest__.py new file mode 100644 index 00000000..163ad7ab --- /dev/null +++ b/__manifest__.py @@ -0,0 +1,16 @@ +{ + 'name': 'Odoo 19 Remove Data', + 'version': '1.4', + 'author': 'Odoo Mates, Sunpop.cn', + 'category': 'Tools', + 'description': 'Data Clean up, Remove Data, Database Clean UP, Reset Database', + 'summary': 'Data Clean up, Remove Data, Database Clean UP, Reset Database', + 'maintainer': 'Odoo Mates', + 'support': 'odoomates@gmail.com', + 'license': 'LGPL-3', + 'depends': ['base'], + 'data': [ + 'views/view.xml', + ], + 'images': ['static/description/banner.png'], +} diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 00000000..833a0ba1 --- /dev/null +++ b/models/__init__.py @@ -0,0 +1,2 @@ +from . import model + diff --git a/models/model.py b/models/model.py new file mode 100644 index 00000000..0cbf625f --- /dev/null +++ b/models/model.py @@ -0,0 +1,41 @@ +import logging +from odoo import api, fields, models, _ +from odoo.exceptions import AccessError + +_logger = logging.getLogger(__name__) + + +class ResConfigSettings(models.TransientModel): + _inherit = 'res.config.settings' + + def _remove_data(self, models_to_remove, sequences=None): + if not self.env.user.has_group('base.group_system'): + raise AccessError(_("Only Administrators can perform this operation.")) + + sequences = sequences or [] + + for model_name in models_to_remove: + try: + model = self.env.get(model_name) + if not model: + _logger.warning("Model not found: %s", model_name) + continue + + table_name = model._table + sql = f'DELETE FROM "{table_name}"' + + self.env.cr.execute(sql) + + except Exception as e: + _logger.warning('Remove data error for %s: %s', model_name, e) + + for seq_prefix in sequences: + domain = ['|', ('code', '=ilike', seq_prefix + '%'), ('prefix', '=ilike', seq_prefix + '%')] + try: + seqs = self.env['ir.sequence'].sudo().search(domain) + if seqs: + seqs.write({'number_next': 1}) + except Exception as e: + _logger.warning('Reset sequence error for %s: %s', seq_prefix, e) + + return True \ No newline at end of file diff --git a/static/description/banner.png b/static/description/banner.png new file mode 100644 index 00000000..653b97de Binary files /dev/null and b/static/description/banner.png differ diff --git a/static/description/icon.png b/static/description/icon.png new file mode 100644 index 00000000..16fc3c8f Binary files /dev/null and b/static/description/icon.png differ diff --git a/static/description/index.html b/static/description/index.html new file mode 100644 index 00000000..2ebd6105 --- /dev/null +++ b/static/description/index.html @@ -0,0 +1,70 @@ +
+
+

Odoo 19 Remove Data

+
+
+ +
+
+
+

+ + + + Features: +

+
+
+

+ Remove all data in single click. +


+

+ Easy to test odoo. +


+
+
+
+
+
+ +
+
+

Remove Data Screen

+
+ +
+
+
+ +
+
+
+
+
+ +
+

If you need any support or want more features, just contact us:


+

Email: odoomates@gmail.com

+
+ +
+
+
+
+
+ \ No newline at end of file diff --git a/static/description/odoo_mates.png b/static/description/odoo_mates.png new file mode 100644 index 00000000..8408fa3a Binary files /dev/null and b/static/description/odoo_mates.png differ diff --git a/static/description/screen.png b/static/description/screen.png new file mode 100644 index 00000000..26afd0c6 Binary files /dev/null and b/static/description/screen.png differ diff --git a/views/security/ir.model.access.csv b/views/security/ir.model.access.csv new file mode 100644 index 00000000..8ee0f2b3 --- /dev/null +++ b/views/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_res_config_settings_data_remove,res.config.settings.data.remove,base.model_res_config_settings,base.group_system,1,1,1,1 \ No newline at end of file diff --git a/views/security/om_data_remove_security.xml b/views/security/om_data_remove_security.xml new file mode 100644 index 00000000..01c5476b --- /dev/null +++ b/views/security/om_data_remove_security.xml @@ -0,0 +1,11 @@ + + + + + + Data Remove Administrator + + + + + \ No newline at end of file diff --git a/views/view.xml b/views/view.xml new file mode 100644 index 00000000..cfd6ff5e --- /dev/null +++ b/views/view.xml @@ -0,0 +1,218 @@ + + + + + + Remove Data + res.config.settings + 20 + +
+
+ +

Data Cleaning (Be careful!)

+

+ Data is deleted directly from the database using queries. Once done, it is irreversible! +

+
+ + +
+ Remove All +
+ + +
+ Sale +
+ + +
+ POS +
+ + +
+ Purchase +
+ + +
+ Expense +
+ + +
+ MRP +
+ + +
+ Inventory +
+ + +
+ + Accounting + + +
+ + +
+ Project +
+ + +
+ Quality +
+ + +
+ Website & Blog +
+ + +
+ Base Models +
+ +
+
+
+
+ + + + Remove Data + ir.actions.act_window + res.config.settings + form + + + + + + + +
\ No newline at end of file