summaryrefslogtreecommitdiff
path: root/addons/mrp/static/src/js/mrp_workorder_popover.js
blob: 7e392c09c7ace5bec220d804b6a788d39b563d0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
odoo.define('mrp.mrp_workorder_popover', function (require) {
'use strict';

var PopoverWidget = require('stock.popover_widget');
var fieldRegistry = require('web.field_registry');
var core = require('web.core');
var _t = core._t;


/**
 * Link to a Char field representing a JSON:
 * {
 *  'replan': <REPLAN_BOOL>, // Show the replan btn
 *  'color': '<COLOR_CLASS>', // Color Class of the icon (d-none to hide)
 *  'infos': [
 *      {'msg' : '<MESSAGE>', 'color' : '<COLOR_CLASS>'},
 *      {'msg' : '<MESSAGE>', 'color' : '<COLOR_CLASS>'},
 *      ... ]
 * }
 */
var MrpWorkorderPopover = PopoverWidget.extend({
    popoverTemplate: 'mrp.workorderPopover',
    title: _t('Scheduling Information'),

    _render: function () {
        this._super.apply(this, arguments);
        if (! this.$popover) {
          return;
        }
        var self = this;
        this.$popover.find('.action_replan_button').click(function (e) {
            self._onReplanClick(e);
        });
    },

    _onReplanClick:function (e) {
        var self = this;
        this._rpc({
            model: 'mrp.workorder',
            method: 'action_replan',
            args: [[self.res_id]]
        }).then(function () {
            self.trigger_up('reload');
        });
    },
});

fieldRegistry.add('mrp_workorder_popover', MrpWorkorderPopover);

return MrpWorkorderPopover;
});