diff --git a/cleaning_database_operations/README.rst b/cleaning_database_operations/README.rst new file mode 100644 index 0000000000..542738fde8 --- /dev/null +++ b/cleaning_database_operations/README.rst @@ -0,0 +1,34 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============================ +Cleaning Database Operations +============================ + +* Cleaning all the database operations of selected companies: + Stock Move Lines, Stock Moves, Pickings, Quants, Lots, + Valuation Layers, Sale Orders, Sale Order Lines, Purchase Orders, + Purchase Order Lines, Account Partial Reconcile, Account Moves, + Account Move Lines, Account Bank Statement, Account Payment Order and + Account Payment Line. +* Restart all sequences. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Contributors +------------ + +* Berezi Amubieta +* Ana Juaristi diff --git a/cleaning_database_operations/__init__.py b/cleaning_database_operations/__init__.py new file mode 100644 index 0000000000..aee8895e7a --- /dev/null +++ b/cleaning_database_operations/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizards diff --git a/cleaning_database_operations/__manifest__.py b/cleaning_database_operations/__manifest__.py new file mode 100644 index 0000000000..92d89f8c21 --- /dev/null +++ b/cleaning_database_operations/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2024 Berezi Amubieta - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Cleaning Database Operations", + "version": "16.0.1.0.0", + "category": "Generic Modules", + "license": "AGPL-3", + "author": "AvanzOSC", + "website": "https://github.com/avanzosc/odoo-addons", + "depends": [ + "stock", + "sale", + "purchase", + "account", + "account_payment_order", + ], + "data": [ + "security/ir.model.access.csv", + "views/cleaning_database_view.xml", + "wizards/cleaning_database_warning_wizard_view.xml", + ], + "installable": True, +} diff --git a/cleaning_database_operations/i18n/cleaning_database_operations.pot b/cleaning_database_operations/i18n/cleaning_database_operations.pot new file mode 100644 index 0000000000..240240f360 --- /dev/null +++ b/cleaning_database_operations/i18n/cleaning_database_operations.pot @@ -0,0 +1,239 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * cleaning_database_operations +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-28 13:45+0000\n" +"PO-Revision-Date: 2024-11-28 13:45+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: cleaning_database_operations +#: model:ir.model.fields.selection,name:cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__accounting +msgid "Accounting" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "" +"Accounting: Account Partial Reconcile, Account Move Line, Account Move, " +"Account Bank Statement, Account Payment Order, Account Payment Line." +msgstr "" + +#. module: cleaning_database_operations +#. odoo-python +#: code:addons/cleaning_database_operations/wizards/cleaning_database_warning_wizard.py:0 +#, python-format +msgid "" +"Are you sure you want to delete the entire operation? This action will be " +"irreversible" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_warning_wizard_view_form +msgid "Cancel" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning Accounting Operations" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.actions.act_window,name:cleaning_database_operations.action_cleaning_database_view +#: model:ir.ui.menu,name:cleaning_database_operations.cleaning_database +#: model:ir.ui.menu,name:cleaning_database_operations.menu_view_cleaning_database +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning Database" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model,name:cleaning_database_operations.model_cleaning_database +msgid "Cleaning Database Operations" +msgstr "" + +#. module: cleaning_database_operations +#. odoo-python +#: code:addons/cleaning_database_operations/models/cleaning_database.py:0 +#, python-format +msgid "Cleaning Database Warning" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning Lots" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning Purchase Operations" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning Sale Operations" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning Stock Operations" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning Valuation Layers" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__company_ids +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Companies" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_warning_wizard_view_form +msgid "Continue" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__create_uid +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__create_uid +msgid "Created by" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__create_date +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__create_date +msgid "Created on" +msgstr "" + +#. module: cleaning_database_operations +#. odoo-python +#: code:addons/cleaning_database_operations/models/cleaning_database.py:0 +#, python-format +msgid "Creation date: {}" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__name +msgid "Description" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__display_name +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__display_name +msgid "Display Name" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__id +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__id +msgid "ID" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "" +"Inventory: Stock Move Line, Stock Move, Stock Picking, Stock Quant, Stock " +"Valuation Layer, Stock Production Lot." +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database____last_update +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard____last_update +msgid "Last Modified on" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__write_uid +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__write_date +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__write_date +msgid "Last Updated on" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields.selection,name:cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__lot +msgid "Lot" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__object_to_delete +msgid "Object To Delete" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields.selection,name:cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__purchase +msgid "Purchase" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Purchases: Purchase Order Line, Purchase Order." +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Reset Sequences" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields.selection,name:cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__sale +msgid "Sale" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Sales: Sale Order Line, Sale Order." +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields.selection,name:cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__sequences +msgid "Sequences" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Squence: Reset sequences." +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields.selection,name:cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__stock +msgid "Stock" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__text +msgid "Text" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "This will delete the following objects" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields.selection,name:cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__valuation +msgid "Valuation Layer" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model,name:cleaning_database_operations.model_cleaning_database_warning_wizard +msgid "Wizard for warning when cleaning database operations" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_warning_wizard_view_form +msgid "or" +msgstr "" diff --git a/cleaning_database_operations/i18n/es.po b/cleaning_database_operations/i18n/es.po new file mode 100644 index 0000000000..1cba86bcc1 --- /dev/null +++ b/cleaning_database_operations/i18n/es.po @@ -0,0 +1,245 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * cleaning_database_operations +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-28 13:45+0000\n" +"PO-Revision-Date: 2024-11-28 13:45+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: cleaning_database_operations +#: model:ir.model.fields.selection,name:cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__accounting +msgid "Accounting" +msgstr "Contabilidad" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "" +"Accounting: Account Partial Reconcile, Account Move Line, Account Move, " +"Account Bank Statement, Account Payment Order, Account Payment Line." +msgstr "" +"Contabilidad: Conciliación parcial, apunte contable, asiento contable, " +"extracto bancario, orden de pago, líneas de pago." + +#. module: cleaning_database_operations +#. odoo-python +#: code:addons/cleaning_database_operations/wizards/cleaning_database_warning_wizard.py:0 +#, python-format +msgid "" +"Are you sure you want to delete the entire operation? This action will be " +"irreversible" +msgstr "" +"¿Está seguro de que desea borrar toda la operativa? Esta acción será " +"irreversible" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_warning_wizard_view_form +msgid "Cancel" +msgstr "Cancelar" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning Accounting Operations" +msgstr "Borrado de operaciones de contabilidad" + +#. module: cleaning_database_operations +#: model:ir.actions.act_window,name:cleaning_database_operations.action_cleaning_database_view +#: model:ir.ui.menu,name:cleaning_database_operations.cleaning_database +#: model:ir.ui.menu,name:cleaning_database_operations.menu_view_cleaning_database +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning Database" +msgstr "Limpieza en base de datos" + +#. module: cleaning_database_operations +#: model:ir.model,name:cleaning_database_operations.model_cleaning_database +msgid "Cleaning Database Operations" +msgstr "Limpieza de operaciones en base de datos" + +#. module: cleaning_database_operations +#. odoo-python +#: code:addons/cleaning_database_operations/models/cleaning_database.py:0 +#, python-format +msgid "Cleaning Database Warning" +msgstr "Alerta borrado de base de datos" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning Lots" +msgstr "Borrado de lotes" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning Purchase Operations" +msgstr "Borrado de operaciones de compra" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning Sale Operations" +msgstr "Borrado de operaciones de venta" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning Stock Operations" +msgstr "Borrado de operaciones de stock" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning Valuation Layers" +msgstr "Borrado de valoración de stock" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__company_ids +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Companies" +msgstr "Compañías" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_warning_wizard_view_form +msgid "Continue" +msgstr "Continuar" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__create_uid +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__create_date +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__create_date +msgid "Created on" +msgstr "Creado el" + +#. module: cleaning_database_operations +#. odoo-python +#: code:addons/cleaning_database_operations/models/cleaning_database.py:0 +#, python-format +msgid "Creation date: {}" +msgstr "Fecha de creación: {}" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__name +msgid "Description" +msgstr "Descripción" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__display_name +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__display_name +msgid "Display Name" +msgstr "Nombre mostrado" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__id +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__id +msgid "ID" +msgstr "" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "" +"Inventory: Stock Move Line, Stock Move, Stock Picking, Stock Quant, Stock " +"Valuation Layer, Stock Production Lot." +msgstr "" +"Inventario: Movimiento de producto, movimiento de stock, albarán, stock, " +"valoración de stock, lote." + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database____last_update +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard____last_update +msgid "Last Modified on" +msgstr "Modificado el" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__write_uid +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__write_uid +msgid "Last Updated by" +msgstr "Actualizado por" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database__write_date +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__write_date +msgid "Last Updated on" +msgstr "Actualizado el" + +#. module: cleaning_database_operations +#: model:ir.model.fields.selection,name:cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__lot +msgid "Lot" +msgstr "Lote" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__object_to_delete +msgid "Object To Delete" +msgstr "Estado" + +#. module: cleaning_database_operations +#: model:ir.model.fields.selection,name:cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__purchase +msgid "Purchase" +msgstr "Compra" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Purchases: Purchase Order Line, Purchase Order." +msgstr "Compras: Pedidos de compra, línea de compra." + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Reset Sequences" +msgstr "Reiniciar secuencias" + +#. module: cleaning_database_operations +#: model:ir.model.fields.selection,name:cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__sale +msgid "Sale" +msgstr "Venta" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Sales: Sale Order Line, Sale Order." +msgstr "Ventas: Pedido de venta, línea de venta." + +#. module: cleaning_database_operations +#: model:ir.model.fields.selection,name:cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__sequences +msgid "Sequences" +msgstr "Secuencias" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "Squence: Reset sequences." +msgstr "Secuencia: Reiniciar secuencias" + +#. module: cleaning_database_operations +#: model:ir.model.fields.selection,name:cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__stock +msgid "Stock" +msgstr "" + +#. module: cleaning_database_operations +#: model:ir.model.fields,field_description:cleaning_database_operations.field_cleaning_database_warning_wizard__text +msgid "Text" +msgstr "Texto" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_form_view +msgid "This will delete the following objects" +msgstr "Esto eliminará los siguientes objetos" + +#. module: cleaning_database_operations +#: model:ir.model.fields.selection,name:cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__valuation +msgid "Valuation Layer" +msgstr "Valoración de inventario" + +#. module: cleaning_database_operations +#: model:ir.model,name:cleaning_database_operations.model_cleaning_database_warning_wizard +msgid "Wizard for warning when cleaning database operations" +msgstr "Asistente para alertar al limpiar las operaciones de la base de datos" + +#. module: cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:cleaning_database_operations.cleaning_database_warning_wizard_view_form +msgid "or" +msgstr "o" diff --git a/cleaning_database_operations/models/__init__.py b/cleaning_database_operations/models/__init__.py new file mode 100644 index 0000000000..71bb69189b --- /dev/null +++ b/cleaning_database_operations/models/__init__.py @@ -0,0 +1 @@ +from . import cleaning_database diff --git a/cleaning_database_operations/models/cleaning_database.py b/cleaning_database_operations/models/cleaning_database.py new file mode 100644 index 0000000000..1559c766e2 --- /dev/null +++ b/cleaning_database_operations/models/cleaning_database.py @@ -0,0 +1,132 @@ +# Copyright 2024 Berezi Amubieta - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import _, api, fields, models + + +class CleaningDatabase(models.Model): + _name = "cleaning.database" + _description = "Cleaning Database Operations" + + name = fields.Char(string="Description", copy=False) + company_ids = fields.Many2many( + string="Companies", + comodel_name="res.company", + relation="rel_cleaning_database_company", + column1="cleaning_database_id", + column2="company_id", + required=True, + ) + + def action_open_delete_warning(self): + wiz_obj = self.env["cleaning.database.warning.wizard"] + vals = {} + if "default_object_to_delete" in self.env.context: + vals = {"object_to_delete": self.env.context["default_object_to_delete"]} + wiz = wiz_obj.with_context(active_id=self.id).create(vals) + context = self.env.context.copy() + return { + "name": _("Cleaning Database Warning"), + "type": "ir.actions.act_window", + "res_model": "cleaning.database.warning.wizard", + "view_type": "form", + "view_mode": "form", + "res_id": wiz.id, + "target": "new", + "context": context, + } + + def action_delete_stock_operations(self): + self.env.cr.execute( + "DELETE FROM stock_move_line WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) + self.env.cr.execute( + "DELETE FROM stock_move WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) + self.env.cr.execute( + "DELETE FROM stock_picking WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) + self.env.cr.execute( + "DELETE FROM stock_quant " + "WHERE company_id in %s OR lot_id in (select l.id " + " from stock_lot as l" + " where l.id = stock_quant.lot_id " + " and l.company_id in %s)", + [tuple(self.company_ids.ids), tuple(self.company_ids.ids)], + ) + + def action_delete_stock_production_lot(self): + self.env.cr.execute( + "DELETE FROM stock_lot WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) + + def action_delete_stock_valuation_operations(self): + self.env.cr.execute( + "DELETE FROM stock_valuation_layer WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) + + def action_delete_sale_operations(self): + self.env.cr.execute( + "DELETE FROM sale_order_line WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) + self.env.cr.execute( + "DELETE FROM sale_order WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) + + def action_delete_purchase_operations(self): + self.env.cr.execute( + "DELETE FROM purchase_order_line WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) + self.env.cr.execute( + "DELETE FROM purchase_order WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) + + def action_delete_accounting_operations(self): + self.env.cr.execute( + "DELETE FROM account_partial_reconcile WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) + self.env.cr.execute( + "DELETE FROM account_move_line WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) + self.env.cr.execute( + "DELETE FROM account_move WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) + self.env.cr.execute( + "DELETE FROM account_bank_statement WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) + self.env.cr.execute( + "DELETE FROM account_payment_order WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) + self.env.cr.execute( + "DELETE FROM account_payment_line WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) + + def action_delete_sequance_operations(self): + sequences = self.env["ir.sequence"].search( + [ + ("number_next_actual", "!=", 1), + ("company_id", "in", self.company_ids.ids), + ] + ) + for line in sequences: + line.number_next_actual = 1 + + @api.model + def create(self, values): + name = _("Creation date: {}").format(fields.Datetime.now()) + values["name"] = name + return super().create(values) diff --git a/cleaning_database_operations/security/ir.model.access.csv b/cleaning_database_operations/security/ir.model.access.csv new file mode 100644 index 0000000000..01154b0cae --- /dev/null +++ b/cleaning_database_operations/security/ir.model.access.csv @@ -0,0 +1,5 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +"access_cleaning_database_user","cleaning_database user","model_cleaning_database","base.group_user",1,0,0,0 +"access_cleaning_database_manager","cleaning_database manager","model_cleaning_database","base.group_partner_manager",1,1,1,1 +"access_cleaning_database_warning_wizard_user","cleaning_database_warning_wizard user","model_cleaning_database_warning_wizard","mrp.group_mrp_user",1,1,1,1 +"access_cleaning_database_warning_wizard_manager","cleaning_database_warning_wizard manager","model_cleaning_database_warning_wizard","mrp.group_mrp_manager",1,1,1,1 diff --git a/cleaning_database_operations/static/description/boom_icon.png b/cleaning_database_operations/static/description/boom_icon.png new file mode 100644 index 0000000000..4084f50f13 Binary files /dev/null and b/cleaning_database_operations/static/description/boom_icon.png differ diff --git a/cleaning_database_operations/views/cleaning_database_view.xml b/cleaning_database_operations/views/cleaning_database_view.xml new file mode 100644 index 0000000000..df9aad0322 --- /dev/null +++ b/cleaning_database_operations/views/cleaning_database_view.xml @@ -0,0 +1,124 @@ + + + + + cleaning.database.form.view + cleaning.database + +
+ +
+

This will delete the following objects

+

Sales: Sale Order Line, Sale Order.

+

+

+ + + + + + +
+
+
+
+ + + cleaning.database.tree.view + cleaning.database + + + + + + + + + Cleaning Database + ir.actions.act_window + cleaning.database + tree,form + + + + + +
diff --git a/cleaning_database_operations/wizards/__init__.py b/cleaning_database_operations/wizards/__init__.py new file mode 100644 index 0000000000..2929000501 --- /dev/null +++ b/cleaning_database_operations/wizards/__init__.py @@ -0,0 +1 @@ +from . import cleaning_database_warning_wizard diff --git a/cleaning_database_operations/wizards/cleaning_database_warning_wizard.py b/cleaning_database_operations/wizards/cleaning_database_warning_wizard.py new file mode 100644 index 0000000000..c9856c941b --- /dev/null +++ b/cleaning_database_operations/wizards/cleaning_database_warning_wizard.py @@ -0,0 +1,55 @@ +# Copyright 2023 Berezi Amubieta - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import _, api, fields, models + + +class CleaningDatabaseWarningWizard(models.TransientModel): + _name = "cleaning.database.warning.wizard" + _description = "Wizard for warning when cleaning database operations" + + text = fields.Text() + object_to_delete = fields.Selection( + selection=[ + ("stock", "Stock"), + ("lot", "Lot"), + ("valuation", "Valuation Layer"), + ("sale", "Sale"), + ("purchase", "Purchase"), + ("accounting", "Accounting"), + ("sequences", "Sequences"), + ], + required=True, + ) + + @api.model + def default_get(self, fields_list): + res = super().default_get(fields_list) + res.update( + { + "text": _( + "Are you sure you want to delete the entire " + "operation? This action will be irreversible" + ) + } + ) + return res + + def continue_with_cleaning_database(self): + self.ensure_one() + cleaning_database = self.env["cleaning.database"].browse( + self.env.context.get("active_id") + ) + if self.object_to_delete == "sale": + return cleaning_database.action_delete_sale_operations() + elif self.object_to_delete == "purchase": + return cleaning_database.action_delete_purchase_operations() + elif self.object_to_delete == "stock": + return cleaning_database.action_delete_stock_operations() + elif self.object_to_delete == "lot": + return cleaning_database.action_delete_stock_production_lot() + elif self.object_to_delete == "valuation": + return cleaning_database.action_delete_stock_valuation_operations() + elif self.object_to_delete == "accounting": + return cleaning_database.action_delete_accounting_operations() + elif self.object_to_delete == "sequences": + return cleaning_database.action_delete_sequance_operations() diff --git a/cleaning_database_operations/wizards/cleaning_database_warning_wizard_view.xml b/cleaning_database_operations/wizards/cleaning_database_warning_wizard_view.xml new file mode 100644 index 0000000000..e7404b44b8 --- /dev/null +++ b/cleaning_database_operations/wizards/cleaning_database_warning_wizard_view.xml @@ -0,0 +1,25 @@ + + + + cleaning.database.warning.wizard.form + cleaning.database.warning.wizard + +
+ + + + + +
+
+
+
diff --git a/setup/cleaning_database_operations/odoo/addons/cleaning_database_operations b/setup/cleaning_database_operations/odoo/addons/cleaning_database_operations new file mode 120000 index 0000000000..5788e83095 --- /dev/null +++ b/setup/cleaning_database_operations/odoo/addons/cleaning_database_operations @@ -0,0 +1 @@ +../../../../cleaning_database_operations \ No newline at end of file diff --git a/setup/cleaning_database_operations/setup.py b/setup/cleaning_database_operations/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/cleaning_database_operations/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)