|
@ -19,15 +19,21 @@ |
|
|
# |
|
|
# |
|
|
############################################################################## |
|
|
############################################################################## |
|
|
import base64 |
|
|
import base64 |
|
|
from openerp import models |
|
|
|
|
|
|
|
|
from openerp import api, models |
|
|
from openerp.tests.common import TransactionCase |
|
|
from openerp.tests.common import TransactionCase |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
acc_number = 'BE1234567890' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HelloWorldParser(models.TransientModel): |
|
|
class HelloWorldParser(models.TransientModel): |
|
|
_inherit = 'account.bank.statement.import' |
|
|
_inherit = 'account.bank.statement.import' |
|
|
|
|
|
|
|
|
def _parse_file(self, cr, uid, data_file, context=None): |
|
|
|
|
|
return 'EUR', 'BE1234567890', [{ |
|
|
|
|
|
|
|
|
@api.model |
|
|
|
|
|
def _parse_file(self, data_file): |
|
|
|
|
|
return [{ |
|
|
|
|
|
'currency_code': 'EUR', |
|
|
|
|
|
'account_number': acc_number, |
|
|
'name': '000000123', |
|
|
'name': '000000123', |
|
|
'date': '2013-06-26', |
|
|
'date': '2013-06-26', |
|
|
'transactions': [{ |
|
|
'transactions': [{ |
|
@ -42,16 +48,21 @@ class HelloWorldParser(models.TransientModel): |
|
|
class TestSaveFile(TransactionCase): |
|
|
class TestSaveFile(TransactionCase): |
|
|
def test_SaveFile(self): |
|
|
def test_SaveFile(self): |
|
|
HelloWorldParser._build_model(self.registry, self.cr) |
|
|
HelloWorldParser._build_model(self.registry, self.cr) |
|
|
testmodel = self.env['account.bank.statement.import'] |
|
|
|
|
|
testmodel._prepare_setup() |
|
|
|
|
|
testmodel._setup_base(False) |
|
|
|
|
|
testmodel._setup_fields() |
|
|
|
|
|
testmodel._setup_complete() |
|
|
|
|
|
testmodel._auto_init() |
|
|
|
|
|
action = self.env['account.bank.statement.import']\ |
|
|
|
|
|
.with_context( |
|
|
|
|
|
journal_id=self.env['account.journal'] |
|
|
|
|
|
.search([('currency.name', '=', 'EUR')]).ids[0])\ |
|
|
|
|
|
|
|
|
import_wizard = self.env['account.bank.statement.import'] |
|
|
|
|
|
import_wizard._prepare_setup() |
|
|
|
|
|
import_wizard._setup_base(False) |
|
|
|
|
|
import_wizard._setup_fields() |
|
|
|
|
|
import_wizard._setup_complete() |
|
|
|
|
|
import_wizard._auto_init() |
|
|
|
|
|
journal_id = self.env['res.partner.bank'].search([ |
|
|
|
|
|
('acc_number', '=', acc_number), |
|
|
|
|
|
]).journal_id.id |
|
|
|
|
|
if not journal_id: |
|
|
|
|
|
account = import_wizard._create_bank_account(acc_number) |
|
|
|
|
|
journal_id = self.env['account.journal']\ |
|
|
|
|
|
.search([('currency.name', '=', 'EUR')]).ids[0] |
|
|
|
|
|
account.journal_id = journal_id |
|
|
|
|
|
action = import_wizard.with_context(journal_id=journal_id)\ |
|
|
.create({'data_file': base64.b64encode('hello world')})\ |
|
|
.create({'data_file': base64.b64encode('hello world')})\ |
|
|
.import_file() |
|
|
.import_file() |
|
|
for statement in self.env['account.bank.statement'].browse( |
|
|
for statement in self.env['account.bank.statement'].browse( |
|
|