[FIX] pylint

pull/512/head
Iryna Vushnevska 2019-01-28 02:53:56 +02:00 committed by Iryna Vyshnevska
parent 3e0da15199
commit 8b894d0c0b
8 changed files with 177 additions and 161 deletions

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>) # Copyright 2019 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).- # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-
from odoo import api, models from odoo import api, models

View File

@ -638,6 +638,7 @@ ORDER BY
self._compute_account_cumul() self._compute_account_cumul()
def _compute_partner_cumul(self): def _compute_partner_cumul(self):
# pylint: disable=sql-injection
where_condition_partner_by_account = """ where_condition_partner_by_account = """
WHERE WHERE
id IN id IN

View File

@ -1,54 +1,57 @@
odoo.define('account_financial_report.account_financial_report_backend', function (require) { odoo.define('account_financial_report.account_financial_report_backend', function (require) {
'use strict'; 'use strict';
var core = require('web.core'); var core = require('web.core');
var Widget = require('web.Widget'); var Widget = require('web.Widget');
var ControlPanelMixin = require('web.ControlPanelMixin'); var ControlPanelMixin = require('web.ControlPanelMixin');
var ReportWidget = require('account_financial_report.account_financial_report_widget'); var ReportWidget = require(
'account_financial_report.account_financial_report_widget'
);
var report_backend = Widget.extend(ControlPanelMixin, { var report_backend = Widget.extend(ControlPanelMixin, {
// Stores all the parameters of the action. // Stores all the parameters of the action.
events: { events: {
'click .o_account_financial_reports_print': 'print', 'click .o_account_financial_reports_print': 'print',
'click .o_account_financial_reports_export': 'export', 'click .o_account_financial_reports_export': 'export',
}, },
init: function(parent, action) { init: function (parent, action) {
this.actionManager = parent; this.actionManager = parent;
this.given_context = {}; this.given_context = {};
this.odoo_context = action.context; this.odoo_context = action.context;
this.controller_url = action.context.url; this.controller_url = action.context.url;
if (action.context.context) { if (action.context.context) {
this.given_context = 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 ||
this.given_context.model = action.context.active_model || false; action.params.active_id;
this.given_context.ttype = action.context.ttype || false; this.given_context.model = action.context.active_model || false;
return this._super.apply(this, arguments); this.given_context.ttype = action.context.ttype || false;
}, return this._super.apply (this, arguments);
willStart: function() { },
return $.when(this.get_html()); willStart: function () {
}, return $.when(this.get_html());
set_html: function() { },
var self = this; set_html: function () {
var def = $.when(); var self = this;
if (!this.report_widget) { var def = $.when();
this.report_widget = new ReportWidget(this, this.given_context); if (!this.report_widget) {
def = this.report_widget.appendTo(this.$el); this.report_widget = new ReportWidget(this, this.given_context);
} def = this.report_widget.appendTo(this.$el);
def.then(function () { }
self.report_widget.$el.html(self.html); def.then(function () {
}); self.report_widget.$el.html(self.html);
}, });
start: function() { },
this.set_html(); start: function() {
return this._super(); this.set_html();
}, return this._super();
// Fetches the html and is previous report.context if any, else create it },
get_html: function() { // Fetches the html and is previous report.context if any, else create it
var self = this; get_html: function() {
var defs = []; var self = this;
return this._rpc({ var defs = [];
return this._rpc({
model: this.given_context.model, model: this.given_context.model,
method: 'get_html', method: 'get_html',
args: [self.given_context], args: [self.given_context],
@ -59,46 +62,50 @@ var report_backend = Widget.extend(ControlPanelMixin, {
defs.push(self.update_cp()); defs.push(self.update_cp());
return $.when.apply($, defs); 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
update_cp: function() { // to be rendered
if (this.$buttons) { update_cp: function () {
var status = { if (this.$buttons) {
breadcrumbs: this.actionManager.get_breadcrumbs(), var status = {
cp_content: {$buttons: this.$buttons}, breadcrumbs: this.actionManager.get_breadcrumbs(),
}; cp_content: {$buttons: this.$buttons},
return this.update_control_panel(status); };
} return this.update_control_panel(status);
}, }
do_show: function() { },
this._super(); do_show: function () {
this.update_cp(); this._super();
}, this.update_cp();
print: function() { },
var self = this; print: function () {
this._rpc({ var self = this;
model: this.given_context.model, this._rpc({
method: 'print_report', model: this.given_context.model,
args: [this.given_context.active_id, 'qweb-pdf'], method: 'print_report',
context: self.odoo_context, args: [this.given_context.active_id, 'qweb-pdf'],
}).then(function(result){ context: self.odoo_context,
self.do_action(result); }).then(function(result){
}); self.do_action(result);
}, });
export: function() { },
var self = this; export: function () {
this._rpc({ var self = this;
model: this.given_context.model, this._rpc({
method: 'print_report', model: this.given_context.model,
args: [this.given_context.active_id, 'xlsx'], method: 'print_report',
context: self.odoo_context, args: [this.given_context.active_id, 'xlsx'],
}) context: self.odoo_context,
.then(function(result){ })
self.do_action(result); .then(function(result){
}); self.do_action(result);
}, });
}); },
});
core.action_registry.add("account_financial_report_backend", report_backend); core.action_registry.add(
return report_backend; "account_financial_report_backend",
report_backend
);
return report_backend;
}); });

View File

@ -1,69 +1,73 @@
odoo.define('account_financial_report.account_financial_report_widget', function odoo.define('account_financial_report.account_financial_report_widget', function
(require) { (require) {
'use strict'; 'use strict';
var Widget = require('web.Widget'); var Widget = require('web.Widget');
var accountFinancialReportWidget = Widget.extend({ var accountFinancialReportWidget = Widget.extend({
events: { events: {
'click .o_account_financial_reports_web_action': 'boundLink', 'click .o_account_financial_reports_web_action':
'click .o_account_financial_reports_web_action_multi': 'boundLinkmulti', 'boundLink',
'click .o_account_financial_reports_web_action_monetary': 'boundLinkMonetary', 'click .o_account_financial_reports_web_action_multi':
'click .o_account_financial_reports_web_action_monetary_multi': 'boundLinkMonetarymulti', 'boundLinkmulti',
}, 'click .o_account_financial_reports_web_action_monetary':
init: function() { 'boundLinkMonetary',
this._super.apply(this, arguments); 'click .o_account_financial_reports_web_action_monetary_multi':
}, 'boundLinkMonetarymulti',
start: function() { },
return this._super.apply(this, arguments); init: function () {
}, this._super.apply(this, arguments);
boundLink: function(e) { },
var res_model = $(e.target).data('res-model'); start: function () {
var res_id = $(e.target).data('active-id'); return this._super.apply(this, arguments);
return this.do_action({ },
type: 'ir.actions.act_window', boundLink: function (e) {
res_model: res_model, var res_model = $(e.target).data('res-model');
res_id: res_id, var res_id = $(e.target).data('active-id');
views: [[false, 'form']], return this.do_action({
target: 'current' type: 'ir.actions.act_window',
}); res_model: res_model,
}, res_id: res_id,
boundLinkmulti: function(e) { views: [[false, 'form']],
var res_model = $(e.target).data('res-model'); target: 'current',
var domain = $(e.target).data('domain'); });
return this.do_action({ },
type: 'ir.actions.act_window', boundLinkmulti: function (e) {
res_model: res_model, var res_model = $(e.target).data('res-model');
domain: domain, var domain = $(e.target).data('domain');
views: [[false, "list"], [false, "form"]], return this.do_action({
target: 'current' type: 'ir.actions.act_window',
}); res_model: res_model,
}, domain: domain,
boundLinkMonetary: function(e) { views: [[false, "list"], [false, "form"]],
var res_model = $(e.target.parentElement).data('res-model'); target: 'current',
var res_id = $(e.target.parentElement).data('active-id'); });
return this.do_action({ },
type: 'ir.actions.act_window', boundLinkMonetary: function (e) {
res_model: res_model, var res_model = $(e.target.parentElement).data('res-model');
res_id: res_id, var res_id = $(e.target.parentElement).data('active-id');
views: [[false, 'form']], return this.do_action({
target: 'current' type: 'ir.actions.act_window',
}); res_model: res_model,
}, res_id: res_id,
boundLinkMonetarymulti: function(e) { views: [[false, 'form']],
var res_model = $(e.target.parentElement).data('res-model'); target: 'current',
var domain = $(e.target.parentElement).data('domain'); });
return this.do_action({ },
type: 'ir.actions.act_window', boundLinkMonetarymulti: function (e) {
res_model: res_model, var res_model = $(e.target.parentElement).data('res-model');
domain: domain, var domain = $(e.target.parentElement).data('domain');
views: [[false, "list"], [false, "form"]], return this.do_action({
target: 'current' type: 'ir.actions.act_window',
}); res_model: res_model,
}, domain: domain,
}); views: [[false, "list"], [false, "form"]],
target: 'current',
});
},
});
return accountFinancialReportWidget; return accountFinancialReportWidget;
}); });

View File

@ -4,7 +4,6 @@
import time import time
from odoo.api import Environment
from odoo.tests import common from odoo.tests import common
from . import abstract_test_foreign_currency as a_t_f_c from . import abstract_test_foreign_currency as a_t_f_c
@ -505,9 +504,12 @@ class TestGeneralLedgerReport(common.TransactionCase):
partner_3.write({'is_company': False}) partner_3.write({'is_company': False})
expected_list = [partner_2.id, partner_3.id, partner_4.id] expected_list = [partner_2.id, partner_3.id, partner_4.id]
context = {'active_ids': [ context = {
partner_1.id, partner_2.id, partner_3.id, partner_4.id], 'active_ids': [
'active_model': 'res.partner'} partner_1.id, partner_2.id, partner_3.id, partner_4.id
],
'active_model': 'res.partner'
}
wizard = self.env["general.ledger.report.wizard"].with_context(context) wizard = self.env["general.ledger.report.wizard"].with_context(context)
self.assertEqual(wizard._default_partners(), expected_list) self.assertEqual(wizard._default_partners(), expected_list)

View File

@ -50,9 +50,12 @@ class TestOpenItems(a_t_f_c.AbstractTestForeignCurrency):
partner_3.write({'is_company': False}) partner_3.write({'is_company': False})
expected_list = [partner_2.id, partner_3.id, partner_4.id] expected_list = [partner_2.id, partner_3.id, partner_4.id]
context = {'active_ids': [ context = {
partner_1.id, partner_2.id, partner_3.id, partner_4.id], 'active_ids': [
'active_model': 'res.partner'} partner_1.id, partner_2.id, partner_3.id, partner_4.id
],
'active_model': 'res.partner'
}
wizard = self.env["open.items.report.wizard"].with_context(context) wizard = self.env["open.items.report.wizard"].with_context(context)
self.assertEqual(wizard._default_partners(), expected_list) self.assertEqual(wizard._default_partners(), expected_list)