diff --git a/stock_quantity_history_location/__manifest__.py b/stock_quantity_history_location/__manifest__.py index ad34d79..5c7e9dc 100644 --- a/stock_quantity_history_location/__manifest__.py +++ b/stock_quantity_history_location/__manifest__.py @@ -5,21 +5,22 @@ { "name": "Stock Quantity History Location", "summary": "Provides stock quantity by location on past date", - "version": "16.0.1.0.0", + "version": "16.0.1.0.1", "license": "AGPL-3", "author": "ForgeFlow, Odoo Community Association (OCA)", "maintainers": [ "luisg123v", + "rolandojduartem", ], "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", + "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/i18n/stock_quantity_history_location.pot b/stock_quantity_history_location/i18n/stock_quantity_history_location.pot index 4dd450c..9ae47f6 100644 --- a/stock_quantity_history_location/i18n/stock_quantity_history_location.pot +++ b/stock_quantity_history_location/i18n/stock_quantity_history_location.pot @@ -20,14 +20,14 @@ msgstr "" #. module: stock_quantity_history_location #. odoo-javascript -#: code:addons/stock_quantity_history_location/static/src/xml/inventory_report.xml:0 +#: code:addons/stock_quantity_history_location/static/src/components/inventory_report/inventory_report.xml:0 #, python-format msgid "Inventory at Date" msgstr "" #. module: stock_quantity_history_location #. odoo-javascript -#: code:addons/stock_quantity_history_location/static/src/xml/inventory_report.xml:0 +#: code:addons/stock_quantity_history_location/static/src/components/inventory_report/inventory_report.xml:0 #, python-format msgid "Inventory at Date & Location" msgstr "" diff --git a/stock_quantity_history_location/static/src/components/inventory_report/inventory_report.esm.js b/stock_quantity_history_location/static/src/components/inventory_report/inventory_report.esm.js new file mode 100644 index 0000000..fd66bfc --- /dev/null +++ b/stock_quantity_history_location/static/src/components/inventory_report/inventory_report.esm.js @@ -0,0 +1,17 @@ +/** @odoo-module **/ + +import {InventoryReportListController} from "@stock/views/list/inventory_report_list_controller"; +import {patch} from "@web/core/utils/patch"; +const {onWillStart} = owl; + +patch(InventoryReportListController.prototype, "inventory_report_list_controller", { + setup() { + this._super(...arguments); + this.multi_location = false; + onWillStart(async () => { + this.multi_location = await this.userService.hasGroup( + "stock.group_stock_multi_locations" + ); + }); + }, +}); diff --git a/stock_quantity_history_location/static/src/components/inventory_report/inventory_report.xml b/stock_quantity_history_location/static/src/components/inventory_report/inventory_report.xml new file mode 100644 index 0000000..d425d04 --- /dev/null +++ b/stock_quantity_history_location/static/src/components/inventory_report/inventory_report.xml @@ -0,0 +1,14 @@ + + + + + + Inventory at Date & Location + + Inventory at Date + + + text_multi_location + + + diff --git a/stock_quantity_history_location/static/src/js/inventory_report.js b/stock_quantity_history_location/static/src/js/inventory_report.js deleted file mode 100644 index 240af2a..0000000 --- a/stock_quantity_history_location/static/src/js/inventory_report.js +++ /dev/null @@ -1,25 +0,0 @@ -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 deleted file mode 100644 index f2067b2..0000000 --- a/stock_quantity_history_location/static/src/xml/inventory_report.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - Inventory at Date & Location - Inventory at Date - - - diff --git a/stock_quantity_history_location/wizards/stock_quantity_history.py b/stock_quantity_history_location/wizards/stock_quantity_history.py index eb6cae8..9e754ba 100644 --- a/stock_quantity_history_location/wizards/stock_quantity_history.py +++ b/stock_quantity_history_location/wizards/stock_quantity_history.py @@ -4,6 +4,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import fields, models +from odoo.tools.safe_eval import safe_eval class StockQuantityHistory(models.TransientModel): @@ -17,6 +18,7 @@ class StockQuantityHistory(models.TransientModel): def open_at_date(self): action = super().open_at_date() ctx = action["context"] + ctx = safe_eval(ctx) if isinstance(ctx, str) else ctx if self.location_id: ctx["location"] = self.location_id.id ctx["compute_child"] = self.include_child_locations