[FIX] pylint
parent
3e0da15199
commit
8b894d0c0b
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-
|
||||
from odoo import api, models
|
||||
|
|
|
@ -638,6 +638,7 @@ ORDER BY
|
|||
self._compute_account_cumul()
|
||||
|
||||
def _compute_partner_cumul(self):
|
||||
# pylint: disable=sql-injection
|
||||
where_condition_partner_by_account = """
|
||||
WHERE
|
||||
id IN
|
||||
|
|
|
@ -1,54 +1,57 @@
|
|||
odoo.define('account_financial_report.account_financial_report_backend', function (require) {
|
||||
'use strict';
|
||||
'use strict';
|
||||
|
||||
var core = require('web.core');
|
||||
var Widget = require('web.Widget');
|
||||
var ControlPanelMixin = require('web.ControlPanelMixin');
|
||||
var ReportWidget = require('account_financial_report.account_financial_report_widget');
|
||||
var core = require('web.core');
|
||||
var Widget = require('web.Widget');
|
||||
var ControlPanelMixin = require('web.ControlPanelMixin');
|
||||
var ReportWidget = require(
|
||||
'account_financial_report.account_financial_report_widget'
|
||||
);
|
||||
|
||||
|
||||
var report_backend = Widget.extend(ControlPanelMixin, {
|
||||
// Stores all the parameters of the action.
|
||||
events: {
|
||||
'click .o_account_financial_reports_print': 'print',
|
||||
'click .o_account_financial_reports_export': 'export',
|
||||
},
|
||||
init: function(parent, action) {
|
||||
this.actionManager = parent;
|
||||
this.given_context = {};
|
||||
this.odoo_context = action.context;
|
||||
this.controller_url = action.context.url;
|
||||
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.model = action.context.active_model || false;
|
||||
this.given_context.ttype = action.context.ttype || false;
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
willStart: function() {
|
||||
return $.when(this.get_html());
|
||||
},
|
||||
set_html: function() {
|
||||
var self = this;
|
||||
var def = $.when();
|
||||
if (!this.report_widget) {
|
||||
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);
|
||||
});
|
||||
},
|
||||
start: function() {
|
||||
this.set_html();
|
||||
return this._super();
|
||||
},
|
||||
// Fetches the html and is previous report.context if any, else create it
|
||||
get_html: function() {
|
||||
var self = this;
|
||||
var defs = [];
|
||||
return this._rpc({
|
||||
var report_backend = Widget.extend(ControlPanelMixin, {
|
||||
// Stores all the parameters of the action.
|
||||
events: {
|
||||
'click .o_account_financial_reports_print': 'print',
|
||||
'click .o_account_financial_reports_export': 'export',
|
||||
},
|
||||
init: function (parent, action) {
|
||||
this.actionManager = parent;
|
||||
this.given_context = {};
|
||||
this.odoo_context = action.context;
|
||||
this.controller_url = action.context.url;
|
||||
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.model = action.context.active_model || false;
|
||||
this.given_context.ttype = action.context.ttype || false;
|
||||
return this._super.apply (this, arguments);
|
||||
},
|
||||
willStart: function () {
|
||||
return $.when(this.get_html());
|
||||
},
|
||||
set_html: function () {
|
||||
var self = this;
|
||||
var def = $.when();
|
||||
if (!this.report_widget) {
|
||||
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);
|
||||
});
|
||||
},
|
||||
start: function() {
|
||||
this.set_html();
|
||||
return this._super();
|
||||
},
|
||||
// Fetches the html and is previous report.context if any, else create it
|
||||
get_html: function() {
|
||||
var self = this;
|
||||
var defs = [];
|
||||
return this._rpc({
|
||||
model: this.given_context.model,
|
||||
method: 'get_html',
|
||||
args: [self.given_context],
|
||||
|
@ -59,46 +62,50 @@ var report_backend = Widget.extend(ControlPanelMixin, {
|
|||
defs.push(self.update_cp());
|
||||
return $.when.apply($, defs);
|
||||
});
|
||||
},
|
||||
// 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},
|
||||
};
|
||||
return this.update_control_panel(status);
|
||||
}
|
||||
},
|
||||
do_show: function() {
|
||||
this._super();
|
||||
this.update_cp();
|
||||
},
|
||||
print: function() {
|
||||
var self = this;
|
||||
this._rpc({
|
||||
model: this.given_context.model,
|
||||
method: 'print_report',
|
||||
args: [this.given_context.active_id, 'qweb-pdf'],
|
||||
context: self.odoo_context,
|
||||
}).then(function(result){
|
||||
self.do_action(result);
|
||||
});
|
||||
},
|
||||
export: function() {
|
||||
var self = this;
|
||||
this._rpc({
|
||||
model: this.given_context.model,
|
||||
method: 'print_report',
|
||||
args: [this.given_context.active_id, 'xlsx'],
|
||||
context: self.odoo_context,
|
||||
})
|
||||
.then(function(result){
|
||||
self.do_action(result);
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
// 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},
|
||||
};
|
||||
return this.update_control_panel(status);
|
||||
}
|
||||
},
|
||||
do_show: function () {
|
||||
this._super();
|
||||
this.update_cp();
|
||||
},
|
||||
print: function () {
|
||||
var self = this;
|
||||
this._rpc({
|
||||
model: this.given_context.model,
|
||||
method: 'print_report',
|
||||
args: [this.given_context.active_id, 'qweb-pdf'],
|
||||
context: self.odoo_context,
|
||||
}).then(function(result){
|
||||
self.do_action(result);
|
||||
});
|
||||
},
|
||||
export: function () {
|
||||
var self = this;
|
||||
this._rpc({
|
||||
model: this.given_context.model,
|
||||
method: 'print_report',
|
||||
args: [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);
|
||||
return report_backend;
|
||||
core.action_registry.add(
|
||||
"account_financial_report_backend",
|
||||
report_backend
|
||||
);
|
||||
return report_backend;
|
||||
});
|
||||
|
|
|
@ -1,69 +1,73 @@
|
|||
odoo.define('account_financial_report.account_financial_report_widget', function
|
||||
(require) {
|
||||
'use strict';
|
||||
'use strict';
|
||||
|
||||
var Widget = require('web.Widget');
|
||||
var Widget = require('web.Widget');
|
||||
|
||||
|
||||
var accountFinancialReportWidget = Widget.extend({
|
||||
events: {
|
||||
'click .o_account_financial_reports_web_action': 'boundLink',
|
||||
'click .o_account_financial_reports_web_action_multi': 'boundLinkmulti',
|
||||
'click .o_account_financial_reports_web_action_monetary': 'boundLinkMonetary',
|
||||
'click .o_account_financial_reports_web_action_monetary_multi': 'boundLinkMonetarymulti',
|
||||
},
|
||||
init: function() {
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
start: function() {
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
boundLink: function(e) {
|
||||
var res_model = $(e.target).data('res-model');
|
||||
var res_id = $(e.target).data('active-id');
|
||||
return this.do_action({
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: res_model,
|
||||
res_id: res_id,
|
||||
views: [[false, 'form']],
|
||||
target: 'current'
|
||||
});
|
||||
},
|
||||
boundLinkmulti: function(e) {
|
||||
var res_model = $(e.target).data('res-model');
|
||||
var domain = $(e.target).data('domain');
|
||||
return this.do_action({
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: res_model,
|
||||
domain: domain,
|
||||
views: [[false, "list"], [false, "form"]],
|
||||
target: 'current'
|
||||
});
|
||||
},
|
||||
boundLinkMonetary: function(e) {
|
||||
var res_model = $(e.target.parentElement).data('res-model');
|
||||
var res_id = $(e.target.parentElement).data('active-id');
|
||||
return this.do_action({
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: res_model,
|
||||
res_id: res_id,
|
||||
views: [[false, 'form']],
|
||||
target: 'current'
|
||||
});
|
||||
},
|
||||
boundLinkMonetarymulti: function(e) {
|
||||
var res_model = $(e.target.parentElement).data('res-model');
|
||||
var domain = $(e.target.parentElement).data('domain');
|
||||
return this.do_action({
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: res_model,
|
||||
domain: domain,
|
||||
views: [[false, "list"], [false, "form"]],
|
||||
target: 'current'
|
||||
});
|
||||
},
|
||||
});
|
||||
var accountFinancialReportWidget = Widget.extend({
|
||||
events: {
|
||||
'click .o_account_financial_reports_web_action':
|
||||
'boundLink',
|
||||
'click .o_account_financial_reports_web_action_multi':
|
||||
'boundLinkmulti',
|
||||
'click .o_account_financial_reports_web_action_monetary':
|
||||
'boundLinkMonetary',
|
||||
'click .o_account_financial_reports_web_action_monetary_multi':
|
||||
'boundLinkMonetarymulti',
|
||||
},
|
||||
init: function () {
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
start: function () {
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
boundLink: function (e) {
|
||||
var res_model = $(e.target).data('res-model');
|
||||
var res_id = $(e.target).data('active-id');
|
||||
return this.do_action({
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: res_model,
|
||||
res_id: res_id,
|
||||
views: [[false, 'form']],
|
||||
target: 'current',
|
||||
});
|
||||
},
|
||||
boundLinkmulti: function (e) {
|
||||
var res_model = $(e.target).data('res-model');
|
||||
var domain = $(e.target).data('domain');
|
||||
return this.do_action({
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: res_model,
|
||||
domain: domain,
|
||||
views: [[false, "list"], [false, "form"]],
|
||||
target: 'current',
|
||||
});
|
||||
},
|
||||
boundLinkMonetary: function (e) {
|
||||
var res_model = $(e.target.parentElement).data('res-model');
|
||||
var res_id = $(e.target.parentElement).data('active-id');
|
||||
return this.do_action({
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: res_model,
|
||||
res_id: res_id,
|
||||
views: [[false, 'form']],
|
||||
target: 'current',
|
||||
});
|
||||
},
|
||||
boundLinkMonetarymulti: function (e) {
|
||||
var res_model = $(e.target.parentElement).data('res-model');
|
||||
var domain = $(e.target.parentElement).data('domain');
|
||||
return this.do_action({
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: res_model,
|
||||
domain: domain,
|
||||
views: [[false, "list"], [false, "form"]],
|
||||
target: 'current',
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return accountFinancialReportWidget;
|
||||
return accountFinancialReportWidget;
|
||||
|
||||
});
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
import time
|
||||
|
||||
from odoo.api import Environment
|
||||
from odoo.tests import common
|
||||
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})
|
||||
|
||||
expected_list = [partner_2.id, partner_3.id, partner_4.id]
|
||||
context = {'active_ids': [
|
||||
partner_1.id, partner_2.id, partner_3.id, partner_4.id],
|
||||
'active_model': 'res.partner'}
|
||||
context = {
|
||||
'active_ids': [
|
||||
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)
|
||||
self.assertEqual(wizard._default_partners(), expected_list)
|
||||
|
|
|
@ -39,7 +39,7 @@ class TestOpenItems(a_t_f_c.AbstractTestForeignCurrency):
|
|||
{'hide_account_at_0': True},
|
||||
{'only_posted_moves': True, 'hide_account_at_0': True},
|
||||
]
|
||||
|
||||
|
||||
def test_partner_filter(self):
|
||||
partner_1 = self.env.ref('base.res_partner_1')
|
||||
partner_2 = self.env.ref('base.res_partner_2')
|
||||
|
@ -50,9 +50,12 @@ class TestOpenItems(a_t_f_c.AbstractTestForeignCurrency):
|
|||
partner_3.write({'is_company': False})
|
||||
|
||||
expected_list = [partner_2.id, partner_3.id, partner_4.id]
|
||||
context = {'active_ids': [
|
||||
partner_1.id, partner_2.id, partner_3.id, partner_4.id],
|
||||
'active_model': 'res.partner'}
|
||||
context = {
|
||||
'active_ids': [
|
||||
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)
|
||||
self.assertEqual(wizard._default_partners(), expected_list)
|
||||
|
|
|
@ -95,7 +95,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
|||
cur_day = fields.Date.from_string(today).day
|
||||
last_fsc_month = self.env.user.company_id.fiscalyear_last_month
|
||||
last_fsc_day = self.env.user.company_id.fiscalyear_last_day
|
||||
|
||||
|
||||
if cur_month < last_fsc_month \
|
||||
or cur_month == last_fsc_month and cur_day <= last_fsc_day:
|
||||
return time.strftime('%Y-01-01')
|
||||
|
|
|
@ -59,13 +59,13 @@ class OpenItemsReportWizard(models.TransientModel):
|
|||
|
||||
def _default_partners(self):
|
||||
context = self.env.context
|
||||
|
||||
|
||||
if context.get('active_ids') and context.get('active_model') \
|
||||
== 'res.partner':
|
||||
partner_ids = context['active_ids']
|
||||
corp_partners = self.env['res.partner'].browse(partner_ids). \
|
||||
filtered(lambda p: p.parent_id)
|
||||
|
||||
|
||||
partner_ids = set(partner_ids) - set(corp_partners.ids)
|
||||
partner_ids |= set(corp_partners.mapped('parent_id.id'))
|
||||
return list(partner_ids)
|
||||
|
|
Loading…
Reference in New Issue