[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 <boi@odoo.com> Co-authored-by: Julien Mougenot <jum@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
This commit is contained in:
committed by
Mathieu Duckerts-Antoine
co-authored by
Julien Mougenot
Mathieu Duckerts-Antoine
parent
efe09fd7ad
commit
859a289b01
@@ -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 $('<span>').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;
|
||||
|
||||
});
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<t t-name="hr_work_entry_contract.calendar.controlButtons" t-inherit="web.CalendarController.controlButtons" t-inherit-mode="primary" owl="1">
|
||||
<xpath expr="//ViewScaleSelector" position="after">
|
||||
<span class="btn-regenerate-work-entries">
|
||||
<button class="btn btn-secondary" t-on-click="onRegenerateWorkEntries">
|
||||
<button class="btn btn-secondary ms-3" t-on-click="onRegenerateWorkEntries">
|
||||
Regenerate Work Entries
|
||||
</button>
|
||||
</span>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,9 +343,9 @@
|
||||
<div class="row g-0">
|
||||
<div class="col">
|
||||
<ul class="ps-1 mb-0 list-unstyled">
|
||||
<li><strong>Start Date: </strong> <t t-out="userTimezoneStartDate.format('L LTS')"/></li>
|
||||
<li><strong>Stop Date: </strong> <t t-out="userTimezoneStopDate.format('L LTS')"/></li>
|
||||
<li><strong>Workcenter: </strong> <t t-out="workcenter_id[1]"/></li>
|
||||
<li><strong>Start Date: </strong> <t t-esc="date_planned_start.toFormat('F')"/></li>
|
||||
<li><strong>Stop Date: </strong> <t t-esc="date_planned_finished.toFormat('F')"/></li>
|
||||
<li><strong>Workcenter: </strong> <t t-esc="workcenter_id[1]"/></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -383,9 +383,9 @@
|
||||
<div class="row g-0">
|
||||
<div class="col">
|
||||
<ul class="ps-1 mb-0 list-unstyled">
|
||||
<li><strong>Start Date: </strong> <t t-out="userTimezoneStartDate.format('L LTS')"/></li>
|
||||
<li><strong>Stop Date: </strong> <t t-out="userTimezoneStopDate.format('L LTS')"/></li>
|
||||
<li><strong>Workcenter: </strong> <t t-out="workcenter_id[1]"/></li>
|
||||
<li><strong>Start Date: </strong><t t-esc="date_planned_start.toFormat('F')"/></li>
|
||||
<li><strong>Stop Date: </strong><t t-esc="date_planned_finished.toFormat('F')"/></li>
|
||||
<li><strong>Workcenter: </strong> <t t-esc="workcenter_id[1]"/></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user