Skip to content

Commit

Permalink
[IMP] cleanup pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
Iryna Vyshnevska committed Mar 27, 2019
1 parent 29648d5 commit 7ddcafc
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 57 deletions.
8 changes: 2 additions & 6 deletions l10n_ch_bank/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# Copyright 2015 Yannick Vaucher (Camptocamp SA)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
from .hooks import import_csv_data


def post_init(cr, registry):
"""Import CSV data as it is faster than xml and because we can't use
noupdate anymore with csv"""
from openerp.tools import convert_file
filename = 'data/res.bank.csv'
convert_file(cr, 'l10n_ch_bank', filename, None, mode='init',
noupdate=True, kind='init', report=None)
import_csv_data(cr, registry)
16 changes: 16 additions & 0 deletions l10n_ch_bank/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo.tools import convert_file


def import_csv_data(cr, registry):
"""Import CSV data as it is faster than xml and because we can't use
noupdate anymore with csv"""
filenames = ['data/res.bank.csv']
for filename in filenames:
convert_file(
cr, 'l10n_ch_bank',
filename, None, mode='init', noupdate=True,
kind='init', report=None,
)
6 changes: 3 additions & 3 deletions l10n_ch_base_bank/tests/test_bank.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright 2014-2015 Nicolas Bessi (Camptocamp SA)
# Copyright 2015-2017 Yannick Vaucher (Camptocamp SA)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp.tests import common
from openerp.tools import mute_logger
from openerp import exceptions
from odoo.tests import common
from odoo.tools import mute_logger
from odoo import exceptions

ch_iban = 'CH15 3881 5158 3845 3843 7'
ch_post_iban = 'CH09 0900 0000 1000 8060 7'
Expand Down
6 changes: 3 additions & 3 deletions l10n_ch_pain_credit_transfer/tests/test_ch_sct.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
ch_iban = 'CH15 3881 5158 3845 3843 7'


class TestSCT_CH(AccountingTestCase):
class TestSCTCH(AccountingTestCase):

def setUp(self):
super().setUp()
Expand Down Expand Up @@ -259,15 +259,15 @@ def test_sct_ch_payment_type3(self):

def create_invoice(
self, partner_id, partner_bank_id, currency, price_unit,
ref_type, ref, type='in_invoice'):
ref_type, ref, inv_type='in_invoice'):
invoice = self.invoice_model.create({
'partner_id': partner_id,
'reference_type': ref_type,
'reference': ref,
'currency_id': currency.id,
'name': 'test',
'account_id': self.account_payable.id,
'type': type,
'type': inv_type,
'date_invoice': time.strftime('%Y-%m-%d'),
'payment_mode_id': self.payment_mode.id,
'partner_bank_id': partner_bank_id,
Expand Down
2 changes: 1 addition & 1 deletion l10n_ch_payment_slip/controllers/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def report_routes(self, reportname, docids=None, converter=None, **data):
else '{0:05d}'.format(invoice_id[0]),
'.pdf'
])
data, format = report_slip.render(invoice_id)
data, format_report = report_slip.render(invoice_id)
pdfhttpheaders = [
('Content-Type', 'application/pdf'),
('Content-Disposition', content_disposition(filename)),
Expand Down
64 changes: 32 additions & 32 deletions l10n_ch_payment_slip/static/src/js/qwebactionmanager.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
odoo.define('l10n_ch_payment_slip.report', function(require){
'use strict';
odoo.define('l10n_ch_payment_slip.report', function (require) {
'use strict';

var ActionManager= require('web.ActionManager');
var crash_manager = require('web.crash_manager');
var framework = require('web.framework');
var ActionManager= require('web.ActionManager');
var crash_manager = require('web.crash_manager');
var framework = require('web.framework');


ActionManager.include({
ir_actions_report: function (action, options){
var report_url = '';
ActionManager.include({
ir_actions_report: function (action, options) {
var report_url = '';

if (action.report_type !== 'reportlab-pdf') {
return this._super(action, options);
}
framework.blockUI();
report_url = '/report/reportlab-pdf/'.concat(
action.report_name,'/',
action.context.active_ids.join(',')
);
this.getSession().get_file({
url: report_url,
data: {data: JSON.stringify([report_url,
action.report_type,
])},
error: crash_manager.rpc_error.bind(crash_manager),
success: function() {
if(action && options && !action.dialog){
options.on_close();
}
},
});
framework.unblockUI();
return;
}
});
if (action.report_type !== 'reportlab-pdf') {
return this._super(action, options);
}
framework.blockUI();
report_url = '/report/reportlab-pdf/'.concat(
action.report_name, '/',
action.context.active_ids.join(',')
);
this.getSession().get_file({
url: report_url,
data: {data: JSON.stringify([report_url,
action.report_type,
])},
error: crash_manager.rpc_error.bind (crash_manager),
success: function() {
if (action && options && !action.dialog) {
options.on_close();
}
},
});
framework.unblockUI();
return;
},
});
});
12 changes: 6 additions & 6 deletions l10n_ch_payment_slip/tests/test_payment_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,28 @@ def test_slip_validity(self):

def test_print_report(self):
invoice = self.make_invoice()
data, format = self.report1slip_from_inv.render(invoice.id)
data, format_report = self.report1slip_from_inv.render(invoice.id)
self.assertTrue(data)
self.assertEqual(format, 'pdf')
self.assertEqual(format_report, 'pdf')

def test_print_multi_report_merge_in_memory(self):
# default value as in memory
self.assertEqual(self.env.user.company_id.merge_mode, 'in_memory')
invoice1 = self.make_invoice()
invoice2 = self.make_invoice()
data, format = self.report1slip_from_inv.render(
data, format_report = self.report1slip_from_inv.render(
[invoice1.id, invoice2.id])
self.assertTrue(data)
self.assertEqual(format, 'pdf')
self.assertEqual(format_report, 'pdf')

def test_print_multi_report_merge_on_disk(self):
self.env.user.company_id.merge_mode = 'on_disk'
invoice1 = self.make_invoice()
invoice2 = self.make_invoice()
data, format = self.report1slip_from_inv.render(
data, format_report = self.report1slip_from_inv.render(
[invoice1.id, invoice2.id])
self.assertTrue(data)
self.assertEqual(format, 'pdf')
self.assertEqual(format_report, 'pdf')

def test_address_format(self):
invoice = self.make_invoice()
Expand Down
8 changes: 2 additions & 6 deletions l10n_ch_zip/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# Copyright 2011-2017 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
from .hooks import import_csv_data


def post_init(cr, registry):
"""Import CSV data as it is faster than xml and because we can't use
noupdate anymore with csv"""
from odoo.tools import convert_file
filename = 'data/res.better.zip.csv'
convert_file(cr, 'l10n_ch_zip', filename, None, mode='init', noupdate=True,
kind='init', report=None)
import_csv_data(cr, registry)
16 changes: 16 additions & 0 deletions l10n_ch_zip/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo.tools import convert_file


def import_csv_data(cr, registry):
"""Import CSV data as it is faster than xml and because we can't use
noupdate anymore with csv"""
filenames = ['data/res.better.zip.csv']
for filename in filenames:
convert_file(
cr, 'l10n_ch_zip',
filename, None, mode='init', noupdate=True,
kind='init', report=None,
)

0 comments on commit 7ddcafc

Please sign in to comment.