From bd57b0c7a8a9a7cb7cc57c4c1158436b7c1c283e Mon Sep 17 00:00:00 2001 From: Berezi Date: Tue, 19 Nov 2024 15:50:47 +0100 Subject: [PATCH] [16.0][IMP] mrp_cleaning_database_operations: Cleaning all the MRP operations: MRP Production and MRP Workorder. --- mrp_cleaning_database_operations/README.rst | 28 +++++++++++ mrp_cleaning_database_operations/__init__.py | 2 + .../__manifest__.py | 19 ++++++++ mrp_cleaning_database_operations/i18n/es.po | 46 +++++++++++++++++++ .../i18n/mrp_cleaning_database_operations.pot | 46 +++++++++++++++++++ .../models/__init__.py | 1 + .../models/cleaning_database.py | 21 +++++++++ .../views/cleaning_database_view.xml | 24 ++++++++++ .../wizards/__init__.py | 1 + .../cleaning_database_warning_wizard.py | 22 +++++++++ .../addons/mrp_cleaning_database_operations | 1 + .../mrp_cleaning_database_operations/setup.py | 6 +++ 12 files changed, 217 insertions(+) create mode 100644 mrp_cleaning_database_operations/README.rst create mode 100644 mrp_cleaning_database_operations/__init__.py create mode 100644 mrp_cleaning_database_operations/__manifest__.py create mode 100644 mrp_cleaning_database_operations/i18n/es.po create mode 100644 mrp_cleaning_database_operations/i18n/mrp_cleaning_database_operations.pot create mode 100644 mrp_cleaning_database_operations/models/__init__.py create mode 100644 mrp_cleaning_database_operations/models/cleaning_database.py create mode 100644 mrp_cleaning_database_operations/views/cleaning_database_view.xml create mode 100644 mrp_cleaning_database_operations/wizards/__init__.py create mode 100644 mrp_cleaning_database_operations/wizards/cleaning_database_warning_wizard.py create mode 120000 setup/mrp_cleaning_database_operations/odoo/addons/mrp_cleaning_database_operations create mode 100644 setup/mrp_cleaning_database_operations/setup.py diff --git a/mrp_cleaning_database_operations/README.rst b/mrp_cleaning_database_operations/README.rst new file mode 100644 index 000000000..8b457ee47 --- /dev/null +++ b/mrp_cleaning_database_operations/README.rst @@ -0,0 +1,28 @@ +.. 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 + +================================ +MRP Cleaning Database Operations +================================ + +Cleaning all the MRP operations: MRP Production and MRP Workorder. + +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/mrp_cleaning_database_operations/__init__.py b/mrp_cleaning_database_operations/__init__.py new file mode 100644 index 000000000..aee8895e7 --- /dev/null +++ b/mrp_cleaning_database_operations/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizards diff --git a/mrp_cleaning_database_operations/__manifest__.py b/mrp_cleaning_database_operations/__manifest__.py new file mode 100644 index 000000000..8872a8761 --- /dev/null +++ b/mrp_cleaning_database_operations/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2024 Berezi Amubieta - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "MRP Cleaning Database Operations", + "version": "16.0.1.0.0", + "category": "Manufacture", + "license": "AGPL-3", + "author": "AvanzOSC", + "website": "https://github.com/avanzosc/mrp-addons", + "depends": [ + "cleaning_database_operations", + "mrp", + ], + "data": [ + "views/cleaning_database_view.xml", + ], + "installable": True, + "auto_install": True, +} diff --git a/mrp_cleaning_database_operations/i18n/es.po b/mrp_cleaning_database_operations/i18n/es.po new file mode 100644 index 000000000..74ce9e5ce --- /dev/null +++ b/mrp_cleaning_database_operations/i18n/es.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_cleaning_database_operations +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-28 14:27+0000\n" +"PO-Revision-Date: 2024-11-28 14:27+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: mrp_cleaning_database_operations +#: model:ir.model,name:mrp_cleaning_database_operations.model_cleaning_database +msgid "Cleaning Database Operations" +msgstr "Limpieza de operaciones en base de datos" + +#. module: mrp_cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:mrp_cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning MRP Operations" +msgstr "Limpieza de operaciones de fabricación" + +#. module: mrp_cleaning_database_operations +#: model:ir.model.fields.selection,name:mrp_cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__mrp +msgid "MRP" +msgstr "" + +#. module: mrp_cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:mrp_cleaning_database_operations.cleaning_database_form_view +msgid "Manufacturing: MRP Workorder, MRP Production." +msgstr "Fabricación: Orden de tranbajo, orden de producción." + +#. module: mrp_cleaning_database_operations +#: model:ir.model.fields,field_description:mrp_cleaning_database_operations.field_cleaning_database_warning_wizard__object_to_delete +msgid "Object To Delete" +msgstr "Estado" + +#. module: mrp_cleaning_database_operations +#: model:ir.model,name:mrp_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" diff --git a/mrp_cleaning_database_operations/i18n/mrp_cleaning_database_operations.pot b/mrp_cleaning_database_operations/i18n/mrp_cleaning_database_operations.pot new file mode 100644 index 000000000..769789ac0 --- /dev/null +++ b/mrp_cleaning_database_operations/i18n/mrp_cleaning_database_operations.pot @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_cleaning_database_operations +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-28 14:26+0000\n" +"PO-Revision-Date: 2024-11-28 14:26+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: mrp_cleaning_database_operations +#: model:ir.model,name:mrp_cleaning_database_operations.model_cleaning_database +msgid "Cleaning Database Operations" +msgstr "" + +#. module: mrp_cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:mrp_cleaning_database_operations.cleaning_database_form_view +msgid "Cleaning MRP Operations" +msgstr "" + +#. module: mrp_cleaning_database_operations +#: model:ir.model.fields.selection,name:mrp_cleaning_database_operations.selection__cleaning_database_warning_wizard__object_to_delete__mrp +msgid "MRP" +msgstr "" + +#. module: mrp_cleaning_database_operations +#: model_terms:ir.ui.view,arch_db:mrp_cleaning_database_operations.cleaning_database_form_view +msgid "Manufacturing: MRP Workorder, MRP Production." +msgstr "" + +#. module: mrp_cleaning_database_operations +#: model:ir.model.fields,field_description:mrp_cleaning_database_operations.field_cleaning_database_warning_wizard__object_to_delete +msgid "Object To Delete" +msgstr "" + +#. module: mrp_cleaning_database_operations +#: model:ir.model,name:mrp_cleaning_database_operations.model_cleaning_database_warning_wizard +msgid "Wizard for warning when cleaning database operations" +msgstr "" diff --git a/mrp_cleaning_database_operations/models/__init__.py b/mrp_cleaning_database_operations/models/__init__.py new file mode 100644 index 000000000..71bb69189 --- /dev/null +++ b/mrp_cleaning_database_operations/models/__init__.py @@ -0,0 +1 @@ +from . import cleaning_database diff --git a/mrp_cleaning_database_operations/models/cleaning_database.py b/mrp_cleaning_database_operations/models/cleaning_database.py new file mode 100644 index 000000000..9df23e9d9 --- /dev/null +++ b/mrp_cleaning_database_operations/models/cleaning_database.py @@ -0,0 +1,21 @@ +# Copyright 2024 Berezi Amubieta - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import models + + +class CleaningDatabase(models.Model): + _inherit = "cleaning.database" + + def action_delete_mrp_operations(self): + self.env.cr.execute( + "DELETE FROM mrp_workorder " + "WHERE production_id in (select p.id " + " from mrp_production as p " + " where p.id = mrp_workorder.production_id " + " and p.company_id in %s)", + [tuple(self.company_ids.ids)], + ) + self.env.cr.execute( + "DELETE FROM mrp_production WHERE company_id in %s", + [tuple(self.company_ids.ids)], + ) diff --git a/mrp_cleaning_database_operations/views/cleaning_database_view.xml b/mrp_cleaning_database_operations/views/cleaning_database_view.xml new file mode 100644 index 000000000..8bbbbe190 --- /dev/null +++ b/mrp_cleaning_database_operations/views/cleaning_database_view.xml @@ -0,0 +1,24 @@ + + + + cleaning.database + + +
+

Manufacturing: MRP Workorder, MRP Production.

+

+

+
+
+
diff --git a/mrp_cleaning_database_operations/wizards/__init__.py b/mrp_cleaning_database_operations/wizards/__init__.py new file mode 100644 index 000000000..292900050 --- /dev/null +++ b/mrp_cleaning_database_operations/wizards/__init__.py @@ -0,0 +1 @@ +from . import cleaning_database_warning_wizard diff --git a/mrp_cleaning_database_operations/wizards/cleaning_database_warning_wizard.py b/mrp_cleaning_database_operations/wizards/cleaning_database_warning_wizard.py new file mode 100644 index 000000000..7ea8159f8 --- /dev/null +++ b/mrp_cleaning_database_operations/wizards/cleaning_database_warning_wizard.py @@ -0,0 +1,22 @@ +# Copyright 2023 Berezi Amubieta - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import fields, models + + +class CleaningDatabaseWarningWizard(models.TransientModel): + _inherit = "cleaning.database.warning.wizard" + + object_to_delete = fields.Selection( + selection_add=[ + ("mrp", "MRP"), + ], + ondelete={"mrp": "cascade"}, + ) + + def continue_with_cleaning_database(self): + super().continue_with_cleaning_database() + cleaning_database = self.env["cleaning.database"].browse( + self.env.context.get("active_id") + ) + if self.object_to_delete == "mrp": + return cleaning_database.action_delete_mrp_operations() diff --git a/setup/mrp_cleaning_database_operations/odoo/addons/mrp_cleaning_database_operations b/setup/mrp_cleaning_database_operations/odoo/addons/mrp_cleaning_database_operations new file mode 120000 index 000000000..3a5e1b485 --- /dev/null +++ b/setup/mrp_cleaning_database_operations/odoo/addons/mrp_cleaning_database_operations @@ -0,0 +1 @@ +../../../../mrp_cleaning_database_operations \ No newline at end of file diff --git a/setup/mrp_cleaning_database_operations/setup.py b/setup/mrp_cleaning_database_operations/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/mrp_cleaning_database_operations/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)