diff --git a/setup/stock_inventory_count_to_zero/odoo/addons/stock_inventory_count_to_zero b/setup/stock_inventory_count_to_zero/odoo/addons/stock_inventory_count_to_zero new file mode 120000 index 000000000..e9c2946dc --- /dev/null +++ b/setup/stock_inventory_count_to_zero/odoo/addons/stock_inventory_count_to_zero @@ -0,0 +1 @@ +../../../../stock_inventory_count_to_zero \ No newline at end of file diff --git a/setup/stock_inventory_count_to_zero/setup.py b/setup/stock_inventory_count_to_zero/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_inventory_count_to_zero/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_inventory_count_to_zero/README.rst b/stock_inventory_count_to_zero/README.rst new file mode 100644 index 000000000..7ae0beb65 --- /dev/null +++ b/stock_inventory_count_to_zero/README.rst @@ -0,0 +1,89 @@ +============================= +Stock Inventory Count To Zero +============================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:61e9cce3b93c7b9f4394e7b8e1405f5f915a8df608be6b005d66f3f5abd2909f + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/15.0/stock_inventory_count_to_zero + :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-15-0/stock-logistics-warehouse-15-0-stock_inventory_count_to_zero + :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=15.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of stock module to allow request a inventory and +set inventory quantities to zero. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module you need to: + +#. Go to a *Inventory > Operations > Inventory adjustment*. +#. Select some records and click on button "Request a count". +#. Set the "Set to zero" in count field. +#. Apply inventory when you want. + +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 +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_ + + * Sergio Teruel + +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/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_count_to_zero/__init__.py b/stock_inventory_count_to_zero/__init__.py new file mode 100644 index 000000000..9b2246d7e --- /dev/null +++ b/stock_inventory_count_to_zero/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import models +from . import wizards diff --git a/stock_inventory_count_to_zero/__manifest__.py b/stock_inventory_count_to_zero/__manifest__.py new file mode 100644 index 000000000..188e40edc --- /dev/null +++ b/stock_inventory_count_to_zero/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2023 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Stock Inventory Count To Zero", + "summary": "Request an inventory count filling the quantities to zero as default", + "version": "16.0.1.0.0", + "development_status": "Beta", + "category": "Inventory/Inventory", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "depends": ["stock"], +} diff --git a/stock_inventory_count_to_zero/i18n/es.po b/stock_inventory_count_to_zero/i18n/es.po new file mode 100644 index 000000000..74d3cdda6 --- /dev/null +++ b/stock_inventory_count_to_zero/i18n/es.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_request_count_to_zero +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-26 21:52+0000\n" +"PO-Revision-Date: 2023-07-26 23:55+0200\n" +"Last-Translator: Sergio Teruel \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 3.0.1\n" + +#. module: stock_inventory_count_to_zero +#: model:ir.model.fields,field_description:stock_inventory_count_to_zero.field_stock_request_count__set_count +msgid "Count" +msgstr "Cuenta" + +#. module: stock_inventory_count_to_zero +#: code:addons/stock_inventory_count_to_zero/models/stock_quant.py:0 +#, python-format +msgid "Quantities Already Set" +msgstr "Cantidades ya establecidas" + +#. module: stock_inventory_count_to_zero +#: model:ir.model,name:stock_inventory_count_to_zero.model_stock_quant +msgid "Quants" +msgstr "Quants" + +#. module: stock_inventory_count_to_zero +#: model:ir.model.fields.selection,name:stock_inventory_count_to_zero.selection__stock_request_count__set_count__zero +msgid "Set to zero" +msgstr "Establecer a cero" + +#. module: stock_inventory_count_to_zero +#: model:ir.model,name:stock_inventory_count_to_zero.model_stock_request_count +msgid "Stock Request an Inventory Count" +msgstr "Solicitar un recuento" diff --git a/stock_inventory_count_to_zero/i18n/stock_inventory_count_to_zero.pot b/stock_inventory_count_to_zero/i18n/stock_inventory_count_to_zero.pot new file mode 100644 index 000000000..ebcc60756 --- /dev/null +++ b/stock_inventory_count_to_zero/i18n/stock_inventory_count_to_zero.pot @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_inventory_count_to_zero +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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_count_to_zero +#: model:ir.model.fields,field_description:stock_inventory_count_to_zero.field_stock_request_count__set_count +msgid "Count" +msgstr "" + +#. module: stock_inventory_count_to_zero +#: code:addons/stock_inventory_count_to_zero/models/stock_quant.py:0 +#, python-format +msgid "Quantities Already Set" +msgstr "" + +#. module: stock_inventory_count_to_zero +#: model:ir.model,name:stock_inventory_count_to_zero.model_stock_quant +msgid "Quants" +msgstr "" + +#. module: stock_inventory_count_to_zero +#: model:ir.model.fields.selection,name:stock_inventory_count_to_zero.selection__stock_request_count__set_count__zero +msgid "Set to zero" +msgstr "" + +#. module: stock_inventory_count_to_zero +#: model:ir.model,name:stock_inventory_count_to_zero.model_stock_request_count +msgid "Stock Request an Inventory Count" +msgstr "" diff --git a/stock_inventory_count_to_zero/i18n/stock_request_count_to_zero.pot b/stock_inventory_count_to_zero/i18n/stock_request_count_to_zero.pot new file mode 100644 index 000000000..b2cb246c6 --- /dev/null +++ b/stock_inventory_count_to_zero/i18n/stock_request_count_to_zero.pot @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_request_count_to_zero +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-26 21:52+0000\n" +"PO-Revision-Date: 2023-07-26 21:52+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: stock_request_count_to_zero +#: model:ir.model.fields,field_description:stock_request_count_to_zero.field_stock_request_count__set_count +msgid "Count" +msgstr "" + +#. module: stock_request_count_to_zero +#: code:addons/stock_request_count_to_zero/models/stock_quant.py:0 +#, python-format +msgid "Quantities Already Set" +msgstr "" + +#. module: stock_request_count_to_zero +#: model:ir.model,name:stock_request_count_to_zero.model_stock_quant +msgid "Quants" +msgstr "" + +#. module: stock_request_count_to_zero +#: model:ir.model.fields.selection,name:stock_request_count_to_zero.selection__stock_request_count__set_count__zero +msgid "Set to zero" +msgstr "" + +#. module: stock_request_count_to_zero +#: model:ir.model,name:stock_request_count_to_zero.model_stock_request_count +msgid "Stock Request an Inventory Count" +msgstr "" diff --git a/stock_inventory_count_to_zero/models/__init__.py b/stock_inventory_count_to_zero/models/__init__.py new file mode 100644 index 000000000..25e6fe912 --- /dev/null +++ b/stock_inventory_count_to_zero/models/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import stock_quant diff --git a/stock_inventory_count_to_zero/models/stock_quant.py b/stock_inventory_count_to_zero/models/stock_quant.py new file mode 100644 index 000000000..74ad7ade4 --- /dev/null +++ b/stock_inventory_count_to_zero/models/stock_quant.py @@ -0,0 +1,30 @@ +# Copyright 2018 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import _, models + + +class StockQuant(models.Model): + _inherit = "stock.quant" + + def action_set_inventory_quantity_recount_to_zero(self): + quants_already_set = self.filtered(lambda quant: quant.inventory_quantity_set) + if quants_already_set: + ctx = dict(self.env.context or {}, default_quant_ids=self.ids) + view = self.env.ref("stock.inventory_warning_set_view", False) + return { + "name": _("Quantities Already Set"), + "type": "ir.actions.act_window", + "view_mode": "form", + "views": [(view.id, "form")], + "view_id": view.id, + "res_model": "stock.inventory.warning", + "target": "new", + "context": ctx, + } + self.update( + { + "inventory_quantity": 0.0, + "user_id": self.env.user.id, + "inventory_quantity_set": True, + } + ) diff --git a/stock_inventory_count_to_zero/readme/CONTRIBUTORS.rst b/stock_inventory_count_to_zero/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..a3eac1615 --- /dev/null +++ b/stock_inventory_count_to_zero/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Tecnativa `_ + + * Sergio Teruel diff --git a/stock_inventory_count_to_zero/readme/DESCRIPTION.rst b/stock_inventory_count_to_zero/readme/DESCRIPTION.rst new file mode 100644 index 000000000..d02726afe --- /dev/null +++ b/stock_inventory_count_to_zero/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module extends the functionality of stock module to allow request a inventory and +set inventory quantities to zero. diff --git a/stock_inventory_count_to_zero/readme/USAGE.rst b/stock_inventory_count_to_zero/readme/USAGE.rst new file mode 100644 index 000000000..425054c53 --- /dev/null +++ b/stock_inventory_count_to_zero/readme/USAGE.rst @@ -0,0 +1,6 @@ +To use this module you need to: + +#. Go to a *Inventory > Operations > Inventory adjustment*. +#. Select some records and click on button "Request a count". +#. Set the "Set to zero" in count field. +#. Apply inventory when you want. diff --git a/stock_inventory_count_to_zero/static/description/icon.png b/stock_inventory_count_to_zero/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_inventory_count_to_zero/static/description/icon.png differ diff --git a/stock_inventory_count_to_zero/static/description/index.html b/stock_inventory_count_to_zero/static/description/index.html new file mode 100644 index 000000000..1af1a71cf --- /dev/null +++ b/stock_inventory_count_to_zero/static/description/index.html @@ -0,0 +1,436 @@ + + + + + + +Stock Inventory Count To Zero + + + +
+

Stock Inventory Count To Zero

+ + +

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

+

This module extends the functionality of stock module to allow request a inventory and +set inventory quantities to zero.

+

Table of contents

+ +
+

Usage

+

To use this module you need to:

+
    +
  1. Go to a Inventory > Operations > Inventory adjustment.
  2. +
  3. Select some records and click on button “Request a count”.
  4. +
  5. Set the “Set to zero” in count field.
  6. +
  7. Apply inventory when you want.
  8. +
+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

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/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_count_to_zero/tests/__init__.py b/stock_inventory_count_to_zero/tests/__init__.py new file mode 100644 index 000000000..5cafbc765 --- /dev/null +++ b/stock_inventory_count_to_zero/tests/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import test_stock_inventory_count_to_zero diff --git a/stock_inventory_count_to_zero/tests/test_stock_inventory_count_to_zero.py b/stock_inventory_count_to_zero/tests/test_stock_inventory_count_to_zero.py new file mode 100644 index 000000000..1ab8bc0df --- /dev/null +++ b/stock_inventory_count_to_zero/tests/test_stock_inventory_count_to_zero.py @@ -0,0 +1,43 @@ +# Copyright 2023 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from freezegun import freeze_time + +from odoo.tests import TransactionCase, tagged + + +@freeze_time("2023-07-27", tick=True) +@tagged("-at_install", "post_install") +class TestStockInventoryCountZero(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.warehouse = cls.env.ref("stock.warehouse0") + cls.product_template = cls.env["product.template"].create( + { + "name": "test inventory count to zero", + "type": "product", + } + ) + StockQuant = cls.env["stock.quant"] + cls.quant = StockQuant.create( + { + "product_id": cls.product_template.product_variant_ids[0].id, + "location_id": cls.warehouse.lot_stock_id.id, + "quantity": 10.0, + } + ) + + def test_request_count_to_zero(self): + wiz = self.env["stock.request.count"].create( + {"quant_ids": [(6, 0, self.quant.ids)], "set_count": "zero"} + ) + wiz.action_request_count() + # Get quant pending to recount + quants = self.env["stock.quant"].search( + [ + ("inventory_quantity_set", "=", True), + ("inventory_date", "<=", "2023-07-27"), + ] + ) + self.assertEqual(quants.inventory_quantity, 0.0) + self.assertEqual(quants.inventory_diff_quantity, -10.0) diff --git a/stock_inventory_count_to_zero/wizards/__init__.py b/stock_inventory_count_to_zero/wizards/__init__.py new file mode 100644 index 000000000..afee1a911 --- /dev/null +++ b/stock_inventory_count_to_zero/wizards/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import stock_request_count diff --git a/stock_inventory_count_to_zero/wizards/stock_request_count.py b/stock_inventory_count_to_zero/wizards/stock_request_count.py new file mode 100644 index 000000000..cc98ce7c2 --- /dev/null +++ b/stock_inventory_count_to_zero/wizards/stock_request_count.py @@ -0,0 +1,22 @@ +# Copyright 2023 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class StockRequestCount(models.TransientModel): + _inherit = "stock.request.count" + set_count = fields.Selection( + selection_add=[("zero", "Set to zero")], ondelete={"zero": "cascade"} + ) + + def action_request_count(self): + if self.set_count == "zero": + self.quant_ids.filtered( + lambda q: not q.inventory_quantity_set + ).action_set_inventory_quantity_recount_to_zero() + self.quant_ids.with_context(inventory_mode=True).write( + self._get_values_to_write() + ) + else: + return super(StockRequestCount, self).action_request_count()