From 4cd7a05684ced02f2ed7925d2411d22838e1f722 Mon Sep 17 00:00:00 2001 From: hveficent Date: Mon, 23 Dec 2019 12:52:02 +0100 Subject: [PATCH] [13.0][IMP] stock_quantity_history_location: Block location selection on Account Valuation --- .isort.cfg | 2 +- .../i18n/stock_quantity_history_location.pot | 9 ++++++++ .../static/src/js/inventory_report.js | 23 +++++++++++++++++++ .../wizards/stock_quantity_history.py | 5 ---- .../wizards/stock_quantity_history.xml | 10 +++++++- 5 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 stock_quantity_history_location/static/src/js/inventory_report.js diff --git a/.isort.cfg b/.isort.cfg index 5751c40..98b216f 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -9,4 +9,4 @@ line_length=88 known_odoo=odoo known_odoo_addons=odoo.addons sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER -known_third_party= +known_third_party=setuptools 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 c3f33ea..958253e 100644 --- a/stock_quantity_history_location/i18n/stock_quantity_history_location.pot +++ b/stock_quantity_history_location/i18n/stock_quantity_history_location.pot @@ -6,6 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-12-24 10:24+0000\n" +"PO-Revision-Date: 2019-12-24 10:24+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -18,6 +20,13 @@ msgstr "" msgid "Include child locations" msgstr "" +#. module: stock_quantity_history_location +#. openerp-web +#: code:addons/stock_quantity_history_location/static/src/js/inventory_report.js: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" 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..f2e054f --- /dev/null +++ b/stock_quantity_history_location/static/src/js/inventory_report.js @@ -0,0 +1,23 @@ +odoo.define('stock.InventoryReportLocationListController', function (require) { +"use strict"; + +var core = require('web.core'); +var InventoryReportListController = require('stock.InventoryReportListController'); + +var qweb = core.qweb; +var _t = core._t; + + +var InventoryReportLocationListController = InventoryReportListController.include({ + + renderButtons: function ($node) { + this._super.apply(this, arguments); + if (this.context.no_at_date) { + return; + } + if (this.modelName === "stock.quant") { + $node.find('.o_list_buttons').find(".btn-primary").html(_t("Inventory at Date & Location")) + } + }, +}); +}); diff --git a/stock_quantity_history_location/wizards/stock_quantity_history.py b/stock_quantity_history_location/wizards/stock_quantity_history.py index 3ea6436..2d831bc 100644 --- a/stock_quantity_history_location/wizards/stock_quantity_history.py +++ b/stock_quantity_history_location/wizards/stock_quantity_history.py @@ -1,8 +1,6 @@ # 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 @@ -17,9 +15,6 @@ class StockQuantityHistory(models.TransientModel): 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 diff --git a/stock_quantity_history_location/wizards/stock_quantity_history.xml b/stock_quantity_history_location/wizards/stock_quantity_history.xml index 12aa036..88b8e58 100644 --- a/stock_quantity_history_location/wizards/stock_quantity_history.xml +++ b/stock_quantity_history_location/wizards/stock_quantity_history.xml @@ -1,12 +1,20 @@ + + + Inventory Report stock.quantity.history - +