diff --git a/mrp_lot_production_date/README.rst b/mrp_lot_production_date/README.rst new file mode 100644 index 000000000..0e358446f --- /dev/null +++ b/mrp_lot_production_date/README.rst @@ -0,0 +1,91 @@ +======================= +MRP Lot Production Date +======================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github + :target: https://github.com/OCA/manufacture/tree/14.0/mrp_lot_production_date + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-mrp_lot_production_date + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/129/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module automatically set a production date on lots/SN produced through manufacturing orders. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To get production dates automatically set on produced lots you need to configure +your products with the *Production Date* option in the *Inventory / Traceability* +section: + +.. image:: https://raw.githubusercontent.com/OCA/stock-logistics-workflow/5c13b66f989ce3b02a2098cee272cc36fad49723/stock_lot_production_date/static/description/product.png + +Then when a lot is produced through a manufacturing order it will get a production 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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Sébastien Alix + +Other credits +~~~~~~~~~~~~~ + +**Financial support** + +* Cosanum + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/manufacture `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mrp_lot_production_date/__init__.py b/mrp_lot_production_date/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/mrp_lot_production_date/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mrp_lot_production_date/__manifest__.py b/mrp_lot_production_date/__manifest__.py new file mode 100644 index 000000000..f65c12501 --- /dev/null +++ b/mrp_lot_production_date/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2023 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +{ + "name": "MRP Lot Production Date", + "Summary": "Set a production date automatically on produced lots/SN.", + "version": "14.0.1.0.0", + "author": "Camptocamp, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/manufacture", + "category": "Manufacturing", + "depends": [ + # core + "mrp", + # OCA/stock-logistics-workflow + "stock_lot_production_date", + ], + "installable": True, + "auto_install": True, + "license": "AGPL-3", +} diff --git a/mrp_lot_production_date/models/__init__.py b/mrp_lot_production_date/models/__init__.py new file mode 100644 index 000000000..a9e5f13e4 --- /dev/null +++ b/mrp_lot_production_date/models/__init__.py @@ -0,0 +1 @@ +from . import mrp_production diff --git a/mrp_lot_production_date/models/mrp_production.py b/mrp_lot_production_date/models/mrp_production.py new file mode 100644 index 000000000..3e239f163 --- /dev/null +++ b/mrp_lot_production_date/models/mrp_production.py @@ -0,0 +1,15 @@ +# Copyright 2023 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import fields, models + + +class MrpProduction(models.Model): + _inherit = "mrp.production" + + def _post_inventory(self, cancel_backorder=False): + res = super()._post_inventory(cancel_backorder=cancel_backorder) + for order in self: + if order.lot_producing_id and not order.lot_producing_id.production_date: + order.lot_producing_id.production_date = fields.Datetime.now() + return res diff --git a/mrp_lot_production_date/readme/CONTRIBUTORS.rst b/mrp_lot_production_date/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..c452804a9 --- /dev/null +++ b/mrp_lot_production_date/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Sébastien Alix diff --git a/mrp_lot_production_date/readme/CREDITS.rst b/mrp_lot_production_date/readme/CREDITS.rst new file mode 100644 index 000000000..060833d87 --- /dev/null +++ b/mrp_lot_production_date/readme/CREDITS.rst @@ -0,0 +1,3 @@ +**Financial support** + +* Cosanum diff --git a/mrp_lot_production_date/readme/DESCRIPTION.rst b/mrp_lot_production_date/readme/DESCRIPTION.rst new file mode 100644 index 000000000..da0384f10 --- /dev/null +++ b/mrp_lot_production_date/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module automatically set a production date on lots/SN produced through the +validation of manufacturing orders. diff --git a/mrp_lot_production_date/readme/USAGE.rst b/mrp_lot_production_date/readme/USAGE.rst new file mode 100644 index 000000000..299abeef0 --- /dev/null +++ b/mrp_lot_production_date/readme/USAGE.rst @@ -0,0 +1,5 @@ +To get production dates automatically set on produced lots you need to configure +your products to be tracked by lots or serial numbers. + +Then at the validation of a manufacturing order the production date will be set +automatically on the produced lot. diff --git a/mrp_lot_production_date/static/description/index.html b/mrp_lot_production_date/static/description/index.html new file mode 100644 index 000000000..2df13f81d --- /dev/null +++ b/mrp_lot_production_date/static/description/index.html @@ -0,0 +1,436 @@ + + + + + + +MRP Lot Production Date + + + +
+

MRP Lot Production Date

+ + +

Beta License: AGPL-3 OCA/manufacture Translate me on Weblate Try me on Runbot

+

This module automatically set a production date on lots/SN produced through manufacturing orders.

+

Table of contents

+ +
+

Usage

+

To get production dates automatically set on produced lots you need to configure +your products with the Production Date option in the Inventory / Traceability +section:

+https://raw.githubusercontent.com/OCA/stock-logistics-workflow/5c13b66f989ce3b02a2098cee272cc36fad49723/stock_lot_production_date/static/description/product.png +

Then when a lot is produced through a manufacturing order it will get a production 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 smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

Financial support

+
    +
  • Cosanum
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/manufacture project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/mrp_lot_production_date/tests/__init__.py b/mrp_lot_production_date/tests/__init__.py new file mode 100644 index 000000000..cc8fc0208 --- /dev/null +++ b/mrp_lot_production_date/tests/__init__.py @@ -0,0 +1 @@ +from . import test_production_date diff --git a/mrp_lot_production_date/tests/test_production_date.py b/mrp_lot_production_date/tests/test_production_date.py new file mode 100644 index 000000000..d4f265f70 --- /dev/null +++ b/mrp_lot_production_date/tests/test_production_date.py @@ -0,0 +1,35 @@ +# Copyright 2023 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo.tests.common import Form, SavepointCase + + +class TestMrpLotProductionDate(SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.bom = cls.env.ref("mrp.mrp_bom_table_top") # Tracked by S/N + + @classmethod + def _create_manufacturing_order(cls, bom, product_qty=1): + with Form(cls.env["mrp.production"]) as form: + form.bom_id = bom + form.product_qty = product_qty + order = form.save() + order.invalidate_cache() + return order + + @classmethod + def _validate_manufacturing_order(cls, order): + order.action_confirm() + order.action_assign() + # To ease the test we generate the lot manually, but this could be + # handled automatically by calling the 'Immediate production' wizard + order.action_generate_serial() + order.button_mark_done() + + def test_lot_production_date(self): + order = self._create_manufacturing_order(self.bom) + self._validate_manufacturing_order(order) + self.assertTrue(order.lot_producing_id.production_date) diff --git a/setup/mrp_lot_production_date/odoo/addons/mrp_lot_production_date b/setup/mrp_lot_production_date/odoo/addons/mrp_lot_production_date new file mode 120000 index 000000000..ce51c1b7c --- /dev/null +++ b/setup/mrp_lot_production_date/odoo/addons/mrp_lot_production_date @@ -0,0 +1 @@ +../../../../mrp_lot_production_date \ No newline at end of file diff --git a/setup/mrp_lot_production_date/setup.py b/setup/mrp_lot_production_date/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/mrp_lot_production_date/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)