mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
Fix warning
Port tests to v12 and python3
This commit is contained in:
@@ -9,7 +9,9 @@ class AccountBankStatement(models.Model):
|
|||||||
|
|
||||||
import_file = fields.Many2one(
|
import_file = fields.Many2one(
|
||||||
'ir.attachment', 'Import file', readonly=True)
|
'ir.attachment', 'Import file', readonly=True)
|
||||||
import_date = fields.Datetime(related='import_file.create_date')
|
import_date = fields.Datetime(
|
||||||
import_user = fields.Many2one(related='import_file.create_uid')
|
related='import_file.create_date', string='Imported on')
|
||||||
|
import_user = fields.Many2one(
|
||||||
|
related='import_file.create_uid', string='Imported by')
|
||||||
import_log = fields.Text(
|
import_log = fields.Text(
|
||||||
related='import_file.description', string='Import Warnings')
|
related='import_file.description', string='Import Warnings')
|
||||||
|
|||||||
@@ -24,11 +24,12 @@ class AccountBankStatementImport(models.TransientModel):
|
|||||||
@api.model
|
@api.model
|
||||||
def _prepare_import_file_attachment(self, data_file, statement_id,
|
def _prepare_import_file_attachment(self, data_file, statement_id,
|
||||||
notifications, filename):
|
notifications, filename):
|
||||||
|
if not filename:
|
||||||
|
filename = '<unknown>'
|
||||||
return {
|
return {
|
||||||
'name': filename,
|
'name': filename,
|
||||||
'res_model': 'account.bank.statement',
|
'res_model': 'account.bank.statement',
|
||||||
'res_id': statement_id,
|
'res_id': statement_id,
|
||||||
'type': 'binary',
|
|
||||||
'datas': data_file,
|
'datas': data_file,
|
||||||
'datas_fname': filename,
|
'datas_fname': filename,
|
||||||
'description': '\n'.join(
|
'description': '\n'.join(
|
||||||
|
|||||||
@@ -1,5 +1 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2015 Therp BV (<http://therp.nl>).
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
||||||
|
|
||||||
from . import test_save_file
|
from . import test_save_file
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2015-2019 Therp BV (<http://therp.nl>).
|
||||||
# © 2015 Therp BV (<http://therp.nl>).
|
# Copyright 2017-Today Mourad EL HADJ MIMOUNE
|
||||||
# © 2017 Today Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
|
# <mourad.elhadj.mimoune@akretion.com>
|
||||||
# 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).
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
@@ -19,7 +19,7 @@ class HelloWorldParser(models.TransientModel):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _parse_file(self, data_file):
|
def _parse_file(self, data_file):
|
||||||
if module_name in data_file:
|
if data_file == module_name.encode('utf-8'):
|
||||||
return self._mock_parse(data_file)
|
return self._mock_parse(data_file)
|
||||||
else:
|
else:
|
||||||
return super(HelloWorldParser, self)._parse_file(data_file)
|
return super(HelloWorldParser, self)._parse_file(data_file)
|
||||||
@@ -58,14 +58,12 @@ class TestSaveFile(TransactionCase):
|
|||||||
HelloWorldParser._build_model(self.registry, self.cr)
|
HelloWorldParser._build_model(self.registry, self.cr)
|
||||||
import_wizard = self.env['account.bank.statement.import']
|
import_wizard = self.env['account.bank.statement.import']
|
||||||
journal_id = self.bank_journal_euro.id
|
journal_id = self.bank_journal_euro.id
|
||||||
|
data_file = base64.b64encode(module_name.encode('utf-8'))
|
||||||
import_wizard_id = import_wizard.with_context(journal_id=journal_id)\
|
import_wizard_id = import_wizard.with_context(journal_id=journal_id)\
|
||||||
.create({
|
.create({'data_file': data_file, 'filename': 'test.ofx'})
|
||||||
'data_file': base64.b64encode(bytes(
|
|
||||||
'account_bank_statement_import_save_file: Hello world'))
|
|
||||||
})
|
|
||||||
action = import_wizard_id.import_file()
|
action = import_wizard_id.import_file()
|
||||||
for statement in self.env['account.bank.statement'].browse(
|
for statement in self.env['account.bank.statement'].browse(
|
||||||
action['context']['statement_ids']):
|
action['context']['statement_ids']):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
base64.b64decode(statement.import_file.datas),
|
base64.b64decode(statement.import_file.datas),
|
||||||
'account_bank_statement_import_save_file: Hello world')
|
module_name.encode('utf-8'))
|
||||||
|
|||||||
Reference in New Issue
Block a user