summaryrefslogtreecommitdiff
path: root/addons/sale/static/src/js/sale.js
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/sale/static/src/js/sale.js
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/sale/static/src/js/sale.js')
-rw-r--r--addons/sale/static/src/js/sale.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/addons/sale/static/src/js/sale.js b/addons/sale/static/src/js/sale.js
new file mode 100644
index 00000000..556c9fd2
--- /dev/null
+++ b/addons/sale/static/src/js/sale.js
@@ -0,0 +1,60 @@
+odoo.define('sale.sales_team_dashboard', function (require) {
+"use strict";
+
+var core = require('web.core');
+var KanbanRecord = require('web.KanbanRecord');
+var _t = core._t;
+
+KanbanRecord.include({
+ events: _.defaults({
+ 'click .sales_team_target_definition': '_onSalesTeamTargetClick',
+ }, KanbanRecord.prototype.events),
+
+ //--------------------------------------------------------------------------
+ // Handlers
+ //--------------------------------------------------------------------------
+
+ /**
+ * @param {MouseEvent} ev
+ */
+ _onSalesTeamTargetClick: function (ev) {
+ ev.preventDefault();
+ var self = this;
+
+ this.$target_input = $('<input>');
+ this.$('.o_kanban_primary_bottom:last').html(this.$target_input);
+ this.$('.o_kanban_primary_bottom:last').prepend(_t("Set an invoicing target: "));
+ this.$target_input.focus();
+
+ this.$target_input.on({
+ blur: this._onSalesTeamTargetSet.bind(this),
+ keydown: function (ev) {
+ if (ev.keyCode === $.ui.keyCode.ENTER) {
+ self._onSalesTeamTargetSet();
+ }
+ },
+ });
+ },
+ /**
+ * Mostly a handler for what happens to the input "this.$target_input"
+ *
+ * @private
+ *
+ */
+ _onSalesTeamTargetSet: function () {
+ var self = this;
+ var value = Number(this.$target_input.val());
+ if (isNaN(value)) {
+ this.do_warn(false, _t("Please enter an integer value"));
+ } else {
+ this.trigger_up('kanban_record_update', {
+ invoiced_target: value,
+ onSuccess: function () {
+ self.trigger_up('reload');
+ },
+ });
+ }
+ },
+});
+
+});