diff --git a/setup/stock_inventory_justification/odoo/addons/stock_inventory_justification b/setup/stock_inventory_justification/odoo/addons/stock_inventory_justification new file mode 120000 index 000000000..86563f133 --- /dev/null +++ b/setup/stock_inventory_justification/odoo/addons/stock_inventory_justification @@ -0,0 +1 @@ +../../../../stock_inventory_justification \ No newline at end of file diff --git a/setup/stock_inventory_justification/setup.py b/setup/stock_inventory_justification/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_inventory_justification/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_inventory_justification/README.rst b/stock_inventory_justification/README.rst new file mode 100644 index 000000000..93273f38f --- /dev/null +++ b/stock_inventory_justification/README.rst @@ -0,0 +1,95 @@ +============================= +Stock Inventory Justification +============================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:077ccd4ba446ba2259f07d5c199568e4210d8fbd33febc071b7c66a52320674b + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fstock--logistics--warehouse-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_inventory_justification + :alt: OCA/stock-logistics-warehouse +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_inventory_justification + :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/stock-logistics-warehouse&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to set justifications on inventories. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +* In the stock inventory list view, fill in justification(s) +* Validate the inventory, the justifications will be added to the stock moves + and displayed on the move lines + +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 + +Contributors +~~~~~~~~~~~~ + +* Thomas Binsfeld +* Denis Roussel + +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-rousseldenis| image:: https://github.com/rousseldenis.png?size=40px + :target: https://github.com/rousseldenis + :alt: rousseldenis +.. |maintainer-ThomasBinsfeld| image:: https://github.com/ThomasBinsfeld.png?size=40px + :target: https://github.com/ThomasBinsfeld + :alt: ThomasBinsfeld + +Current `maintainers `__: + +|maintainer-rousseldenis| |maintainer-ThomasBinsfeld| + +This module is part of the `OCA/stock-logistics-warehouse `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_inventory_justification/__init__.py b/stock_inventory_justification/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/stock_inventory_justification/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_inventory_justification/__manifest__.py b/stock_inventory_justification/__manifest__.py new file mode 100644 index 000000000..3f7081114 --- /dev/null +++ b/stock_inventory_justification/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Inventory Justification", + "summary": """ + This module allows to set justification on inventories""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "maintainers": ["rousseldenis", "ThomasBinsfeld"], + "depends": ["stock"], + "data": [ + "security/acl_stock_inventory_justification.xml", + "views/stock_move_line.xml", + "views/stock_quant.xml", + "views/stock_inventory_justification.xml", + ], +} diff --git a/stock_inventory_justification/i18n/stock_inventory_justification.pot b/stock_inventory_justification/i18n/stock_inventory_justification.pot new file mode 100644 index 000000000..4b35ce43b --- /dev/null +++ b/stock_inventory_justification/i18n/stock_inventory_justification.pot @@ -0,0 +1,85 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_inventory_justification +# +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: stock_inventory_justification +#: model:ir.model.fields,field_description:stock_inventory_justification.field_stock_inventory_justification__active +msgid "Active" +msgstr "" + +#. module: stock_inventory_justification +#: model:ir.model.fields,field_description:stock_inventory_justification.field_stock_inventory_justification__create_uid +msgid "Created by" +msgstr "" + +#. module: stock_inventory_justification +#: model:ir.model.fields,field_description:stock_inventory_justification.field_stock_inventory_justification__create_date +msgid "Created on" +msgstr "" + +#. module: stock_inventory_justification +#: model:ir.model.fields,field_description:stock_inventory_justification.field_stock_inventory_justification__display_name +msgid "Display Name" +msgstr "" + +#. module: stock_inventory_justification +#: model:ir.model.fields,field_description:stock_inventory_justification.field_stock_inventory_justification__id +msgid "ID" +msgstr "" + +#. module: stock_inventory_justification +#: model:ir.model,name:stock_inventory_justification.model_stock_inventory +msgid "Inventory" +msgstr "" + +#. module: stock_inventory_justification +#: model:ir.model,name:stock_inventory_justification.model_stock_inventory_justification +msgid "Inventory justification" +msgstr "" + +#. module: stock_inventory_justification +#: model:ir.actions.act_window,name:stock_inventory_justification.stock_inventory_justification_act_window +#: model:ir.ui.menu,name:stock_inventory_justification.silog_stock_inventory_justification_menu +msgid "Inventory justifications" +msgstr "" + +#. module: stock_inventory_justification +#: model:ir.model.fields,field_description:stock_inventory_justification.field_stock_inventory__justification_ids +msgid "Justifications" +msgstr "" + +#. module: stock_inventory_justification +#: model:ir.model.fields,field_description:stock_inventory_justification.field_stock_inventory_justification____last_update +msgid "Last Modified on" +msgstr "" + +#. module: stock_inventory_justification +#: model:ir.model.fields,field_description:stock_inventory_justification.field_stock_inventory_justification__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: stock_inventory_justification +#: model:ir.model.fields,field_description:stock_inventory_justification.field_stock_inventory_justification__write_date +msgid "Last Updated on" +msgstr "" + +#. module: stock_inventory_justification +#: model:ir.model.fields,field_description:stock_inventory_justification.field_stock_inventory_justification__name +msgid "Name" +msgstr "" + +#. module: stock_inventory_justification +#: model:ir.model.constraint,message:stock_inventory_justification.constraint_stock_inventory_justification_unique_name +msgid "This stock inventory justification already exists." +msgstr "" diff --git a/stock_inventory_justification/models/__init__.py b/stock_inventory_justification/models/__init__.py new file mode 100644 index 000000000..61f4ec10e --- /dev/null +++ b/stock_inventory_justification/models/__init__.py @@ -0,0 +1,4 @@ +from . import stock_inventory_justification +from . import stock_move +from . import stock_quant +from . import stock_move_line diff --git a/stock_inventory_justification/models/stock_inventory_justification.py b/stock_inventory_justification/models/stock_inventory_justification.py new file mode 100644 index 000000000..70db5ac01 --- /dev/null +++ b/stock_inventory_justification/models/stock_inventory_justification.py @@ -0,0 +1,20 @@ +# Copyright 2019 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class StockInventoryJustification(models.Model): + _name = "stock.inventory.justification" + _description = "Inventory justification" + + _sql_constraints = [ + ( + "unique_name", + "EXCLUDE (name WITH =) WHERE (active = True)", + "This stock inventory justification already exists.", + ), + ] + + name = fields.Char(required=True) + active = fields.Boolean(default=True) diff --git a/stock_inventory_justification/models/stock_move.py b/stock_inventory_justification/models/stock_move.py new file mode 100644 index 000000000..d1b9650a1 --- /dev/null +++ b/stock_inventory_justification/models/stock_move.py @@ -0,0 +1,18 @@ +# Copyright 2024 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class StockMove(models.Model): + _inherit = "stock.move" + + inventory_justification_ids = fields.Many2many( + string="Justifications", + help="Inventory justifications", + comodel_name="stock.inventory.justification", + relation="stock_move_inventory_justification_rel", + column1="move_id", + column2="justification_id", + readonly=True, + ) diff --git a/stock_inventory_justification/models/stock_move_line.py b/stock_inventory_justification/models/stock_move_line.py new file mode 100644 index 000000000..d09804864 --- /dev/null +++ b/stock_inventory_justification/models/stock_move_line.py @@ -0,0 +1,17 @@ +# Copyright 2024 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class StockMoveLine(models.Model): + _inherit = "stock.move.line" + + inventory_justification_ids = fields.Many2many( + string="Justifications", + help="Inventory justifications", + comodel_name="stock.inventory.justification", + related="move_id.inventory_justification_ids", + store=False, + readonly=True, + ) diff --git a/stock_inventory_justification/models/stock_quant.py b/stock_inventory_justification/models/stock_quant.py new file mode 100644 index 000000000..fee5dab58 --- /dev/null +++ b/stock_inventory_justification/models/stock_quant.py @@ -0,0 +1,42 @@ +# Copyright 2024 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class StockQuant(models.Model): + _inherit = "stock.quant" + + inventory_justification_ids = fields.Many2many( + string="Justifications", + help="Inventory justifications", + comodel_name="stock.inventory.justification", + relation="stock_quant_inventory_justification_rel", + column1="quant_id", + column2="justification_id", + ) + + def action_inventory_history(self): # pragma: no cover + action = super().action_inventory_history() + action["context"]["show_inventory_justifications"] = True + return action + + def _get_inventory_move_values(self, qty, location_id, location_dest_id, out=False): + res = super()._get_inventory_move_values( + qty, location_id, location_dest_id, out + ) + res["inventory_justification_ids"] = [ + (6, 0, self.inventory_justification_ids.ids) + ] + return res + + def _apply_inventory(self): + res = super()._apply_inventory() + self.write({"inventory_justification_ids": [(5,)]}) + return res + + @api.model + def _get_inventory_fields_write(self): + res = super()._get_inventory_fields_write() + res.append("inventory_justification_ids") + return res diff --git a/stock_inventory_justification/readme/CONTRIBUTORS.rst b/stock_inventory_justification/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..d02b48998 --- /dev/null +++ b/stock_inventory_justification/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Thomas Binsfeld +* Denis Roussel diff --git a/stock_inventory_justification/readme/DESCRIPTION.rst b/stock_inventory_justification/readme/DESCRIPTION.rst new file mode 100644 index 000000000..b0c0dac03 --- /dev/null +++ b/stock_inventory_justification/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to set justifications on inventories. diff --git a/stock_inventory_justification/readme/USAGE.rst b/stock_inventory_justification/readme/USAGE.rst new file mode 100644 index 000000000..cac1ce3c2 --- /dev/null +++ b/stock_inventory_justification/readme/USAGE.rst @@ -0,0 +1,3 @@ +* In the stock inventory list view, fill in justification(s) +* Validate the inventory, the justifications will be added to the stock moves + and displayed on the move lines diff --git a/stock_inventory_justification/security/acl_stock_inventory_justification.xml b/stock_inventory_justification/security/acl_stock_inventory_justification.xml new file mode 100644 index 000000000..479e49310 --- /dev/null +++ b/stock_inventory_justification/security/acl_stock_inventory_justification.xml @@ -0,0 +1,28 @@ + + + + + + stock.inventory.justification reader access + + + + + + + + + + stock.inventory.justification manager access + + + + + + + + diff --git a/stock_inventory_justification/static/description/icon.png b/stock_inventory_justification/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_inventory_justification/static/description/icon.png differ diff --git a/stock_inventory_justification/static/description/index.html b/stock_inventory_justification/static/description/index.html new file mode 100644 index 000000000..c16705177 --- /dev/null +++ b/stock_inventory_justification/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +Stock Inventory Justification + + + +
+

Stock Inventory Justification

+ + +

Beta License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runboat

+

This module allows to set justifications on inventories.

+

Table of contents

+ +
+

Usage

+
    +
  • In the stock inventory list view, fill in justification(s)
  • +
  • Validate the inventory, the justifications will be added to the stock moves +and displayed on the move lines
  • +
+
+
+

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
  • +
+
+
+

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 maintainers:

+

rousseldenis ThomasBinsfeld

+

This module is part of the OCA/stock-logistics-warehouse project on GitHub.

+

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

+
+
+
+ + diff --git a/stock_inventory_justification/tests/__init__.py b/stock_inventory_justification/tests/__init__.py new file mode 100644 index 000000000..b5be58a7a --- /dev/null +++ b/stock_inventory_justification/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_inventory_justification diff --git a/stock_inventory_justification/tests/test_stock_inventory_justification.py b/stock_inventory_justification/tests/test_stock_inventory_justification.py new file mode 100644 index 000000000..1079abad7 --- /dev/null +++ b/stock_inventory_justification/tests/test_stock_inventory_justification.py @@ -0,0 +1,71 @@ +# Copyright 2024 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.addons.stock.tests.common2 import TestStockCommon + + +class TestStockInventoryJustification(TestStockCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + # MODELS + cls.stock_inventory_justification_model = cls.env[ + "stock.inventory.justification" + ] + cls.stock_quant_model = cls.env["stock.quant"].with_context(inventory_mode=True) + # INSTANCES + # Inventory justifications + cls.inventory_justification_01 = cls.stock_inventory_justification_model.create( + {"name": "Justification 01"} + ) + cls.inventory_justification_02 = cls.stock_inventory_justification_model.create( + {"name": "Justification 02"} + ) + # Products + cls.product_1.type = "product" + + def test_01(self): + """ + Test case: + - Process a stock inventory on a quant without justification + Expected result: + - The created move has no inventory justification + """ + inventory_quant = self.stock_quant_model.create( + { + "product_id": self.product_1.id, + "inventory_quantity": 50.0, + "location_id": self.warehouse_1.lot_stock_id.id, + } + ) + inventory_quant.action_apply_inventory() + stock_move = self.env["stock.move"].search( + [("is_inventory", "=", True), ("product_id", "=", self.product_1.id)] + ) + self.assertFalse(stock_move.inventory_justification_ids) + + def test_02(self): + """ + Test case: + - Process a stock inventory on a quant with justification + Expected result: + - The created move has the same inventory justification as the quant + """ + inventory_quant = self.stock_quant_model.create( + { + "product_id": self.product_1.id, + "inventory_quantity": 50.0, + "location_id": self.warehouse_1.lot_stock_id.id, + "inventory_justification_ids": [ + (6, 0, [self.inventory_justification_01.id]) + ], + } + ) + inventory_quant.action_apply_inventory() + stock_move = self.env["stock.move"].search( + [("is_inventory", "=", True), ("product_id", "=", self.product_1.id)] + ) + self.assertFalse(inventory_quant.inventory_justification_ids) + self.assertEqual( + stock_move.inventory_justification_ids, self.inventory_justification_01 + ) diff --git a/stock_inventory_justification/views/stock_inventory_justification.xml b/stock_inventory_justification/views/stock_inventory_justification.xml new file mode 100644 index 000000000..d4067f4ce --- /dev/null +++ b/stock_inventory_justification/views/stock_inventory_justification.xml @@ -0,0 +1,64 @@ + + + + + + stock.inventory.justification.form (in stock_inventory_justification) + stock.inventory.justification + +
+
+ + + + + + + + + + + stock.inventory.justification.tree (in stock_inventory_justification) + stock.inventory.justification + + + + + + + + + stock.inventory.justification.search (in stock_inventory_justification) + stock.inventory.justification + + + + + + + + + Inventory justifications + stock.inventory.justification + tree,form + [] + {} + + + + Inventory justifications + + + + + diff --git a/stock_inventory_justification/views/stock_move_line.xml b/stock_inventory_justification/views/stock_move_line.xml new file mode 100644 index 000000000..5a937e5dd --- /dev/null +++ b/stock_inventory_justification/views/stock_move_line.xml @@ -0,0 +1,37 @@ + + + + + stock.move.line + + + + + + + + + + + + stock.move.line + + + + + + + + + + + diff --git a/stock_inventory_justification/views/stock_quant.xml b/stock_inventory_justification/views/stock_quant.xml new file mode 100644 index 000000000..d3a0270f3 --- /dev/null +++ b/stock_inventory_justification/views/stock_quant.xml @@ -0,0 +1,14 @@ + + + + + stock.quant + + + + + + + +