summaryrefslogtreecommitdiff
path: root/addons/stock/static/src/js
diff options
context:
space:
mode:
authorArnold Moyaux <arm@odoo.com>2019-06-18 11:39:26 +0000
committerArnold Moyaux <arm@odoo.com>2019-07-12 11:37:13 +0000
commitec02ca91760a9f1bda2eec0c703ddf20d6a4734b (patch)
tree98c5e7ac3756840fac05c23b28b72848dd3e8dc0 /addons/stock/static/src/js
parentc861edefaa0009ba214d79a53376c85ab9f45991 (diff)
[IMP] stock, stock_account: inventory at date
Usability improvement because when the user click on inventory report it's mainly in order to edit/check its current stock since commit da33eb36b80d1b2a0004c28cf20d6b0263bcb643 This change redirect the user directly on stock.quant tree view and add an inventory at date button in the control panel. This button will open the same wizard than previously and ask for a date. The same principle is used for valuation layer. Co-authored-by: svs-odoo <svs@odoo.com> Task: 1880379
Diffstat (limited to 'addons/stock/static/src/js')
-rw-r--r--addons/stock/static/src/js/inventory_report_list_controller.js51
-rw-r--r--addons/stock/static/src/js/inventory_report_list_view.js19
-rw-r--r--addons/stock/static/src/js/inventory_singleton_list_controller.js4
-rw-r--r--addons/stock/static/src/js/inventory_singleton_list_view.js6
4 files changed, 75 insertions, 5 deletions
diff --git a/addons/stock/static/src/js/inventory_report_list_controller.js b/addons/stock/static/src/js/inventory_report_list_controller.js
new file mode 100644
index 00000000000..09bb54d0eed
--- /dev/null
+++ b/addons/stock/static/src/js/inventory_report_list_controller.js
@@ -0,0 +1,51 @@
+odoo.define('stock.InventoryReportListController', function (require) {
+"use strict";
+
+var core = require('web.core');
+var ListController = require('web.ListController');
+
+var qweb = core.qweb;
+
+
+var InventoryReportListController = ListController.extend({
+
+ // -------------------------------------------------------------------------
+ // Public
+ // -------------------------------------------------------------------------
+
+ /**
+ * @override
+ */
+ renderButtons: function ($node) {
+ this._super.apply(this, arguments);
+ var $buttonToDate = $(qweb.render('InventoryReport.Buttons'));
+ $buttonToDate.on('click', this._onOpenWizard.bind(this));
+
+ $buttonToDate.prependTo($node.find('.o_list_buttons'));
+ },
+
+ // -------------------------------------------------------------------------
+ // Handlers
+ // -------------------------------------------------------------------------
+
+ /**
+ * Handler called when the user clicked on the 'Inventory at Date' button.
+ * Opens wizard to display, at choice, the products inventory or a computed
+ * inventory at a given date.
+ */
+ _onOpenWizard: function () {
+ this.do_action({
+ res_model: 'stock.quantity.history',
+ views: [[false, 'form']],
+ target: 'new',
+ type: 'ir.actions.act_window',
+ context: {
+ active_model: this.modelName,
+ }
+ });
+ },
+});
+
+return InventoryReportListController;
+
+});
diff --git a/addons/stock/static/src/js/inventory_report_list_view.js b/addons/stock/static/src/js/inventory_report_list_view.js
new file mode 100644
index 00000000000..494dd838b73
--- /dev/null
+++ b/addons/stock/static/src/js/inventory_report_list_view.js
@@ -0,0 +1,19 @@
+odoo.define('stock.InventoryReportListView', function (require) {
+"use strict";
+
+var ListView = require('web.ListView');
+var InventoryReportListController = require('stock.InventoryReportListController');
+var viewRegistry = require('web.view_registry');
+
+
+var InventoryReportListView = ListView.extend({
+ config: _.extend({}, ListView.prototype.config, {
+ Controller: InventoryReportListController,
+ }),
+});
+
+viewRegistry.add('inventory_report_list', InventoryReportListView);
+
+return InventoryReportListView;
+
+});
diff --git a/addons/stock/static/src/js/inventory_singleton_list_controller.js b/addons/stock/static/src/js/inventory_singleton_list_controller.js
index b71f2d6ae39..9e5bd4db850 100644
--- a/addons/stock/static/src/js/inventory_singleton_list_controller.js
+++ b/addons/stock/static/src/js/inventory_singleton_list_controller.js
@@ -2,7 +2,7 @@ odoo.define('stock.SingletonListController', function (require) {
"use strict";
var core = require('web.core');
-var ListController = require('web.ListController');
+var InventoryReportListController = require('stock.InventoryReportListController');
var _t = core._t;
@@ -16,7 +16,7 @@ var _t = core._t;
* in the list view, so we refresh it.
*/
-var SingletonListController = ListController.extend({
+var SingletonListController = InventoryReportListController.extend({
/**
* @override
* @return {Promise} rejected when update the list because we don't want
diff --git a/addons/stock/static/src/js/inventory_singleton_list_view.js b/addons/stock/static/src/js/inventory_singleton_list_view.js
index 1f6fc30e483..53faf5b801e 100644
--- a/addons/stock/static/src/js/inventory_singleton_list_view.js
+++ b/addons/stock/static/src/js/inventory_singleton_list_view.js
@@ -1,12 +1,12 @@
odoo.define('stock.SingletonListView', function (require) {
'use strict';
-var ListView = require('web.ListView');
+var InventoryReportListView = require('stock.InventoryReportListView');
var SingletonListController = require('stock.SingletonListController');
var viewRegistry = require('web.view_registry');
-var SingletonListView = ListView.extend({
- config: _.extend({}, ListView.prototype.config, {
+var SingletonListView = InventoryReportListView.extend({
+ config: _.extend({}, InventoryReportListView.prototype.config, {
Controller: SingletonListController,
}),
});