From f28ee0ebadd75aea5bef50230ad5b247bfdcd73c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ana=C3=AFs?= Date: Tue, 14 May 2024 11:33:37 +0200 Subject: [PATCH] [MIG] stock_quantity_history_location: Migration to 17.0 - refactored .js code by inheriting `get_views` method to display a different button text for those users having the Multi Locations group enabled. Added a test case to cover the change --- stock_quantity_history_location/README.rst | 9 +++++- stock_quantity_history_location/__init__.py | 1 + .../__manifest__.py | 10 +----- .../models/__init__.py | 1 + .../models/stock_quant.py | 25 +++++++++++++++ .../readme/USAGE.md | 10 ++++-- .../static/description/index.html | 7 +++-- .../inventory_report/inventory_report.esm.js | 17 ---------- .../inventory_report/inventory_report.xml | 14 --------- .../tests/common.py | 5 +-- .../test_stock_quantity_history_location.py | 31 ++++++++++++++++++- .../wizards/stock_quantity_history.xml | 6 ++-- 12 files changed, 86 insertions(+), 50 deletions(-) create mode 100644 stock_quantity_history_location/models/__init__.py create mode 100644 stock_quantity_history_location/models/stock_quant.py delete mode 100644 stock_quantity_history_location/static/src/components/inventory_report/inventory_report.esm.js delete mode 100644 stock_quantity_history_location/static/src/components/inventory_report/inventory_report.xml diff --git a/stock_quantity_history_location/README.rst b/stock_quantity_history_location/README.rst index ecdbda5b2..682d64896 100644 --- a/stock_quantity_history_location/README.rst +++ b/stock_quantity_history_location/README.rst @@ -39,7 +39,14 @@ report by location, for a past date or for current date. Usage ===== -- Go to: *Inventory / Reporting / Inventory or Inventory Valuation* +First, you need to activate Storage Locations. To do so, go to Inventory +/ Configuration / Settings / Warehouse and activate it. + +To use this module, go to: + +- *Inventory / Reporting / Locations* + +- Select Inventory at Date & Location - Filter by location diff --git a/stock_quantity_history_location/__init__.py b/stock_quantity_history_location/__init__.py index 5cb1c4914..976591c99 100644 --- a/stock_quantity_history_location/__init__.py +++ b/stock_quantity_history_location/__init__.py @@ -1 +1,2 @@ from . import wizards +from . import models diff --git a/stock_quantity_history_location/__manifest__.py b/stock_quantity_history_location/__manifest__.py index 5c7e9dc95..ce454c91c 100644 --- a/stock_quantity_history_location/__manifest__.py +++ b/stock_quantity_history_location/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Stock Quantity History Location", "summary": "Provides stock quantity by location on past date", - "version": "16.0.1.0.1", + "version": "17.0.1.0.0", "license": "AGPL-3", "author": "ForgeFlow, Odoo Community Association (OCA)", "maintainers": [ @@ -15,12 +15,4 @@ "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/components" - "/inventory_report/inventory_report.esm.js", - "stock_quantity_history_location/static/src/components/" - "inventory_report/inventory_report.xml", - ], - }, } diff --git a/stock_quantity_history_location/models/__init__.py b/stock_quantity_history_location/models/__init__.py new file mode 100644 index 000000000..70f8e6c8d --- /dev/null +++ b/stock_quantity_history_location/models/__init__.py @@ -0,0 +1 @@ +from . import stock_quant diff --git a/stock_quantity_history_location/models/stock_quant.py b/stock_quantity_history_location/models/stock_quant.py new file mode 100644 index 000000000..e8e42fd02 --- /dev/null +++ b/stock_quantity_history_location/models/stock_quant.py @@ -0,0 +1,25 @@ +# Copyright 2024 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from lxml import etree + +from odoo import api, models + + +class StockQuant(models.Model): + _inherit = "stock.quant" + + @api.model + def get_views(self, views, options=None): + res = super().get_views(views, options=options) + user_has_group = self.user_has_groups("stock.group_stock_multi_locations") + list_view = res.get("views", {}).get("list", {}) + if user_has_group and list_view: + arch = list_view.get("arch", "") + arch_tree = etree.XML(arch) + buttons = arch_tree.xpath('//button[@name="action_inventory_at_date"]') + for button in buttons: + button.set("string", "Inventory at Date & Location") + new_arch = etree.tostring(arch_tree, encoding="unicode") + list_view["arch"] = new_arch + return res diff --git a/stock_quantity_history_location/readme/USAGE.md b/stock_quantity_history_location/readme/USAGE.md index 0f4b8a4fe..f0450377b 100644 --- a/stock_quantity_history_location/readme/USAGE.md +++ b/stock_quantity_history_location/readme/USAGE.md @@ -1,9 +1,15 @@ -- Go to: *Inventory / Reporting / Inventory or Inventory Valuation* +First, you need to activate Storage Locations. To do so, go to +Inventory / Configuration / Settings / Warehouse and activate it. + +To use this module, go to: +- *Inventory / Reporting / Locations* + +- Select Inventory at Date & Location - Filter by location - **Optionally: Mark if you want to include child location** -- Choose a moment in time: +- Choose a moment in time: - Current Inventory - At a Specific Date diff --git a/stock_quantity_history_location/static/description/index.html b/stock_quantity_history_location/static/description/index.html index 5b5c2a515..c0616c850 100644 --- a/stock_quantity_history_location/static/description/index.html +++ b/stock_quantity_history_location/static/description/index.html @@ -1,4 +1,3 @@ - @@ -387,8 +386,12 @@

Stock Quantity History Location

Usage

+

First, you need to activate Storage Locations. To do so, go to Inventory +/ Configuration / Settings / Warehouse and activate it.

+

To use this module, go to: