Files
odoo_source/addons/fleet/static/src/js/fleet_form.js
T
Aurélien (avd) fc396a4d17 [IMP] fleet: improve ux + fix contracts/services archive bug
Revamp the kanban view of fleet.vehicle.log.services.

Add some ux improvements (new filters, better naming,..).

Fix bug where contracts/services of archived fleet.vehicle were
not counted in statinfo.

When a fleet.vehicle is archived, archive its related contracts/services.

closes odoo/odoo#62556

Taskid: 2389823
Related: odoo/upgrade#2063
Related: odoo/enterprise#15036
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-02-24 12:32:11 +00:00

45 lines
1.5 KiB
JavaScript

odoo.define('fleet.FleetForm', function(require) {
"use strict";
const FormController = require('web.FormController');
const FormView = require('web.FormView');
const viewRegistry = require('web.view_registry');
const Dialog = require('web.Dialog');
const core = require('web.core');
const _t = core._t;
const FleetFormController = FormController.extend({
/**
* @override
* @private
**/
_getActionMenuItems: function (state) {
if (!this.hasActionMenus || this.mode === 'edit') {
return null;
}
var menuItems = this._super.apply(this, arguments);
var archiveAction = _.find(menuItems.items.other, (actionItem) => {return actionItem.description === _t("Archive");});
if (archiveAction) {
archiveAction.callback = () => {
Dialog.confirm(this, _t("Each Services and contracts of this vehicle will be considered as Archived. Are you sure that you want to archive this record?"), {
confirm_callback: () => this._toggleArchiveState(true),
});
};
}
return menuItems;
},
});
var FleetFormView = FormView.extend({
config: _.extend({}, FormView.prototype.config, {
Controller: FleetFormController,
}),
});
viewRegistry.add('fleet_form', FleetFormView);
return FleetFormView;
});