|
|
@ -4,7 +4,8 @@ odoo.define('account_financial_report_qweb.account_financial_report_backend', fu |
|
|
|
var core = require('web.core'); |
|
|
|
var Widget = require('web.Widget'); |
|
|
|
var ControlPanelMixin = require('web.ControlPanelMixin'); |
|
|
|
var ReportWidget = require('account_financial_report_qweb.account_financial_report_widget'); |
|
|
|
var ReportWidget = require( |
|
|
|
'account_financial_report_qweb.account_financial_report_widget'); |
|
|
|
var Model = require('web.Model'); |
|
|
|
|
|
|
|
|
|
|
@ -22,7 +23,8 @@ var report_backend = Widget.extend(ControlPanelMixin, { |
|
|
|
if (action.context.context) { |
|
|
|
this.given_context = action.context.context; |
|
|
|
} |
|
|
|
this.given_context.active_id = action.context.active_id || action.params.active_id; |
|
|
|
this.given_context.active_id = action.context.active_id || |
|
|
|
action.params.active_id; |
|
|
|
this.given_context.model = action.context.active_model || false; |
|
|
|
this.given_context.ttype = action.context.ttype || false; |
|
|
|
return this._super.apply(this, arguments); |
|
|
@ -45,23 +47,22 @@ var report_backend = Widget.extend(ControlPanelMixin, { |
|
|
|
this.set_html(); |
|
|
|
return this._super(); |
|
|
|
}, |
|
|
|
// Fetches the html and is previous report.context if any, else create it
|
|
|
|
// Fetches the html and is previous report.context if any,
|
|
|
|
// else create it
|
|
|
|
get_html: function () { |
|
|
|
var self = this; |
|
|
|
var defs = []; |
|
|
|
self.model = new Model(this.given_context.model); |
|
|
|
return self.model.call('get_html', [this.given_context], {context: self.odoo_context}).then(function |
|
|
|
(result) { |
|
|
|
return self.model.call('get_html', [this.given_context], |
|
|
|
{context: self.odoo_context}).then(function (result) { |
|
|
|
self.html = result.html; |
|
|
|
defs.push(self.update_cp()); |
|
|
|
return $.when.apply($, defs); |
|
|
|
}); |
|
|
|
}, |
|
|
|
// Updates the control panel and render the elements that have yet to be rendered
|
|
|
|
// Updates the control panel and render the elements that have yet to
|
|
|
|
// be rendered
|
|
|
|
update_cp: function () { |
|
|
|
if (!this.$buttons) { |
|
|
|
|
|
|
|
} |
|
|
|
var status = { |
|
|
|
breadcrumbs: this.actionManager.get_breadcrumbs(), |
|
|
|
cp_content: {$buttons: this.$buttons}, |
|
|
@ -75,7 +76,8 @@ var report_backend = Widget.extend(ControlPanelMixin, { |
|
|
|
print: function () { |
|
|
|
var self = this; |
|
|
|
self.model = new Model(this.given_context.model); |
|
|
|
self.model.call('print_report', [this.given_context.active_id, 'qweb-pdf'], {context: self.odoo_context}) |
|
|
|
self.model.call('print_report', [this.given_context.active_id, |
|
|
|
'qweb-pdf'], {context: self.odoo_context}) |
|
|
|
.then(function (result) { |
|
|
|
self.do_action(result); |
|
|
|
}); |
|
|
@ -83,13 +85,15 @@ var report_backend = Widget.extend(ControlPanelMixin, { |
|
|
|
export: function () { |
|
|
|
var self = this; |
|
|
|
self.model = new Model(this.given_context.model); |
|
|
|
self.model.call('print_report', [this.given_context.active_id, 'xlsx'], {context: self.odoo_context}) |
|
|
|
self.model.call('print_report', [this.given_context.active_id, |
|
|
|
'xlsx'], {context: self.odoo_context}) |
|
|
|
.then(function (result) { |
|
|
|
self.do_action(result); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
core.action_registry.add("account_financial_report_backend", report_backend); |
|
|
|
core.action_registry.add("account_financial_report_backend", |
|
|
|
report_backend); |
|
|
|
return report_backend; |
|
|
|
}); |