diff --git a/rma_lot/README.rst b/rma_lot/README.rst new file mode 100644 index 000000000..11e9384a4 --- /dev/null +++ b/rma_lot/README.rst @@ -0,0 +1,96 @@ +======= +Rma Lot +======= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:179ae979736d64a8afa520769acb7d060690a304e812587c70bf43b4542d2ea6 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Frma-lightgray.png?logo=github + :target: https://github.com/OCA/rma/tree/17.0/rma_lot + :alt: OCA/rma +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/rma-17-0/rma-17-0-rma_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/rma&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Tracking returned products by lot or serial number is crucial for +businesses that require precise monitoring, especially in industries +where quality control, compliance, and inventory accuracy are critical. +By enabling returns to be tracked by lot or serial numbers, this module +ensures that each returned item is handled correctly, reducing the risk +of errors, fraud, or compliance issues. + +This level of detail is essential for maintaining the integrity of +inventory records, meeting regulatory requirements, and providing +excellent customer service. + +The module extends the existing RMA functionality by adding a lot field +to the RMA model, allowing users to associate returns with specific lot +or serial numbers. This enhancement enforces stricter controls over +return processes, ensuring that only the correct items are accepted +during a return and that inventory records remain accurate. + +**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 +------- + +* ACSONE SA/NV +* BCIM + +Contributors +------------ + +- Jacques-Etienne Baudoux - BCIM je@bcim.be +- Souheil Bejaoui - ACSONE SA/NV souheil.bejaoui@acsone.eu +- `APSL-Nagarro `__: + + - Antoni Marroig amarroig@apsl.net + +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/rma `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/rma_lot/__init__.py b/rma_lot/__init__.py new file mode 100644 index 000000000..aee8895e7 --- /dev/null +++ b/rma_lot/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizards diff --git a/rma_lot/__manifest__.py b/rma_lot/__manifest__.py new file mode 100644 index 000000000..7954e259b --- /dev/null +++ b/rma_lot/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2024 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Rma Lot", + "summary": """ + Manage lot in RMA""", + "version": "17.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,BCIM,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/rma", + "depends": ["rma", "stock_picking_return_lot"], + "data": ["views/rma.xml"], + "demo": [], +} diff --git a/rma_lot/i18n/rma_lot.pot b/rma_lot/i18n/rma_lot.pot new file mode 100644 index 000000000..0327520fb --- /dev/null +++ b/rma_lot/i18n/rma_lot.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * rma_lot +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \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: rma_lot +#: model:ir.model.fields,field_description:rma_lot.field_rma__lot_id +msgid "Lot/Serial Number" +msgstr "" + +#. module: rma_lot +#: model:ir.model.fields,field_description:rma_lot.field_rma__lots_visible +msgid "Lots Visible" +msgstr "" + +#. module: rma_lot +#: model:ir.model,name:rma_lot.model_rma +msgid "RMA" +msgstr "" + +#. module: rma_lot +#: model:ir.model,name:rma_lot.model_stock_return_picking_line +msgid "Return Picking Line" +msgstr "" diff --git a/rma_lot/models/__init__.py b/rma_lot/models/__init__.py new file mode 100644 index 000000000..0031f431f --- /dev/null +++ b/rma_lot/models/__init__.py @@ -0,0 +1 @@ +from . import rma diff --git a/rma_lot/models/rma.py b/rma_lot/models/rma.py new file mode 100644 index 000000000..f61364bb7 --- /dev/null +++ b/rma_lot/models/rma.py @@ -0,0 +1,40 @@ +# Copyright 2024 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class Rma(models.Model): + _inherit = "rma" + + lot_id = fields.Many2one( + comodel_name="stock.lot", + string="Lot/Serial Number", + domain="[('product_id', '=?', product_id)]", + compute="_compute_lot_id", + store=True, + readonly=False, + ) + lots_visible = fields.Boolean(compute="_compute_lots_visible") + + @api.depends("product_id.tracking") + def _compute_lots_visible(self): + for rec in self: + rec.lots_visible = rec.product_id.tracking != "none" + + def _prepare_reception_procurement_vals(self, group=None): + vals = super()._prepare_reception_procurement_vals(group=group) + vals["restrict_lot_id"] = self.lot_id.id + return vals + + @api.depends("move_id", "lot_id") + def _compute_product_id(self): + res = super()._compute_product_id() + for rec in self: + if not rec.move_id and rec.lot_id: + self.product_id = rec.lot_id.product_id + return res + + @api.depends("product_id") + def _compute_lot_id(self): + self.update({"lot_id": False}) diff --git a/rma_lot/pyproject.toml b/rma_lot/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/rma_lot/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/rma_lot/readme/CONTRIBUTORS.md b/rma_lot/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..e2f3a5dac --- /dev/null +++ b/rma_lot/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Jacques-Etienne Baudoux - BCIM +- Souheil Bejaoui - ACSONE SA/NV +- [APSL-Nagarro](): + - Antoni Marroig diff --git a/rma_lot/readme/DESCRIPTION.md b/rma_lot/readme/DESCRIPTION.md new file mode 100644 index 000000000..637ea4605 --- /dev/null +++ b/rma_lot/readme/DESCRIPTION.md @@ -0,0 +1,15 @@ +Tracking returned products by lot or serial number is crucial for businesses +that require precise monitoring, especially in industries where quality control, +compliance, and inventory accuracy are critical. +By enabling returns to be tracked by lot or serial numbers, this module ensures +that each returned item is handled correctly, reducing the risk of errors, +fraud, or compliance issues. + +This level of detail is essential for maintaining the integrity of inventory +records, meeting regulatory requirements, and providing excellent customer service. + +The module extends the existing RMA functionality by adding a lot field to the +RMA model, allowing users to associate returns with specific lot or serial numbers. +This enhancement enforces stricter controls over return processes, +ensuring that only the correct items are accepted during a return and that +inventory records remain accurate. diff --git a/rma_lot/static/description/icon.png b/rma_lot/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/rma_lot/static/description/icon.png differ diff --git a/rma_lot/static/description/index.html b/rma_lot/static/description/index.html new file mode 100644 index 000000000..c618b468e --- /dev/null +++ b/rma_lot/static/description/index.html @@ -0,0 +1,442 @@ + + + + + +Rma Lot + + + +
+

Rma Lot

+ + +

Beta License: AGPL-3 OCA/rma Translate me on Weblate Try me on Runboat

+

Tracking returned products by lot or serial number is crucial for +businesses that require precise monitoring, especially in industries +where quality control, compliance, and inventory accuracy are critical. +By enabling returns to be tracked by lot or serial numbers, this module +ensures that each returned item is handled correctly, reducing the risk +of errors, fraud, or compliance issues.

+

This level of detail is essential for maintaining the integrity of +inventory records, meeting regulatory requirements, and providing +excellent customer service.

+

The module extends the existing RMA functionality by adding a lot field +to the RMA model, allowing users to associate returns with specific lot +or serial numbers. This enhancement enforces stricter controls over +return processes, ensuring that only the correct items are accepted +during a return and that inventory records remain accurate.

+

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

+
    +
  • ACSONE SA/NV
  • +
  • BCIM
  • +
+
+
+

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.

+

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

+

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

+
+
+
+ + diff --git a/rma_lot/tests/__init__.py b/rma_lot/tests/__init__.py new file mode 100644 index 000000000..25cf26216 --- /dev/null +++ b/rma_lot/tests/__init__.py @@ -0,0 +1 @@ +from . import test_rma_lot diff --git a/rma_lot/tests/test_rma_lot.py b/rma_lot/tests/test_rma_lot.py new file mode 100644 index 000000000..bff6831f5 --- /dev/null +++ b/rma_lot/tests/test_rma_lot.py @@ -0,0 +1,102 @@ +# Copyright 2020 Iryna Vyshnevska Camptocamp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import Command +from odoo.tests.common import Form, TransactionCase + + +class TestRMALot(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.picking_obj = cls.env["stock.picking"] + partner = cls.env["res.partner"].create({"name": "Test"}) + cls.product = cls.env["product.product"].create( + {"name": "test_product", "type": "product", "tracking": "lot"} + ) + cls.lot_1 = cls.env["stock.lot"].create( + {"name": "000001", "product_id": cls.product.id} + ) + cls.lot_2 = cls.env["stock.lot"].create( + {"name": "000002", "product_id": cls.product.id} + ) + picking_type_out = cls.env.ref("stock.picking_type_out") + stock_location = cls.env.ref("stock.stock_location_stock") + customer_location = cls.env.ref("stock.stock_location_customers") + cls.env["stock.quant"]._update_available_quantity( + cls.product, stock_location, 1, lot_id=cls.lot_1 + ) + cls.env["stock.quant"]._update_available_quantity( + cls.product, stock_location, 2, lot_id=cls.lot_2 + ) + cls.picking = cls.picking_obj.create( + { + "partner_id": partner.id, + "picking_type_id": picking_type_out.id, + "location_id": stock_location.id, + "location_dest_id": customer_location.id, + "move_ids": [ + Command.create( + { + "name": cls.product.name, + "product_id": cls.product.id, + "product_uom_qty": 3, + "product_uom": cls.product.uom_id.id, + "location_id": stock_location.id, + "location_dest_id": customer_location.id, + }, + ) + ], + } + ) + cls.picking.action_confirm() + cls.picking.action_assign() + cls.picking.move_ids.picked = True + cls.picking._action_done() + cls.operation = cls.env.ref("rma.rma_operation_replace") + + @classmethod + def create_return_wiz(cls): + return ( + cls.env["stock.return.picking"] + .with_context(active_id=cls.picking.id, active_model="stock.picking") + .create({"create_rma": True}) + ) + + def test_00(self): + """ + Check the process of creating RMAs when returning products tracked by lot + - The correct number of RMAs is created + - The RMAs are correctly associated with the lot + """ + stock_return_picking_form = Form( + self.env["stock.return.picking"].with_context( + active_ids=self.picking.ids, + active_id=self.picking.id, + active_model="stock.picking", + ) + ) + stock_return_picking_form.create_rma = True + return_wizard = stock_return_picking_form.save() + self.assertEqual(len(return_wizard.product_return_moves), 2) + return_wizard.create_returns() + self.assertEqual(self.picking.rma_count, 2) + rmas = self.picking.move_ids.rma_ids + rma_lot_1 = rmas.filtered(lambda r, lot=self.lot_1: r.lot_id == lot) + rma_lot_2 = rmas.filtered(lambda r, lot=self.lot_2: r.lot_id == lot) + self.assertTrue(rma_lot_1) + self.assertEqual(rma_lot_1.reception_move_id.restrict_lot_id, self.lot_1) + self.assertEqual(rma_lot_1.reception_move_id.state, "assigned") + self.assertEqual(rma_lot_1.reception_move_id.move_line_ids.lot_id, self.lot_1) + self.assertTrue(rma_lot_2) + self.assertEqual(rma_lot_2.reception_move_id.restrict_lot_id, self.lot_2) + self.assertEqual(rma_lot_2.reception_move_id.state, "assigned") + self.assertEqual(rma_lot_2.reception_move_id.move_line_ids.lot_id, self.lot_2) + + def test_rma_form(self): + rma_form = Form(self.env["rma"]) + self.assertFalse(rma_form.product_id) + rma_form.lot_id = self.lot_1 + self.assertEqual(rma_form.product_id, self.product) + rma_form.product_id = self.env.ref("product.product_product_4") + self.assertFalse(rma_form.lot_id) diff --git a/rma_lot/views/rma.xml b/rma_lot/views/rma.xml new file mode 100644 index 000000000..58881c745 --- /dev/null +++ b/rma_lot/views/rma.xml @@ -0,0 +1,41 @@ + + + + + + rma + + + + + + + + + + + rma + + + + + + + + + + rma + + + + + + + + + diff --git a/rma_lot/wizards/__init__.py b/rma_lot/wizards/__init__.py new file mode 100644 index 000000000..2ed06ea13 --- /dev/null +++ b/rma_lot/wizards/__init__.py @@ -0,0 +1 @@ +from . import stock_return_picking_line diff --git a/rma_lot/wizards/stock_return_picking_line.py b/rma_lot/wizards/stock_return_picking_line.py new file mode 100644 index 000000000..9ce1b1a4c --- /dev/null +++ b/rma_lot/wizards/stock_return_picking_line.py @@ -0,0 +1,13 @@ +# Copyright 2024 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockReturnPickingLine(models.TransientModel): + _inherit = "stock.return.picking.line" + + def _prepare_rma_vals(self): + vals = super()._prepare_rma_vals() + vals.update({"lot_id": self.lot_id.id}) + return vals