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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
openerp.help_online = function (instance) {
var QWeb = instance.web.qweb;
var _t = instance.web._t;
var _lt = instance.web._lt;
instance.web.ListView.include({
load_list: function () {
var self = this;
var add_button = false;
if (!this.$buttons) {
add_button = true;
}
this._super.apply(this, arguments);
this.$buttons.on('click', '.oe_list_button_help_online', function() {
self.do_action({
type: 'ir.actions.act_url',
url: '/partner_mobile',
target: 'self',
});
});
},
});
openerp.web.TreeView.include({
view_loading: function(r) {
var ret = this._super(r);
if(! _.isUndefined(this.ViewManager.load_help_buttons)){
this.ViewManager.load_help_buttons();
}
return ret
},
});
openerp.web.ListView.include({
view_loading: function(r) {
var ret = this._super(r);
if(! _.isUndefined(this.ViewManager.load_help_buttons)){
this.ViewManager.load_help_buttons();
}
return ret
},
});
openerp.web.FormView.include({
view_loading: function(r) {
var ret = this._super(r);
if(!_.isUndefined(this.ViewManager.clean_help_buttons)){
this.ViewManager.clean_help_buttons();
}
return ret
},
do_show: function (options){
var ret = this._super(options);
if(! _.isUndefined(this.ViewManager.load_help_buttons)){
this.ViewManager.load_help_buttons();
}
return ret
},
});
openerp.web.ViewManager.include({
clean_help_buttons:function() {
this.$el.find("div.oe_help_online_buttons").first().remove();
},
load_help_buttons:function() {
var self = this;
this.rpc('/help_online/build_url', {model: this.dataset.model, view_type: this.active_view}).then(function(result) {
self.clean_help_buttons();
if (result && ! _.isEmpty(result)) {
self.$helpButtonsEl = $(QWeb.render("HelpOnline.Buttons", {'view_manager':self, 'url_info': result}));
self.$el.find("ul.oe_view_manager_switch.oe_button_group.oe_right").first().before(self.$helpButtonsEl);
self.$helpButtonsEl.find('a.oe_list_button_help_online').tooltip();
if (result.exists === false) {
self.$helpButtonsEl.find('li').addClass('oe_help_online_not_found')
self.$helpButtonsEl.find('a.oe_list_button_help_online').on('click', function (event) {
var evt = event;
evt.preventDefault();
var dialog = new instance.web.Dialog(this, {
title: _t('Confirm'),
buttons: [
{text: _t("Cancel"), click: function() {
this.parents('.modal').modal('hide');
return false;
}
},
{text: _t("Ok"), click: function() {
this.parents('.modal').modal('hide');
var form = $("<form></form>");
form.attr(
{
id : "formform",
// The location given in the link itself
action : evt.target.href,
method : "GET",
// Open in new window/tab
target : evt.target.target
});
$("body").append(form);
$("#formform").submit();
$("#formform").remove();
return false;
}
}
],
}, $('<div/>').text(_t('Page does not exist. Do you want to create?'))).open();
});
}
}
});
},
});
}