[MIG] Migrate to 9.0

This commit is contained in:
Laurent Mignon
2016-06-22 11:34:15 +02:00
parent b7a980abcd
commit 80cd9e9024
34 changed files with 841 additions and 806 deletions

View File

@@ -1,12 +1,3 @@
li.oe_help_online_not_found {
a.o_help_online_not_found {
background-color: #df3f3f;
}
.openerp .oe_view_manager .oe_view_manager_switch .oe_list_button_help_online:after {
font-size: 28px;
content: "?";
text-align: center;
margin: 3px auto 4px;
position: relative;
display: inline-block;
}
}

View File

@@ -1,115 +1,86 @@
openerp.help_online = function (instance) {
var QWeb = instance.web.qweb;
var _t = instance.web._t;
var _lt = instance.web._lt;
odoo.define('oca.HelpOnline', function (require) {
"use strict";
instance.web.ListView.include({
load_list: function () {
var self = this;
var add_button = false;
if (!this.$buttons) {
add_button = true;
}
var core = require('web.core');
var QWeb = core.qweb;
var _t = core._t;
var ViewManager = require('web.ViewManager');
var ControlPanel = require('web.ControlPanel');
var Dialog = require('web.Dialog');
ControlPanel.include({
start: function(){
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
this._toggle_visibility(true);
this.nodes = _.extend(
this.nodes,
{$help_online_buttons: this.$('.o_help_online_buttons')});
this._toggle_visibility(false);
},
});
openerp.web.ViewManager.include({
clean_help_buttons:function() {
this.$el.find("div.oe_help_online_buttons").first().remove();
ViewManager.include({
/**
* This function render the help button with the informations received
* from the call to the method build_url from the help_online controller
*/
render_help_button: function(url_info){
var $helpButton = $(QWeb.render("HelpOnline.Button", {'view_manager':this, 'url_info': url_info}));
$helpButton.tooltip();
if (url_info.exists === false) {
$helpButton.on('click', function (event) {
var evt = event;
evt.preventDefault();
Dialog.confirm(
self,
_t('Page does not exist. Do you want to create?'),
{confirm_callback: function() {
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;
}
});
});
}
return $helpButton;
},
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();
/**
* This function render the help buttons container on the view.
* It should be called after start() by render_view_control_elements.
* @param {control_elements} the list of control elements to display into the ControlPanel
*/
render_help_buttons: function(control_elements){
if (! control_elements.$help_online_buttons){
control_elements.$help_online_buttons = $('<div/>');
}
var self = this;
this.rpc('/help_online/build_url', {model: this.dataset.model, view_type: this.active_view.type}).then(function(result) {
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();
});
}
var $helpButton = self.render_help_button(result);
control_elements.$help_online_buttons = $helpButton;
// update the control panel with the new help button
self.update_control_panel({cp_content: _.extend({}, self.searchview_elements, control_elements)}, {clear: false});
}
});
},
render_view_control_elements: function() {
var control_elements = this._super.apply(this, arguments);
this.render_help_buttons(control_elements);
return control_elements;
},
});
}
});

View File

@@ -1,21 +0,0 @@
(function () {
'use strict';
var website = openerp.website;
var _t = openerp._t;
website.RTE.include({
_config: function () {
// add anchor button
var config = this._super();
config.plugins = config.plugins.concat(',link');
_.each(config.toolbar, function (tb) {
if (tb.name === 'span'){
tb.items.unshift('Anchor');
}
});
return config;
},
});
})();

View File

@@ -1,13 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<templates>
<t t-name='HelpOnline.Buttons'>
<div class='oe_help_online_buttons'>
<ul class='oe_view_manager_switch oe_button_group oe_right'>
<li class='oe_i'>
<a class='oe_list_button_help_online'
t-att-title='url_info.title'
t-att-href='url_info.url' target='_blank'></a>
</li>
</ul>
<t t-name='HelpOnline.Button'>
<t t-if='url_info'>
<a t-att-class="'fa fa-question-circle btn btn-icon o_help_online_button ' + (url_info.exists? '': 'o_help_online_not_found')"
t-att-title='url_info.title' t-att-href='url_info.url'
target='_blank'></a>
</t>
</t>
<t t-name='HelpOnline.ButtonsContainer'>
<div class='hidden-xs btn-group btn-group-sm o_help_online_buttons'>
</div>
</t>
</t>
<t t-extend="ControlPanel">
<t t-jquery="div.o_cp_switch_buttons" t-operation="after">
<t t-call='HelpOnline.ButtonsContainer' />
</t>
<t t-jquery="div.oe-cp-switch-buttons" t-operation="after">
<t t-call='HelpOnline.ButtonsContainer' />
</t>
</t>
<t t-extend="X2ManyControlPanel">
<t t-jquery="div.o_cp_pager" t-operation="after">
<t t-call='HelpOnline.ButtonsContainer' />
</t>
<t t-jquery="div.oe-cp-pager" t-operation="after">
<div class="pull-right">
<t t-call='HelpOnline.ButtonsContainer' />
</div>
</t>
</t>
</templates>