diff --git a/stock_quantity_history_location/README.rst b/stock_quantity_history_location/README.rst new file mode 100644 index 0000000..0256f30 --- /dev/null +++ b/stock_quantity_history_location/README.rst @@ -0,0 +1,79 @@ +=============================== +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/12.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-12-0/stock-logistics-reporting-12-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/12.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 +~~~~~~~ + +* Eficent + +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..012495c --- /dev/null +++ b/stock_quantity_history_location/__manifest__.py @@ -0,0 +1,14 @@ +# 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": "13.0.1.0.1", + "license": "AGPL-3", + "author": "ForgeFlow," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-reporting", + "depends": ["stock"], + "data": ["wizards/stock_quantity_history.xml"], +} 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..ab92ce2 --- /dev/null +++ b/stock_quantity_history_location/i18n/stock_quantity_history_location.pot @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_quantity_history_location +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.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 +#: 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/CONSTRIBUTORS.rst b/stock_quantity_history_location/readme/CONSTRIBUTORS.rst new file mode 100644 index 0000000..6860aff --- /dev/null +++ b/stock_quantity_history_location/readme/CONSTRIBUTORS.rst @@ -0,0 +1 @@ +* Jordi Ballester Alomar 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..87088e3 --- /dev/null +++ b/stock_quantity_history_location/static/description/index.html @@ -0,0 +1,431 @@ + + + + + + +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

+
    +
  • Eficent
  • +
+
+
+

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/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/test_stock_quantity_history_location.py b/stock_quantity_history_location/tests/test_stock_quantity_history_location.py new file mode 100644 index 0000000..83d86b4 --- /dev/null +++ b/stock_quantity_history_location/tests/test_stock_quantity_history_location.py @@ -0,0 +1,78 @@ +# Copyright 2019 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import SavepointCase + + +class TestStockQuantityHistoryLocation(SavepointCase): + @classmethod + def setUpClass(cls): + super(TestStockQuantityHistoryLocation, cls).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, + } + ) + # Create a move for the past + move = cls.env["stock.move"].create( + { + "name": "Stock move in", + "location_id": cls.supplier_location.id, + "location_dest_id": cls.child_test_stock_loc.id, + "product_id": cls.product.id, + "product_uom": cls.product.uom_id.id, + "product_uom_qty": 100.0, + } + ) + move._action_confirm() + move._action_assign() + move_line = move.move_line_ids[0] + move_line.qty_done = 100.0 + move._action_done() + move.date = "2019-08-11" + + def test_wizard_past_date(self): + wizard = self.env["stock.quantity.history"].create( + { + "location_id": self.test_stock_loc.id, + "include_child_locations": True, + "inventory_datetime": "2019-08-12 00:00:00", + } + ) + action = wizard.with_context(company_owned=True).open_at_date() + self.assertEquals( + self.product.with_context(action["context"]).qty_available, 100.0 + ) + self.assertEquals( + self.product.with_context( + location=self.child_test_stock_loc.id, to_date="2019-08-10" + ).qty_available, + 0.0, + ) + + def test_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.assertEquals(action["context"]["compute_child"], False) + self.assertEquals(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.assertEquals(action["context"]["compute_child"], True) + self.assertEquals(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..3ea6436 --- /dev/null +++ b/stock_quantity_history_location/wizards/stock_quantity_history.py @@ -0,0 +1,32 @@ +# Copyright 2019 ForgeFlow S.L. +# Copyright 2019 Aleph Objects, Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import ast + +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("Include child locations", default=True) + + def open_at_date(self): + action = super(StockQuantityHistory, self).open_at_date() + ctx = action["context"] + if isinstance(ctx, str): + ctx = ast.literal_eval(ctx) + # If we are opening the current quants, filter by domain + 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["name"] = "{} ({})".format( + action["name"], self.location_id.complete_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..12aa036 --- /dev/null +++ b/stock_quantity_history_location/wizards/stock_quantity_history.xml @@ -0,0 +1,15 @@ + + + + Inventory Report + stock.quantity.history + + + + + + + + +