diff --git a/product_last_mrp_info/README.rst b/product_last_mrp_info/README.rst new file mode 100644 index 000000000..76e026796 --- /dev/null +++ b/product_last_mrp_info/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 + +===================== +Product last mrp info +===================== + +* In products new fields: "Last Manufacturing Order", and + "Last Manufacturing Order Date". + +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 +------------ +* Ana Juaristi +* Alfredo de la Fuente diff --git a/product_last_mrp_info/__init__.py b/product_last_mrp_info/__init__.py new file mode 100644 index 000000000..83e553ac4 --- /dev/null +++ b/product_last_mrp_info/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/product_last_mrp_info/__manifest__.py b/product_last_mrp_info/__manifest__.py new file mode 100644 index 000000000..1c02a0867 --- /dev/null +++ b/product_last_mrp_info/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2024 Alfredo de la Fuente - AvanzOSC +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +{ + "name": "Product Last MRP Info", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "category": "Manufacturing", + "author": "Avanzosc", + "website": "https://github.com/avanzosc/mrp-addons", + "depends": [ + "product", + "mrp", + ], + "data": ["views/product_product_views.xml"], + "installable": True, +} diff --git a/product_last_mrp_info/i18n/es.po b/product_last_mrp_info/i18n/es.po new file mode 100644 index 000000000..0459675d9 --- /dev/null +++ b/product_last_mrp_info/i18n/es.po @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_last_mrp_info +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-05-16 11:00+0000\n" +"PO-Revision-Date: 2024-05-16 11:00+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: product_last_mrp_info +#: model:ir.model.fields,field_description:product_last_mrp_info.field_product_product__last_mrp_id +msgid "Last Manufacturing Order" +msgstr "Última OF" + +#. module: product_last_mrp_info +#: model:ir.model.fields,field_description:product_last_mrp_info.field_product_product__last_mrp_date +msgid "Last Manufacturing Order Date" +msgstr "Última fecha OF" + +#. module: product_last_mrp_info +#: model_terms:ir.ui.view,arch_db:product_last_mrp_info.product_normal_form_view +msgid "MRP" +msgstr "MRP" + +#. module: product_last_mrp_info +#: model:ir.model,name:product_last_mrp_info.model_product_product +msgid "Product Variant" +msgstr "Variante de producto" diff --git a/product_last_mrp_info/i18n/product_last_mrp_info.pot b/product_last_mrp_info/i18n/product_last_mrp_info.pot new file mode 100644 index 000000000..126c78b27 --- /dev/null +++ b/product_last_mrp_info/i18n/product_last_mrp_info.pot @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_last_mrp_info +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-05-16 11:00+0000\n" +"PO-Revision-Date: 2024-05-16 11:00+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: product_last_mrp_info +#: model:ir.model.fields,field_description:product_last_mrp_info.field_product_product__last_mrp_id +msgid "Last Manufacturing Order" +msgstr "" + +#. module: product_last_mrp_info +#: model:ir.model.fields,field_description:product_last_mrp_info.field_product_product__last_mrp_date +msgid "Last Manufacturing Order Date" +msgstr "" + +#. module: product_last_mrp_info +#: model_terms:ir.ui.view,arch_db:product_last_mrp_info.product_normal_form_view +msgid "MRP" +msgstr "" + +#. module: product_last_mrp_info +#: model:ir.model,name:product_last_mrp_info.model_product_product +msgid "Product Variant" +msgstr "" diff --git a/product_last_mrp_info/models/__init__.py b/product_last_mrp_info/models/__init__.py new file mode 100644 index 000000000..5c74c8c30 --- /dev/null +++ b/product_last_mrp_info/models/__init__.py @@ -0,0 +1 @@ +from . import product_product diff --git a/product_last_mrp_info/models/product_product.py b/product_last_mrp_info/models/product_product.py new file mode 100644 index 000000000..ecbb45b14 --- /dev/null +++ b/product_last_mrp_info/models/product_product.py @@ -0,0 +1,29 @@ +# Copyright 2024 Alfredo de la Fuente - AvanzOSC +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from odoo import fields, models + + +class ProductProduct(models.Model): + _inherit = "product.product" + + last_mrp_id = fields.Many2one( + string="Last Manufacturing Order", + comodel_name="mrp.production", + compute="_compute_last_mrp_info", + ) + last_mrp_date = fields.Datetime( + string="Last Manufacturing Order Date", compute="_compute_last_mrp_info" + ) + + def _compute_last_mrp_info(self): + for product in self: + production = self.env["mrp.production"].search( + [("product_id", "=", product.id), ("state", "=", "done")], + limit=1, + order="date_finished desc", + ) + product._get_last_mrp_info(production) + + def _get_last_mrp_info(self, production): + self.last_mrp_id = production.id + self.last_mrp_date = production.date_finished diff --git a/product_last_mrp_info/views/product_product_views.xml b/product_last_mrp_info/views/product_product_views.xml new file mode 100644 index 000000000..9fc18a558 --- /dev/null +++ b/product_last_mrp_info/views/product_product_views.xml @@ -0,0 +1,37 @@ + + + product.product + + + + + + + + + + + + + + + product.product + + + + + + + + + diff --git a/setup/product_last_mrp_info/odoo/addons/product_last_mrp_info b/setup/product_last_mrp_info/odoo/addons/product_last_mrp_info new file mode 120000 index 000000000..01f0d7b41 --- /dev/null +++ b/setup/product_last_mrp_info/odoo/addons/product_last_mrp_info @@ -0,0 +1 @@ +../../../../product_last_mrp_info \ No newline at end of file diff --git a/setup/product_last_mrp_info/setup.py b/setup/product_last_mrp_info/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/product_last_mrp_info/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)