|
@ -6,77 +6,91 @@ odoo.define("report_qweb_encrypt.Dialog", function (require) { |
|
|
var ActionManager = require("web.ActionManager"); |
|
|
var ActionManager = require("web.ActionManager"); |
|
|
var framework = require("web.framework"); |
|
|
var framework = require("web.framework"); |
|
|
var Dialog = require("web.Dialog"); |
|
|
var Dialog = require("web.Dialog"); |
|
|
var core = require('web.core'); |
|
|
|
|
|
|
|
|
var core = require("web.core"); |
|
|
|
|
|
|
|
|
var _t = core._t; |
|
|
var _t = core._t; |
|
|
|
|
|
|
|
|
var EncryptDialog = Dialog.extend({ |
|
|
var EncryptDialog = Dialog.extend({ |
|
|
events: _.extend({}, Dialog.prototype.events, { |
|
|
events: _.extend({}, Dialog.prototype.events, { |
|
|
change: '_onChange', |
|
|
|
|
|
|
|
|
change: "_onChange", |
|
|
}), |
|
|
}), |
|
|
_setValue: function () { |
|
|
_setValue: function () { |
|
|
this.value = this.$el.find('.o_password').val() |
|
|
|
|
|
|
|
|
this.value = this.$el.find(".o_password").val(); |
|
|
}, |
|
|
}, |
|
|
_onChange: function (event) { |
|
|
_onChange: function (event) { |
|
|
this._setValue(); |
|
|
this._setValue(); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
}); |
|
|
EncryptDialog.askPassword = function (owner, action, action_options, options) { |
|
|
EncryptDialog.askPassword = function (owner, action, action_options, options) { |
|
|
var buttons = [ |
|
|
var buttons = [ |
|
|
{ |
|
|
{ |
|
|
text: _t("Ok"), |
|
|
text: _t("Ok"), |
|
|
classes: 'btn-primary', |
|
|
|
|
|
|
|
|
classes: "btn-primary", |
|
|
close: true, |
|
|
close: true, |
|
|
click: function (event) { |
|
|
click: function (event) { |
|
|
var password = this.value || false; |
|
|
var password = this.value || false; |
|
|
owner._executeReportAction(action, action_options, password) |
|
|
|
|
|
|
|
|
owner._executeReportAction(action, action_options, password); |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
text: _t("Cancel"), |
|
|
text: _t("Cancel"), |
|
|
close: true, |
|
|
close: true, |
|
|
click: false, |
|
|
click: false, |
|
|
} |
|
|
|
|
|
|
|
|
}, |
|
|
]; |
|
|
]; |
|
|
return new EncryptDialog(owner, _.extend({ |
|
|
|
|
|
size: 'small', |
|
|
|
|
|
|
|
|
return new EncryptDialog( |
|
|
|
|
|
owner, |
|
|
|
|
|
_.extend( |
|
|
|
|
|
{ |
|
|
|
|
|
size: "small", |
|
|
buttons: buttons, |
|
|
buttons: buttons, |
|
|
$content: $('<div><input class="o_password" type="password"/></div>'), |
|
|
|
|
|
|
|
|
$content: $( |
|
|
|
|
|
'<div><input class="o_password" type="password"/></div>' |
|
|
|
|
|
), |
|
|
title: _t("Encrypt"), |
|
|
title: _t("Encrypt"), |
|
|
}, options)).open(); |
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
options |
|
|
|
|
|
) |
|
|
|
|
|
).open(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
ActionManager.include({ |
|
|
ActionManager.include({ |
|
|
_executeReportAction: function (action, options, password) { |
|
|
_executeReportAction: function (action, options, password) { |
|
|
if (action.encrypt === 'manual' |
|
|
|
|
|
&& action.report_type === 'qweb-pdf' |
|
|
|
|
|
&& password === undefined) { |
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
|
action.encrypt === "manual" && |
|
|
|
|
|
action.report_type === "qweb-pdf" && |
|
|
|
|
|
password === undefined |
|
|
|
|
|
) { |
|
|
EncryptDialog.askPassword(this, action, options); |
|
|
EncryptDialog.askPassword(this, action, options); |
|
|
return $.Deferred(); |
|
|
return $.Deferred(); |
|
|
} |
|
|
|
|
|
else if (action.encrypt === 'manual') { |
|
|
|
|
|
|
|
|
} else if (action.encrypt === "manual") { |
|
|
action.context = _.extend({}, action.context, { |
|
|
action.context = _.extend({}, action.context, { |
|
|
encrypt_password: password, |
|
|
encrypt_password: password, |
|
|
}) |
|
|
|
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
return this._super(action, options, password) |
|
|
|
|
|
|
|
|
return this._super(action, options, password); |
|
|
}, |
|
|
}, |
|
|
_makeReportUrls: function (action) { |
|
|
_makeReportUrls: function (action) { |
|
|
var reportUrls = this._super.apply(this, arguments); |
|
|
var reportUrls = this._super.apply(this, arguments); |
|
|
if (action.encrypt === 'manual' && action.context.encrypt_password) { |
|
|
|
|
|
if (_.isUndefined(action.data) || _.isNull(action.data) || |
|
|
|
|
|
(_.isObject(action.data) && _.isEmpty(action.data))) { |
|
|
|
|
|
var serializedOptionsPath = '?context=' + encodeURIComponent(JSON.stringify({ |
|
|
|
|
|
|
|
|
if (action.encrypt === "manual" && action.context.encrypt_password) { |
|
|
|
|
|
if ( |
|
|
|
|
|
_.isUndefined(action.data) || |
|
|
|
|
|
_.isNull(action.data) || |
|
|
|
|
|
(_.isObject(action.data) && _.isEmpty(action.data)) |
|
|
|
|
|
) { |
|
|
|
|
|
var serializedOptionsPath = |
|
|
|
|
|
"?context=" + |
|
|
|
|
|
encodeURIComponent( |
|
|
|
|
|
JSON.stringify({ |
|
|
encrypt_password: action.context.encrypt_password, |
|
|
encrypt_password: action.context.encrypt_password, |
|
|
})); |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
); |
|
|
reportUrls = _.mapObject(reportUrls, function (value) { |
|
|
reportUrls = _.mapObject(reportUrls, function (value) { |
|
|
return value += serializedOptionsPath; |
|
|
|
|
|
|
|
|
return (value += serializedOptionsPath); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return reportUrls; |
|
|
return reportUrls; |
|
|
} |
|
|
|
|
|
|
|
|
}, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
}); |
|
|
}); |