diff --git a/setup/stock_quantity_history_location/odoo/addons/stock_quantity_history_location b/setup/stock_quantity_history_location/odoo/addons/stock_quantity_history_location new file mode 120000 index 0000000..2f1a370 --- /dev/null +++ b/setup/stock_quantity_history_location/odoo/addons/stock_quantity_history_location @@ -0,0 +1 @@ +../../../../stock_quantity_history_location \ No newline at end of file diff --git a/setup/stock_quantity_history_location/setup.py b/setup/stock_quantity_history_location/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/stock_quantity_history_location/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_quantity_history_location/README.rst b/stock_quantity_history_location/README.rst new file mode 100644 index 0000000..7c506e0 --- /dev/null +++ b/stock_quantity_history_location/README.rst @@ -0,0 +1,87 @@ +=============================== +Stock Quantity History Location +=============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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--reporting-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-reporting/tree/15.0/stock_quantity_history_location + :alt: OCA/stock-logistics-reporting +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-reporting-15-0/stock-logistics-reporting-15-0-stock_quantity_history_location + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/151/15.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to run an Inventory report or Inventory Valuation +report by location, for a past date or for current date. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +* Go to: *Inventory / Reporting / Inventory or Inventory Valuation* +* Filter by location +* **Optionally: Mark if you want to include child location** +* Choose a moment in time: + * Current Inventory + * At a Specific Date + +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 +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Jordi Ballester Alomar +* `Tecnativa `_: + + * Ernesto Tejeda + +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-reporting `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_quantity_history_location/__init__.py b/stock_quantity_history_location/__init__.py new file mode 100644 index 0000000..5cb1c49 --- /dev/null +++ b/stock_quantity_history_location/__init__.py @@ -0,0 +1 @@ +from . import wizards diff --git a/stock_quantity_history_location/__manifest__.py b/stock_quantity_history_location/__manifest__.py new file mode 100644 index 0000000..ad34d79 --- /dev/null +++ b/stock_quantity_history_location/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2019 ForgeFlow S.L. +# Copyright 2019 Aleph Objects, Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Quantity History Location", + "summary": "Provides stock quantity by location on past date", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "maintainers": [ + "luisg123v", + ], + "website": "https://github.com/OCA/stock-logistics-reporting", + "depends": ["stock"], + "data": ["wizards/stock_quantity_history.xml"], + "assets": { + "web.assets_backend": [ + "stock_quantity_history_location/static/src/js/inventory_report.js", + ], + "web.assets_qweb": [ + "stock_quantity_history_location/static/src/xml/inventory_report.xml", + ], + }, +} diff --git a/stock_quantity_history_location/i18n/it.po b/stock_quantity_history_location/i18n/it.po new file mode 100644 index 0000000..e155095 --- /dev/null +++ b/stock_quantity_history_location/i18n/it.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_quantity_history_location +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-04-08 09:46+0000\n" +"Last-Translator: Alessandro Fiorino \n" +"Language-Team: none\n" +"Language: it\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" +"X-Generator: Weblate 4.3.2\n" + +#. module: stock_quantity_history_location +#: model:ir.model.fields,field_description:stock_quantity_history_location.field_stock_quantity_history__include_child_locations +msgid "Include Child Locations" +msgstr "" + +#. module: stock_quantity_history_location +#. openerp-web +#: code:addons/stock_quantity_history_location/static/src/xml/inventory_report.xml:0 +#, python-format +msgid "Inventory at Date" +msgstr "" + +#. module: stock_quantity_history_location +#. openerp-web +#: code:addons/stock_quantity_history_location/static/src/xml/inventory_report.xml:0 +#, python-format +msgid "Inventory at Date & Location" +msgstr "Inventario alla Data e Locazione" + +#. module: stock_quantity_history_location +#: model:ir.model.fields,field_description:stock_quantity_history_location.field_stock_quantity_history__location_id +msgid "Location" +msgstr "Locazione" + +#. module: stock_quantity_history_location +#: model:ir.model,name:stock_quantity_history_location.model_stock_quantity_history +msgid "Stock Quantity History" +msgstr "Storico quantità giacenza" + +#~ msgid "Include child locations" +#~ msgstr "Includi locazioni figlie" diff --git a/stock_quantity_history_location/i18n/ja.po b/stock_quantity_history_location/i18n/ja.po new file mode 100644 index 0000000..3120cb3 --- /dev/null +++ b/stock_quantity_history_location/i18n/ja.po @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_quantity_history_location +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-01-21 10:40+0000\n" +"Last-Translator: kakurai8 \n" +"Language-Team: none\n" +"Language: ja\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: stock_quantity_history_location +#: model:ir.model.fields,field_description:stock_quantity_history_location.field_stock_quantity_history__include_child_locations +msgid "Include Child Locations" +msgstr "" + +#. module: stock_quantity_history_location +#. openerp-web +#: code:addons/stock_quantity_history_location/static/src/xml/inventory_report.xml:0 +#, python-format +msgid "Inventory at Date" +msgstr "" + +#. module: stock_quantity_history_location +#. openerp-web +#: code:addons/stock_quantity_history_location/static/src/xml/inventory_report.xml:0 +#, python-format +msgid "Inventory at Date & Location" +msgstr "" + +#. module: stock_quantity_history_location +#: model:ir.model.fields,field_description:stock_quantity_history_location.field_stock_quantity_history__location_id +msgid "Location" +msgstr "ロケーション" + +#. module: stock_quantity_history_location +#: model:ir.model,name:stock_quantity_history_location.model_stock_quantity_history +msgid "Stock Quantity History" +msgstr "在庫数量履歴" + +#~ msgid "Display Name" +#~ msgstr "表示名" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Include child locations" +#~ msgstr "子ロケーションを含める" + +#~ msgid "Last Modified on" +#~ msgstr "最終更新日" diff --git a/stock_quantity_history_location/i18n/ro.po b/stock_quantity_history_location/i18n/ro.po new file mode 100644 index 0000000..5858b94 --- /dev/null +++ b/stock_quantity_history_location/i18n/ro.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_quantity_history_location +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-09-29 11:00+0000\n" +"Last-Translator: erik-bzcl \n" +"Language-Team: none\n" +"Language: ro\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < " +"20)) ? 1 : 2;\n" +"X-Generator: Weblate 3.10\n" + +#. module: stock_quantity_history_location +#: model:ir.model.fields,field_description:stock_quantity_history_location.field_stock_quantity_history__include_child_locations +msgid "Include Child Locations" +msgstr "" + +#. module: stock_quantity_history_location +#. openerp-web +#: code:addons/stock_quantity_history_location/static/src/xml/inventory_report.xml:0 +#, python-format +msgid "Inventory at Date" +msgstr "" + +#. module: stock_quantity_history_location +#. openerp-web +#: code:addons/stock_quantity_history_location/static/src/xml/inventory_report.xml:0 +#, python-format +msgid "Inventory at Date & Location" +msgstr "Stoc în data & locaţia" + +#. module: stock_quantity_history_location +#: model:ir.model.fields,field_description:stock_quantity_history_location.field_stock_quantity_history__location_id +msgid "Location" +msgstr "Locaţia" + +#. module: stock_quantity_history_location +#: model:ir.model,name:stock_quantity_history_location.model_stock_quantity_history +msgid "Stock Quantity History" +msgstr "Stoc cantitativ istoric" + +#~ msgid "Include child locations" +#~ msgstr "Inclusiv sublocaţii" diff --git a/stock_quantity_history_location/i18n/stock_quantity_history_location.pot b/stock_quantity_history_location/i18n/stock_quantity_history_location.pot new file mode 100644 index 0000000..f3f718a --- /dev/null +++ b/stock_quantity_history_location/i18n/stock_quantity_history_location.pot @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_quantity_history_location +# +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_quantity_history_location +#: model:ir.model.fields,field_description:stock_quantity_history_location.field_stock_quantity_history__include_child_locations +msgid "Include Child Locations" +msgstr "" + +#. module: stock_quantity_history_location +#. openerp-web +#: code:addons/stock_quantity_history_location/static/src/xml/inventory_report.xml:0 +#, python-format +msgid "Inventory at Date" +msgstr "" + +#. module: stock_quantity_history_location +#. openerp-web +#: code:addons/stock_quantity_history_location/static/src/xml/inventory_report.xml:0 +#, python-format +msgid "Inventory at Date & Location" +msgstr "" + +#. module: stock_quantity_history_location +#: model:ir.model.fields,field_description:stock_quantity_history_location.field_stock_quantity_history__location_id +msgid "Location" +msgstr "" + +#. module: stock_quantity_history_location +#: model:ir.model,name:stock_quantity_history_location.model_stock_quantity_history +msgid "Stock Quantity History" +msgstr "" diff --git a/stock_quantity_history_location/readme/CONTRIBUTORS.rst b/stock_quantity_history_location/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..c7a3048 --- /dev/null +++ b/stock_quantity_history_location/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Jordi Ballester Alomar +* `Tecnativa `_: + + * Ernesto Tejeda diff --git a/stock_quantity_history_location/readme/DESCRIPTION.rst b/stock_quantity_history_location/readme/DESCRIPTION.rst new file mode 100644 index 0000000..9b1d7c4 --- /dev/null +++ b/stock_quantity_history_location/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module allows to run an Inventory report or Inventory Valuation +report by location, for a past date or for current date. diff --git a/stock_quantity_history_location/readme/USAGE.rst b/stock_quantity_history_location/readme/USAGE.rst new file mode 100644 index 0000000..9037ce5 --- /dev/null +++ b/stock_quantity_history_location/readme/USAGE.rst @@ -0,0 +1,6 @@ +* Go to: *Inventory / Reporting / Inventory or Inventory Valuation* +* Filter by location +* **Optionally: Mark if you want to include child location** +* Choose a moment in time: + * Current Inventory + * At a Specific Date diff --git a/stock_quantity_history_location/static/description/icon.png b/stock_quantity_history_location/static/description/icon.png new file mode 100644 index 0000000..3a0328b Binary files /dev/null and b/stock_quantity_history_location/static/description/icon.png differ diff --git a/stock_quantity_history_location/static/description/index.html b/stock_quantity_history_location/static/description/index.html new file mode 100644 index 0000000..c428b87 --- /dev/null +++ b/stock_quantity_history_location/static/description/index.html @@ -0,0 +1,442 @@ + + + + + + +Stock Quantity History Location + + + +
+

Stock Quantity History Location

+ + +

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

+

This module allows to run an Inventory report or Inventory Valuation +report by location, for a past date or for current date.

+

Table of contents

+ +
+

Usage

+
    +
  • Go to: Inventory / Reporting / Inventory or Inventory Valuation
  • +
  • Filter by location
  • +
  • Optionally: Mark if you want to include child location
  • +
  • +
    Choose a moment in time:
    +
      +
    • Current Inventory
    • +
    • At a Specific Date
    • +
    +
    +
    +
  • +
+
+
+

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

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

+

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

+

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

+
+
+
+ + diff --git a/stock_quantity_history_location/static/src/js/inventory_report.js b/stock_quantity_history_location/static/src/js/inventory_report.js new file mode 100644 index 0000000..240af2a --- /dev/null +++ b/stock_quantity_history_location/static/src/js/inventory_report.js @@ -0,0 +1,25 @@ +odoo.define( + "stock_quantity_history_location.InventoryReportListController", + function (require) { + "use strict"; + + const session = require("web.session"); + const InventoryReportListController = require("stock.InventoryReportListController"); + + InventoryReportListController.include({ + init: function () { + this._super.apply(this, arguments); + this.multi_location = false; + }, + willStart: function () { + const sup = this._super(...arguments); + const user_group = session + .user_has_group("stock.group_stock_multi_locations") + .then((hasGroup) => { + this.multi_location = hasGroup; + }); + return Promise.all([sup, user_group]); + }, + }); + } +); diff --git a/stock_quantity_history_location/static/src/xml/inventory_report.xml b/stock_quantity_history_location/static/src/xml/inventory_report.xml new file mode 100644 index 0000000..f2067b2 --- /dev/null +++ b/stock_quantity_history_location/static/src/xml/inventory_report.xml @@ -0,0 +1,9 @@ + + + + + Inventory at Date & Location + Inventory at Date + + + diff --git a/stock_quantity_history_location/tests/__init__.py b/stock_quantity_history_location/tests/__init__.py new file mode 100644 index 0000000..6be307f --- /dev/null +++ b/stock_quantity_history_location/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_quantity_history_location diff --git a/stock_quantity_history_location/tests/common.py b/stock_quantity_history_location/tests/common.py new file mode 100644 index 0000000..4ec8d3d --- /dev/null +++ b/stock_quantity_history_location/tests/common.py @@ -0,0 +1,28 @@ +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestCommon(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + def _create_stock_move(self, location_dest_id, qty): + move = self.env["stock.move"].create( + { + "name": "Stock move in", + "location_id": self.supplier_location.id, + "location_dest_id": location_dest_id.id, + "product_id": self.product.id, + "product_uom": self.product.uom_id.id, + "product_uom_qty": qty, + } + ) + move._action_confirm() + move._action_assign() + move_line = move.move_line_ids[0] + move_line.qty_done = qty + move._action_done() + return move diff --git a/stock_quantity_history_location/tests/test_stock_quantity_history_location.py b/stock_quantity_history_location/tests/test_stock_quantity_history_location.py new file mode 100644 index 0000000..dae4733 --- /dev/null +++ b/stock_quantity_history_location/tests/test_stock_quantity_history_location.py @@ -0,0 +1,65 @@ +# Copyright 2019 ForgeFlow S.L. +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields + +from .common import TestCommon + + +class TestStockQuantityHistoryLocation(TestCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.supplier_location = cls.env.ref("stock.stock_location_suppliers") + cls.main_company = cls.env.ref("base.main_company") + cls.product = cls.env.ref("product.product_product_3") + cls.test_stock_loc = cls.env["stock.location"].create( + { + "usage": "internal", + "name": "Test Stock Location", + "company_id": cls.main_company.id, + } + ) + cls.child_test_stock_loc = cls.env["stock.location"].create( + { + "usage": "internal", + "name": "Child Test Stock Location", + "location_id": cls.test_stock_loc.id, + "company_id": cls.main_company.id, + } + ) + cls._create_stock_move(cls, location_dest_id=cls.child_test_stock_loc, qty=100) + + def test_01_wizard_past_date(self): + wizard = self.env["stock.quantity.history"].create( + { + "location_id": self.test_stock_loc.id, + "include_child_locations": True, + "inventory_datetime": fields.Datetime.now(), + } + ) + action = wizard.with_context(company_owned=True).open_at_date() + self.assertEqual( + self.product.with_context(**action["context"]).qty_available, 100.0 + ) + self.assertEqual( + self.product.with_context( + location=self.child_test_stock_loc.id, to_date="2019-08-10" + ).qty_available, + 0.0, + ) + + def test_02_wizard_current(self): + wizard = self.env["stock.quantity.history"].create( + {"location_id": self.test_stock_loc.id, "include_child_locations": False} + ) + action = wizard.with_context().open_at_date() + self.assertEqual(action["context"]["compute_child"], False) + self.assertEqual(action["context"]["location"], self.test_stock_loc.id) + wizard = self.env["stock.quantity.history"].create( + {"location_id": self.test_stock_loc.id, "include_child_locations": True} + ) + action = wizard.with_context().open_at_date() + self.assertEqual(action["context"]["compute_child"], True) + self.assertEqual(action["context"]["location"], self.test_stock_loc.id) diff --git a/stock_quantity_history_location/wizards/__init__.py b/stock_quantity_history_location/wizards/__init__.py new file mode 100644 index 0000000..51f2abb --- /dev/null +++ b/stock_quantity_history_location/wizards/__init__.py @@ -0,0 +1 @@ +from . import stock_quantity_history diff --git a/stock_quantity_history_location/wizards/stock_quantity_history.py b/stock_quantity_history_location/wizards/stock_quantity_history.py new file mode 100644 index 0000000..eb6cae8 --- /dev/null +++ b/stock_quantity_history_location/wizards/stock_quantity_history.py @@ -0,0 +1,29 @@ +# Copyright 2019 ForgeFlow S.L. +# Copyright 2019 Aleph Objects, Inc. +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class StockQuantityHistory(models.TransientModel): + _inherit = "stock.quantity.history" + + location_id = fields.Many2one( + "stock.location", domain=[("usage", "in", ["internal", "transit"])] + ) + include_child_locations = fields.Boolean(default=True) + + def open_at_date(self): + action = super().open_at_date() + ctx = action["context"] + if self.location_id: + ctx["location"] = self.location_id.id + ctx["compute_child"] = self.include_child_locations + if ctx.get("company_owned", False): + ctx.pop("company_owned") + action[ + "display_name" + ] = f"{self.location_id.complete_name} - {action['display_name']}" + action["context"] = ctx + return action diff --git a/stock_quantity_history_location/wizards/stock_quantity_history.xml b/stock_quantity_history_location/wizards/stock_quantity_history.xml new file mode 100644 index 0000000..b34f001 --- /dev/null +++ b/stock_quantity_history_location/wizards/stock_quantity_history.xml @@ -0,0 +1,19 @@ + + + + + Inventory Report + stock.quantity.history + + + + + + + + +