diff --git a/setup/stock_inventory_include_exhausted/odoo/addons/stock_inventory_include_exhausted b/setup/stock_inventory_include_exhausted/odoo/addons/stock_inventory_include_exhausted new file mode 120000 index 000000000..59daf9070 --- /dev/null +++ b/setup/stock_inventory_include_exhausted/odoo/addons/stock_inventory_include_exhausted @@ -0,0 +1 @@ +../../../../stock_inventory_include_exhausted \ No newline at end of file diff --git a/setup/stock_inventory_include_exhausted/setup.py b/setup/stock_inventory_include_exhausted/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_inventory_include_exhausted/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_inventory_include_exhausted/README.rst b/stock_inventory_include_exhausted/README.rst new file mode 100644 index 000000000..bdcb49b2b --- /dev/null +++ b/stock_inventory_include_exhausted/README.rst @@ -0,0 +1,85 @@ +=========================== +Inventory Include Exhausted +=========================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fstock--logistics--warehouse-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_inventory_include_exhausted + :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-13-0/stock-logistics-warehouse-13-0-stock_inventory_include_exhausted + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/153/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module lets you include non-stocked products to your inventory. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you simply need to: + +#. Create a new inventory adjustment. +#. Select the products that you want to do the inventory. +#. Check the box "Include Exhausted". +#. Press the button Start Inventory + +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 +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Carlos Roca + +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_include_exhausted/__init__.py b/stock_inventory_include_exhausted/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/stock_inventory_include_exhausted/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_inventory_include_exhausted/__manifest__.py b/stock_inventory_include_exhausted/__manifest__.py new file mode 100644 index 000000000..1975639b1 --- /dev/null +++ b/stock_inventory_include_exhausted/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2020 Tecnativa - Carlos Roca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Inventory Include Exhausted", + "summary": "It includes the option for adding products exhausted on the " + "inventories.", + "version": "14.0.1.0.0", + "depends": ["stock"], + "author": "Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "category": "Warehouse", + "license": "AGPL-3", + "data": ["views/stock_inventory_view.xml"], + "installable": True, +} diff --git a/stock_inventory_include_exhausted/i18n/es.po b/stock_inventory_include_exhausted/i18n/es.po new file mode 100644 index 000000000..c26c0c4c1 --- /dev/null +++ b/stock_inventory_include_exhausted/i18n/es.po @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_inventory_include_exhausted +# +# Translators: +# Carlos Roca , 2020 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-02-18 11:00+0000\n" +"PO-Revision-Date: 2020-02-18 11:00+0000\n" +"Last-Translator: Carlos Roca , 2020\n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: stock_inventory_include_exhausted +#: model:ir.model.fields,help:stock_inventory_include_exhausted.field_stock_inventory__include_exhausted +msgid "" +"If you select this option, you will receive the out of stock inventory " +"products" +msgstr "" + +#. module: stock_inventory_include_exhausted +#: model:ir.model.fields,field_description:stock_inventory_include_exhausted.field_stock_inventory__include_exhausted +msgid "Include Exhausted" +msgstr "Incluir productos sin existencias" + +#. module: stock_inventory_include_exhausted +#: model:ir.model,name:stock_inventory_include_exhausted.model_stock_inventory +msgid "Inventory" +msgstr "Inventario" diff --git a/stock_inventory_include_exhausted/i18n/stock_inventory_include_exhausted.pot b/stock_inventory_include_exhausted/i18n/stock_inventory_include_exhausted.pot new file mode 100644 index 000000000..b29601558 --- /dev/null +++ b/stock_inventory_include_exhausted/i18n/stock_inventory_include_exhausted.pot @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_inventory_include_exhausted +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.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_include_exhausted +#: model:ir.model.fields,help:stock_inventory_include_exhausted.field_stock_inventory__include_exhausted +msgid "" +"If you select this option, you will receive the out of stock inventory " +"products" +msgstr "" + +#. module: stock_inventory_include_exhausted +#: model:ir.model.fields,field_description:stock_inventory_include_exhausted.field_stock_inventory__include_exhausted +msgid "Include Exhausted" +msgstr "" + +#. module: stock_inventory_include_exhausted +#: model:ir.model,name:stock_inventory_include_exhausted.model_stock_inventory +msgid "Inventory" +msgstr "" diff --git a/stock_inventory_include_exhausted/models/__init__.py b/stock_inventory_include_exhausted/models/__init__.py new file mode 100644 index 000000000..35536816e --- /dev/null +++ b/stock_inventory_include_exhausted/models/__init__.py @@ -0,0 +1 @@ +from . import stock_inventory diff --git a/stock_inventory_include_exhausted/models/stock_inventory.py b/stock_inventory_include_exhausted/models/stock_inventory.py new file mode 100644 index 000000000..3399dbb37 --- /dev/null +++ b/stock_inventory_include_exhausted/models/stock_inventory.py @@ -0,0 +1,41 @@ +# Copyright 2020 Tecnativa - Carlos Roca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class StockInventory(models.Model): + _inherit = "stock.inventory" + + include_exhausted = fields.Boolean( + string="Include Exhausted", + help="If you select this option, you will receive the " + "out of stock inventory products", + ) + + def _get_inventory_lines_values(self): + vals = super()._get_inventory_lines_values() + + if self.include_exhausted: + domain = [("qty_available", "=", 0), ("type", "=", "product")] + if self.product_ids: + domain.append(("id", "in", self.product_ids.ids)) + exhausted_products = self.env["product.product"].search(domain) + vals_dic = { + "inventory_id": self.id, + "company_id": self.company_id.id, + "product_qty": 0, + "theoretical_qty": 0, + } + vals_dic["location_id"] = ( + self.env["stock.warehouse"] + .search([("company_id", "=", vals_dic["company_id"])], limit=1) + .lot_stock_id.id + ) + for product in exhausted_products: + vals_dic["product_id"] = product.id + vals_dic["product_uom_id"] = product.uom_id.id + + vals.append(vals_dic.copy()) + + return vals diff --git a/stock_inventory_include_exhausted/readme/CONTRIBUTORS.rst b/stock_inventory_include_exhausted/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..3b98bebb6 --- /dev/null +++ b/stock_inventory_include_exhausted/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Tecnativa `_: + + * Carlos Roca diff --git a/stock_inventory_include_exhausted/readme/DESCRIPTION.rst b/stock_inventory_include_exhausted/readme/DESCRIPTION.rst new file mode 100644 index 000000000..ef42a3240 --- /dev/null +++ b/stock_inventory_include_exhausted/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module lets you include non-stocked products to your inventory. diff --git a/stock_inventory_include_exhausted/readme/USAGE.rst b/stock_inventory_include_exhausted/readme/USAGE.rst new file mode 100644 index 000000000..0ca1bcec3 --- /dev/null +++ b/stock_inventory_include_exhausted/readme/USAGE.rst @@ -0,0 +1,6 @@ +To use this module, you simply need to: + +#. Create a new inventory adjustment. +#. Select the products that you want to do the inventory. +#. Check the box "Include Exhausted". +#. Press the button Start Inventory diff --git a/stock_inventory_include_exhausted/static/description/icon.png b/stock_inventory_include_exhausted/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_inventory_include_exhausted/static/description/icon.png differ diff --git a/stock_inventory_include_exhausted/static/description/index.html b/stock_inventory_include_exhausted/static/description/index.html new file mode 100644 index 000000000..78cf91f56 --- /dev/null +++ b/stock_inventory_include_exhausted/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +Inventory Include Exhausted + + + +
+

Inventory Include Exhausted

+ + +

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

+

This module lets you include non-stocked products to your inventory.

+

Table of contents

+ +
+

Usage

+

To use this module, you simply need to:

+
    +
  1. Create a new inventory adjustment.
  2. +
  3. Select the products that you want to do the inventory.
  4. +
  5. Check the box “Include Exhausted”.
  6. +
  7. Press the button Start Inventory
  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 smashing 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_include_exhausted/tests/__init__.py b/stock_inventory_include_exhausted/tests/__init__.py new file mode 100644 index 000000000..8ff9dbc55 --- /dev/null +++ b/stock_inventory_include_exhausted/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_inventory_include_exhausted diff --git a/stock_inventory_include_exhausted/tests/test_stock_inventory_include_exhausted.py b/stock_inventory_include_exhausted/tests/test_stock_inventory_include_exhausted.py new file mode 100644 index 000000000..e8116b05c --- /dev/null +++ b/stock_inventory_include_exhausted/tests/test_stock_inventory_include_exhausted.py @@ -0,0 +1,94 @@ +# Copyright 2020 Tecnativa - Carlos Roca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests.common import TransactionCase + + +class StockInventoryIncludeExhaustedTest(TransactionCase): + def setUp(self): + super().setUp() + + self.inventory_model = self.env["stock.inventory"] + self.location_model = self.env["stock.location"] + self.res_users_model = self.env["res.users"] + + self.company = self.env.ref("base.main_company") + self.partner = self.ref("base.res_partner_4") + + # We need this to know how many product with no stock we have on our + # database + self.quantity_out_of_stock = len( + self.env["product.product"].search( + [("qty_available", "=", 0), ("type", "=", "product")] + ) + ) + + self.user = self.res_users_model.create( + { + "name": "Test Account User", + "login": "user_1", + "email": "example@yourcompany.com", + "company_id": self.company.id, + "company_ids": [(4, self.company.id)], + } + ) + + self.product1 = self.env["product.product"].create( + { + "name": "Product for parent location", + "type": "product", + "default_code": "PROD1", + } + ) + self.product2 = self.env["product.product"].create( + { + "name": "Product for child location", + "type": "product", + "default_code": "PROD2", + } + ) + + self.location = self.location_model.create( + {"name": "Inventory tests 1", "usage": "internal"} + ) + + def _create_inventory_all_products(self, name, location, include_exhausted): + inventory = self.inventory_model.create( + { + "name": name, + "location_ids": [(4, location.id)], + "include_exhausted": include_exhausted, + } + ) + return inventory + + def test_not_including_exhausted(self): + """Check if products with no stock are not included into the inventory + if the including exhausted option is disabled.""" + inventory_not_inc = self._create_inventory_all_products( + "not_included", self.location, False + ) + inventory_not_inc.action_start() + inventory_not_inc.action_validate() + lines = inventory_not_inc.line_ids + self.assertEqual(len(lines), 0, "Not all expected products are included") + + def test_including_exhausted(self): + """Check if products with no stock are included into the inventory + if the including exhausted option is enabled.""" + inventory_inc = self._create_inventory_all_products( + # The products with no stock don't have a location, + # that's why search the non-stocked in all locations + "included", + self.location, + True, + ) + + inventory_inc.action_start() + inventory_inc.action_validate() + lines = inventory_inc.line_ids + self.assertEqual( + len(lines), + self.quantity_out_of_stock + 2, + "The products with no stock are not included", + ) diff --git a/stock_inventory_include_exhausted/views/stock_inventory_view.xml b/stock_inventory_include_exhausted/views/stock_inventory_view.xml new file mode 100644 index 000000000..f3624abc2 --- /dev/null +++ b/stock_inventory_include_exhausted/views/stock_inventory_view.xml @@ -0,0 +1,16 @@ + + + + + Inventory form view - stock_inventory_include_exhausted extension + stock.inventory + + + + + + + +