diff --git a/repair_stock_move_restrict_lot/README.rst b/repair_stock_move_restrict_lot/README.rst new file mode 100644 index 00000000..0d02b651 --- /dev/null +++ b/repair_stock_move_restrict_lot/README.rst @@ -0,0 +1,92 @@ +============================== +Repair Stock Move Restrict Lot +============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c94e72916093650c40fe3428b8f443013e3897f3df7b2c59d27bb45283e50fa7 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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%2Frepair-lightgray.png?logo=github + :target: https://github.com/OCA/repair/tree/15.0/repair_stock_move_restrict_lot + :alt: OCA/repair +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/repair-15-0/repair-15-0-repair_stock_move_restrict_lot + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/repair&target_branch=15.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Glue module between repair_stock_move and stock_restrict_lot. +It assigns the repair lot to the stock moves on creation. Otherwise in the +_action_assign it may reserve the incorrect quant and then and error is raised +when unreserving the quant: https://github.com/odoo/odoo/blob/15.0/addons/stock/models/stock_move_line.py#L388 + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Aaron Henriquez + +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. + +.. |maintainer-AaronHForgeFlow| image:: https://github.com/AaronHForgeFlow.png?size=40px + :target: https://github.com/AaronHForgeFlow + :alt: AaronHForgeFlow + +Current `maintainer `__: + +|maintainer-AaronHForgeFlow| + +This module is part of the `OCA/repair `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/repair_stock_move_restrict_lot/__init__.py b/repair_stock_move_restrict_lot/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/repair_stock_move_restrict_lot/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/repair_stock_move_restrict_lot/__manifest__.py b/repair_stock_move_restrict_lot/__manifest__.py new file mode 100644 index 00000000..0ca31920 --- /dev/null +++ b/repair_stock_move_restrict_lot/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2024 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +{ + "name": "Repair Stock Move Restrict Lot", + "version": "15.0.1.0.0", + "development_status": "Alpha", + "license": "AGPL-3", + "category": "Repair", + "summary": "Glue module to restrict lot in stock moves of repair orders", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/repair", + "depends": ["repair_stock_move", "stock_restrict_lot"], + "installable": True, + "application": False, + "maintainers": ["AaronHForgeFlow"], +} diff --git a/repair_stock_move_restrict_lot/models/__init__.py b/repair_stock_move_restrict_lot/models/__init__.py new file mode 100644 index 00000000..2251f67d --- /dev/null +++ b/repair_stock_move_restrict_lot/models/__init__.py @@ -0,0 +1 @@ +from . import repair_order diff --git a/repair_stock_move_restrict_lot/models/repair_order.py b/repair_stock_move_restrict_lot/models/repair_order.py new file mode 100644 index 00000000..c9b5ace9 --- /dev/null +++ b/repair_stock_move_restrict_lot/models/repair_order.py @@ -0,0 +1,11 @@ +from odoo import models + + +class RepairOrder(models.Model): + _inherit = "repair.order" + + def _prepare_repair_stock_move(self): + vals = super()._prepare_repair_stock_move() + if self.lot_id: + vals["restrict_lot_id"] = self.lot_id.id + return vals diff --git a/repair_stock_move_restrict_lot/readme/CONTRIBUTORS.rst b/repair_stock_move_restrict_lot/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..9fa71265 --- /dev/null +++ b/repair_stock_move_restrict_lot/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Aaron Henriquez diff --git a/repair_stock_move_restrict_lot/readme/DESCRIPTION.rst b/repair_stock_move_restrict_lot/readme/DESCRIPTION.rst new file mode 100644 index 00000000..045c38c9 --- /dev/null +++ b/repair_stock_move_restrict_lot/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +Glue module between repair_stock_move and stock_restrict_lot. +It assigns the repair lot to the stock moves on creation. Otherwise in the +_action_assign it may reserve the incorrect quant and then and error is raised +when unreserving the quant: https://github.com/odoo/odoo/blob/15.0/addons/stock/models/stock_move_line.py#L388 diff --git a/repair_stock_move_restrict_lot/static/description/icon.png b/repair_stock_move_restrict_lot/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/repair_stock_move_restrict_lot/static/description/icon.png differ diff --git a/repair_stock_move_restrict_lot/static/description/index.html b/repair_stock_move_restrict_lot/static/description/index.html new file mode 100644 index 00000000..10505fa4 --- /dev/null +++ b/repair_stock_move_restrict_lot/static/description/index.html @@ -0,0 +1,434 @@ + + + + + +Repair Stock Move Restrict Lot + + + +
+

Repair Stock Move Restrict Lot

+ + +

Alpha License: AGPL-3 OCA/repair Translate me on Weblate Try me on Runboat

+

Glue module between repair_stock_move and stock_restrict_lot. +It assigns the repair lot to the stock moves on creation. Otherwise in the +_action_assign it may reserve the incorrect quant and then and error is raised +when unreserving the quant: https://github.com/odoo/odoo/blob/15.0/addons/stock/models/stock_move_line.py#L388

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

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.

+

Current maintainer:

+

AaronHForgeFlow

+

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

+

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

+
+
+
+ + diff --git a/repair_stock_move_restrict_lot/tests/__init__.py b/repair_stock_move_restrict_lot/tests/__init__.py new file mode 100644 index 00000000..71b6b8bc --- /dev/null +++ b/repair_stock_move_restrict_lot/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2021 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from . import test_repair_stock_move diff --git a/repair_stock_move_restrict_lot/tests/test_repair_stock_move.py b/repair_stock_move_restrict_lot/tests/test_repair_stock_move.py new file mode 100644 index 00000000..c918a420 --- /dev/null +++ b/repair_stock_move_restrict_lot/tests/test_repair_stock_move.py @@ -0,0 +1,88 @@ +from odoo.tests import common + + +class TestRepairStockMove(common.TransactionCase): + @classmethod + def setUpClass(cls): + super(TestRepairStockMove, cls).setUpClass() + # Models + cls.StockProductionLot = cls.env["stock.production.lot"] + cls.StockQuant = cls.env["stock.quant"] + # Partners + cls.res_partner_1 = cls.env["res.partner"].create({"name": "Wood Corner"}) + + cls.env.user.groups_id |= cls.env.ref("stock.group_stock_user") + + # setup for the tests with lots + # we create several lots qith qty + # we want to check the system will get the correct lot + cls.product_lot = cls.env["product.product"].create( + { + "name": "Acoustic Magic Bloc", + "list_price": 2950.0, + "type": "product", + "tracking": "serial", + } + ) + cls.lot = cls.StockProductionLot.create( + { + "product_id": cls.product_lot.id, + "name": "Lot A", + "company_id": cls.env.company.id, + } + ) + cls.lot2 = cls.lot.copy({"name": "Lot B"}) + cls.lot3 = cls.lot.copy({"name": "Lot C"}) + cls.stock_location_stock = cls.env.ref("stock.stock_location_stock") + cls.StockQuant.create( + { + "location_id": cls.stock_location_stock.id, + "product_id": cls.product_lot.id, + "lot_id": cls.lot.id, + "inventory_quantity": 1, + } + ).action_apply_inventory() + cls.StockQuant.create( + { + "location_id": cls.stock_location_stock.id, + "product_id": cls.product_lot.id, + "lot_id": cls.lot2.id, + "inventory_quantity": 1, + } + ).action_apply_inventory() + cls.StockQuant.create( + { + "location_id": cls.stock_location_stock.id, + "product_id": cls.product_lot.id, + "lot_id": cls.lot3.id, + "inventory_quantity": 1, + } + ).action_apply_inventory() + cls.repair_with_lot = cls.env["repair.order"].create( + { + "invoice_method": "none", + "user_id": False, + "product_id": cls.product_lot.id, + "product_uom": cls.env.ref("uom.product_uom_unit").id, + "location_id": cls.stock_location_stock.id, + "lot_id": cls.lot3.id, + "partner_id": cls.res_partner_1.id, + } + ) + + def test_stock_move_lot_reservation(self): + self.repair_with_lot.action_validate() + # Start Repair + self.repair_with_lot.action_repair_start() + # check stock move status and lot_id + for move in self.repair_with_lot.mapped("stock_move_ids"): + self.assertEqual( + move.state, + "assigned", + "Generated stock move state should be assigned", + ) + self.assertEqual( + move.move_line_ids.lot_id, + self.repair_with_lot.lot_id, + "Generated stock move lot_id should be the same as repair order", + ) diff --git a/setup/repair_stock_move_restrict_lot/odoo/addons/repair_stock_move_restrict_lot b/setup/repair_stock_move_restrict_lot/odoo/addons/repair_stock_move_restrict_lot new file mode 120000 index 00000000..6d411009 --- /dev/null +++ b/setup/repair_stock_move_restrict_lot/odoo/addons/repair_stock_move_restrict_lot @@ -0,0 +1 @@ +../../../../repair_stock_move_restrict_lot \ No newline at end of file diff --git a/setup/repair_stock_move_restrict_lot/setup.py b/setup/repair_stock_move_restrict_lot/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/repair_stock_move_restrict_lot/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)