[FIX] stock_quantity_history_location: Migrate js to OWL

This commit solves the error
"Non loaded module
stock_quantity_history_location.InventoryReportListController" because
the dependency stock.InventoryReportListController was missed. The
dependency from stock was migrated to OWL [1], so it is inherited using the
OWL to preserve the behavior.

References:
- [1] https://github.com/odoo/odoo/commit/ec0b1005
This commit is contained in:
rolandojduartem
2023-08-18 04:45:49 +00:00
committed by GuillemCForgeFlow
parent e3a20f5a3f
commit 994abb7987
7 changed files with 41 additions and 41 deletions

View File

@@ -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",
],
},
}

View File

@@ -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 ""

View File

@@ -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"
);
});
},
});

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-inherit="stock.InventoryReport.Buttons" t-inherit-mode="extension" owl="1">
<xpath expr="//button[contains(@t-if, 'stock.quant')]" position="before">
<t t-if="multi_location" t-set="text_multi_location">
Inventory at Date &amp; Location
</t>
<t t-else="" t-set="text_multi_location">Inventory at Date</t>
</xpath>
<xpath expr="//button[contains(@t-if, 'stock.quant')]" position="attributes">
<attribute name="t-out">text_multi_location</attribute>
</xpath>
</t>
</templates>

View File

@@ -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]);
},
});
}
);

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-extend="StockInventoryReport.Buttons">
<t t-jquery="button.o_button_at_date" t-operation="inner">
<t t-if="widget.multi_location">Inventory at Date &amp; Location</t>
<t t-else="">Inventory at Date</t>
</t>
</t>
</templates>

View File

@@ -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