summaryrefslogtreecommitdiff
path: root/addons/sale_timesheet/static/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/sale_timesheet/static/src/js')
-rw-r--r--addons/sale_timesheet/static/src/js/project_overview.js56
-rw-r--r--addons/sale_timesheet/static/src/js/sale_project_kanban_controller.js68
2 files changed, 124 insertions, 0 deletions
diff --git a/addons/sale_timesheet/static/src/js/project_overview.js b/addons/sale_timesheet/static/src/js/project_overview.js
new file mode 100644
index 00000000..6f40b30d
--- /dev/null
+++ b/addons/sale_timesheet/static/src/js/project_overview.js
@@ -0,0 +1,56 @@
+odoo.define('sale_timesheet.project_overview', function (require) {
+ "use strict";
+
+ var qweb = require('web.qweb');
+ var viewRegistry = require('web.view_registry');
+
+ const Controller = qweb.Controller.extend({
+ events: _.extend({}, qweb.Controller.prototype.events, {
+ 'click .project_overview_foldable': '_onFoldToggle',
+ }),
+
+ _onFoldToggle(ev) {
+ const {model, resId} = ev.target.dataset;
+ const shouldOpen = ev.target.classList.contains('fa-caret-right');
+ if (model === 'sale.order' && shouldOpen) {
+ this._openSaleOrder(resId);
+ }
+ else if (model === 'sale.order.line' && shouldOpen) {
+ this._openSaleOrderLine(resId);
+ }
+ else {
+ const targetClass = `.${model.replace(/\./g, '_')}_${resId || 'None'}`;
+ this.$(targetClass).hide();
+ }
+ $(ev.target).toggleClass('fa-caret-right');
+ $(ev.target).toggleClass('fa-caret-down');
+ },
+
+ _openSaleOrder(id) {
+ id = id || 'None';
+ const targetClass = `.sale_order_${id}`;
+ this.$(`.o_timesheet_forecast_sale_order_line${targetClass}`).show();
+ this.$(`.o_timesheet_forecast_hr_employee${targetClass}`).hide();
+ this.$(`.o_timesheet_forecast_sale_order_line${targetClass} .fa`).removeClass('fa-caret-down');
+ this.$(`.o_timesheet_forecast_sale_order_line${targetClass} .fa`).addClass('fa-caret-right');
+
+ },
+
+ _openSaleOrderLine(id) {
+ id = id || 'None';
+ const targetClass = `.sale_order_line_${id}`;
+ this.$(`.o_timesheet_forecast_hr_employee${targetClass}`).show();
+ },
+ });
+
+ var ProjectOverview = qweb.View.extend({
+ withSearchBar: true,
+ searchMenuTypes: ['filter', 'favorite'],
+
+ config: _.extend({}, qweb.View.prototype.config, {
+ Controller: Controller,
+ }),
+ });
+
+ viewRegistry.add('project_overview', ProjectOverview);
+});
diff --git a/addons/sale_timesheet/static/src/js/sale_project_kanban_controller.js b/addons/sale_timesheet/static/src/js/sale_project_kanban_controller.js
new file mode 100644
index 00000000..2c252c6f
--- /dev/null
+++ b/addons/sale_timesheet/static/src/js/sale_project_kanban_controller.js
@@ -0,0 +1,68 @@
+odoo.define('sale_timesheet.sale_project_kanban_controller', function (require) {
+"use strict";
+
+var core = require('web.core');
+var ProjectKanbanController = require('project.project_kanban');
+var session = require('web.session');
+
+var QWeb = core.qweb;
+
+// YTI TODO : Master remove file
+
+var SaleProjectKanbanController = ProjectKanbanController.include({
+
+ //--------------------------------------------------------------------------
+ // Private
+ //--------------------------------------------------------------------------
+
+ _showCreateSOButton: async function () {
+ var self = this;
+ this.activeProjectIds = this.initialState.context.active_ids;
+
+ if (!this.activeProjectIds || this.activeProjectIds.length !== 1) {
+ this.showCreateSaleOrder = false;
+ return;
+ }
+ var canCreateSO = await session.user_has_group('sales_team.group_sale_salesman');
+ if (canCreateSO) {
+ await this._rpc({
+ model: 'project.project',
+ method: 'search_count',
+ args: [[
+ ["id", "in", this.activeProjectIds],
+ ["bill_type", "=", "customer_project"],
+ ["sale_order_id", "=", false],
+ ["allow_billable", "=", true],
+ ["allow_timesheets", "=", true],
+ ]],
+ }).then(function (projectCount) {
+ self.showCreateSaleOrder = projectCount !== 0;
+ });
+ } else {
+ this.showCreateSaleOrder = false;
+ }
+ },
+
+ //--------------------------------------------------------------------------
+ // Handlers
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ * @param {MouseEvent} ev
+ */
+ _onCreateSaleOrder: function (ev) {
+ ev.preventDefault();
+ this.do_action('sale_timesheet.project_project_action_multi_create_sale_order', {
+ additional_context: {
+ 'active_id': this.activeProjectIds && this.activeProjectIds[0],
+ 'active_model': "project.project",
+ },
+ on_close: async () => await this.reload()
+ });
+ },
+});
+
+return SaleProjectKanbanController;
+
+});