From 859a289b0183ec9434ab9f652187264fcf52eb24 Mon Sep 17 00:00:00 2001 From: Bruno Boi Date: Thu, 19 Jan 2023 09:43:30 +0000 Subject: [PATCH] [REF] web,*: OWL GanttView (part 2) This commit acts as a setup that allows the newly converted gantt view extensions in enterprise to work properly. Part-of: odoo/odoo#112756 Co-authored-by: Bruno Boi Co-authored-by: Julien Mougenot Co-authored-by: Mathieu Duckerts-Antoine --- .../src/js/work_entries_controller_mixin.js | 113 ------------------ .../work_entry_calendar.xml | 2 +- addons/mrp/static/src/scss/mrp_gantt.scss | 8 +- addons/mrp/views/mrp_workorder_views.xml | 12 +- addons/web/tooling/_eslintignore | 18 +++ 5 files changed, 29 insertions(+), 124 deletions(-) delete mode 100644 addons/hr_work_entry_contract/static/src/js/work_entries_controller_mixin.js diff --git a/addons/hr_work_entry_contract/static/src/js/work_entries_controller_mixin.js b/addons/hr_work_entry_contract/static/src/js/work_entries_controller_mixin.js deleted file mode 100644 index 59777b02f6e..00000000000 --- a/addons/hr_work_entry_contract/static/src/js/work_entries_controller_mixin.js +++ /dev/null @@ -1,113 +0,0 @@ -odoo.define('hr_work_entry_contract.WorkEntryControllerMixin', function(require) { - 'use strict'; - - var core = require('web.core'); - var time = require('web.time'); - - var _t = core._t; - var QWeb = core.qweb; - - /* - This mixin implements the behaviours necessary to generate and validate work entries and Payslips - It is intended to be used in a Controller and requires four methods to be defined on your Controller - - 1. _fetchRecords - Which should return a list of records containing at least the state and id fields - - 2. _fetchFirstDay - Which should return the first day for which we will generate the work entries, it should be a Moment instance - (Typically the first day of the current month) - - 3. _fetchLastDay - Same as _fetchFirstDay except that this is the last day of the period - - 4. _displayWarning - Which should insert in the DOM the warning rendered template received as argument. - - This mixin is responsible for rendering the buttons in the control panel and adds the two following methods - - 1. _generateWorkEntries - */ - - var WorkEntryControllerMixin = { - - /** - * @override - * @returns {Promise} - */ - _update: function () { - var self = this; - return this._super.apply(this, arguments).then(function () { - self.firstDay = self._fetchFirstDay().toDate(); - self.lastDay = self._fetchLastDay().toDate(); - var now = moment(); - if (self.firstDay > now.add(1, 'months')) return Promise.resolve(); - return self._generateWorkEntries(); - }); - }, - - updateButtons: function() { - this._super.apply(this, arguments); - - if(!this.$buttons) { - return; - } - - this.$buttons.find('.btn-regenerate-work-entries').on('click', this._onRegenerateWorkEntries.bind(this)); - }, - - renderButtons: function($node) { - this._super.apply(this, arguments); - - if(this.$buttons) { - this.$buttons.append(this._renderWorkEntryButtons()); - } - }, - - /* - Private - */ - _renderWorkEntryButtons: function() { - return $('').append(QWeb.render('hr_work_entry.work_entry_button', { - button_text: _t("Regenerate Work Entries"), - event_class: 'btn-regenerate-work-entries', - })); - }, - - _generateWorkEntries: function () { - var self = this; - return this._rpc({ - model: 'hr.employee', - method: 'generate_work_entries', - args: [[], time.date_to_str(this.firstDay), time.date_to_str(this.lastDay)], - }).then(function (new_work_entries) { - if (new_work_entries) { - self.reload(); - } - }); - }, - - _regenerateWorkEntries: function () { - const all_rows = Object.values(this.model.allRows); - const only_employee = all_rows.length === 1 ? all_rows[0].resId : null; - this.do_action('hr_work_entry_contract.hr_work_entry_regeneration_wizard_action', { - additional_context: { - default_employee_id: only_employee, - date_start: time.date_to_str(this.firstDay), - date_end: time.date_to_str(this.lastDay), - }, - on_close: this.reload.bind(this), - }); - }, - - _onRegenerateWorkEntries: function (e) { - e.preventDefault(); - e.stopImmediatePropagation(); - this._regenerateWorkEntries(); - }, - - }; - - return WorkEntryControllerMixin; - -}); diff --git a/addons/hr_work_entry_contract/static/src/views/work_entry_calendar/work_entry_calendar.xml b/addons/hr_work_entry_contract/static/src/views/work_entry_calendar/work_entry_calendar.xml index 55031127a8c..060d3b24f52 100644 --- a/addons/hr_work_entry_contract/static/src/views/work_entry_calendar/work_entry_calendar.xml +++ b/addons/hr_work_entry_contract/static/src/views/work_entry_calendar/work_entry_calendar.xml @@ -4,7 +4,7 @@ - diff --git a/addons/mrp/static/src/scss/mrp_gantt.scss b/addons/mrp/static/src/scss/mrp_gantt.scss index f88fef16afc..f12a590f4ff 100644 --- a/addons/mrp/static/src/scss/mrp_gantt.scss +++ b/addons/mrp/static/src/scss/mrp_gantt.scss @@ -6,14 +6,14 @@ } } -.o_mrp_workorder_gantt .o_legacy_gantt_view .o_gantt_row_container .o_gantt_row .o_gantt_cell .o_gantt_pill_wrapper { - div.o_gantt_pill.decoration-success { +.o_mrp_workorder_gantt .o_gantt_cells .o_gantt_pill_wrapper div.o_gantt_pill { + &.decoration-success { @include gantt-decoration-color($success); } - div.o_gantt_pill.decoration-warning { + &.decoration-warning { @include gantt-decoration-color(map-get($grays, '500')); } - div.o_gantt_pill.decoration-danger { + &.decoration-danger { @include gantt-decoration-color($danger); } } diff --git a/addons/mrp/views/mrp_workorder_views.xml b/addons/mrp/views/mrp_workorder_views.xml index fd537f4b597..f2d7e7635db 100644 --- a/addons/mrp/views/mrp_workorder_views.xml +++ b/addons/mrp/views/mrp_workorder_views.xml @@ -343,9 +343,9 @@
    -
  • Start Date:
  • -
  • Stop Date:
  • -
  • Workcenter:
  • +
  • Start Date:
  • +
  • Stop Date:
  • +
  • Workcenter:
@@ -383,9 +383,9 @@
    -
  • Start Date:
  • -
  • Stop Date:
  • -
  • Workcenter:
  • +
  • Start Date:
  • +
  • Stop Date:
  • +
  • Workcenter:
diff --git a/addons/web/tooling/_eslintignore b/addons/web/tooling/_eslintignore index 8e149e0d268..af289693e14 100644 --- a/addons/web/tooling/_eslintignore +++ b/addons/web/tooling/_eslintignore @@ -69,6 +69,24 @@ web_cohort/static/tests/legacy/**/* web_gantt/static/src/legacy/**/* web_gantt/static/tests/legacy/**/* +# planning +# whitelist new code +!planning +!planning/static +!planning/static/src +!planning/static/src/*.js +!planning/static/tests +!planning/static/tests/planning_gantt_tests.js + +# project_enterprise +# whitelist new code +!project_enterprise +!project_enterprise/static +!project_enterprise/static/src +!project_enterprise/static/src/*.js +!project_enterprise/static/tests +!project_enterprise/static/tests/*.js + # web_map # whitelist new code !web_map