diff --git a/__init__.py b/__init__.py
index 40272379f7217766e0f72a9c8f820110387c8961..9b4296142f475392fb090e036775e999aa8e4a27 100644
--- a/__init__.py
+++ b/__init__.py
@@ -1 +1,2 @@
+from . import models
from . import wizard
diff --git a/models/ebics_file.py b/models/ebics_file.py
index 8b074094cb0d69a0921d8c1fc59f2ba1696c9edc..982fd0d1826b68056be10b2e5f274c4301e3d030 100644
--- a/models/ebics_file.py
+++ b/models/ebics_file.py
@@ -9,5 +9,8 @@ class EbicsFile(models.Model):
def _split_cfonb(self, res):
# Avoid splitting cfonb in one statement per day
datas = []
- datas.append({"data": base64.b64encode(self.data)})
+ datas.append({
+ "company_id": self.env.company.id,
+ "data": self.data
+ })
return datas
diff --git a/wizard/ebics_statement_rop_import_wizard.py b/wizard/ebics_statement_rop_import_wizard.py
index dda6edc2be5f06f8c88f738bcfdca8ae96917488..5c11257de7e15915ed380345b4ef6a817c5d0652 100644
--- a/wizard/ebics_statement_rop_import_wizard.py
+++ b/wizard/ebics_statement_rop_import_wizard.py
@@ -58,15 +58,16 @@ class EbicsStatementRopImport(models.TransientModel):
_logger.debug("Creating statements for retrieved enriched moves")
ebics_mvt_file.with_context(active_model="ebics.file").process()
- bank_statement_ids = ebics_mvt_file.bank_statement_ids
- _logger.debug(f"Created statements : {bank_statement_ids.mapped('date')}")
+ bank_statement = ebics_mvt_file.bank_statement_ids
+ bank_statement.ensure_one()
+ _logger.debug(f"Created statement : {bank_statement.date}")
self.log += f"""
<strong><u>Import des mouvements enrichis<u></strong><br/>
- - Journal : {bank_statement_ids[0].journal_id.name}
- - Du : {bank_statement_ids[0].date}
- au : {bank_statement_ids[-1].date} <br/>
- Solde Initial : {bank_statement_ids[0].balance_start} €<br/>
- Solde Final : {bank_statement_ids[-1].balance_end} €
+ Référence : {bank_statement.name}
+ - Journal : {bank_statement.journal_id.name}
+ - Date : {bank_statement.date} <br/>
+ Solde Initial : {bank_statement.balance_start} €<br/>
+ Solde Final : {bank_statement.balance_end} €
<hr/>
"""
else:
@@ -98,17 +99,17 @@ class EbicsStatementRopImport(models.TransientModel):
ebics_rop_file_id = ebics_rop_wizard_act.get("context").get("ebics_file_ids")
ebics_rop_file = self.env["ebics.file"].browse(ebics_rop_file_id)
- if ebics_rop_file and bank_statement_ids:
+ if ebics_rop_file and bank_statement:
_logger.debug(f"Processing ROP file {ebics_rop_file.name}")
# Process EBICS ROP file
ebics_rop_file.ensure_one()
# Suppression de lignes CORPORATE
- lines_to_delete = bank_statement_ids.line_ids.filtered(
+ lines_to_delete = bank_statement.line_ids.filtered(
lambda line: "CORPORATE CARD" in line.payment_ref
)
line_nb = len(lines_to_delete)
_logger.debug(f"Deleting {line_nb} statement lines : {lines_to_delete.ids}")
- lines_to_delete.unlink()
+ #lines_to_delete.unlink()
self.log += f"""
<strong><u>Suppression de lignes CORPORATE<u></strong><br/>
Suppression de {line_nb} lignes.
@@ -120,11 +121,10 @@ class EbicsStatementRopImport(models.TransientModel):
rop_lines = self._get_rop_lines(ebics_rop_file.data)
for ropl in rop_lines:
_logger.debug(f"Adding {ropl['payment_ref']} - {ropl['date']}")
- _logger.debug(
- f"List of statement_ids : {bank_statement_ids.mapped('date')}"
- )
-
- ropl.update({"statement_id": bank_statement_ids[0].id})
+ ropl.update({
+ "statement_id": bank_statement.id,
+ "journal_id": ebics_conf_id.journal_ids[0].id
+ })
self.env["account.bank.statement.line"].create(ropl)
ebics_rop_file.set_to_done()
@@ -156,19 +156,20 @@ class EbicsStatementRopImport(models.TransientModel):
"res_model": "ebics.statement.import.wizard",
"view_id": result_view.id,
"context": {
- "statement_ids": bank_statement_ids.ids if ebics_mvt_file else None
+ "statement_id": bank_statement.id if ebics_mvt_file else None
},
"target": "new",
"type": "ir.actions.act_window",
}
- def view_statements(self):
- action = self.env["ir.actions.act_window"]._for_xml_id(
- "account.action_bank_statement_tree"
- )
- domain = [("id", "in", self.env.context.get("statement_ids"))]
- action["domain"] = domain
- return action
+ def view_statement(self):
+ statement_id = self.env.context.get("statement_id")
+ return {
+ "res_id": statement_id,
+ "view_mode": form,
+ "res_model": "account.bank.statement",
+ "type": "ir.actions.act_window",
+ }
def _get_rop_lines(self, data):
"""
diff --git a/wizard/ebics_statement_rop_import_wizard.xml b/wizard/ebics_statement_rop_import_wizard.xml
index 57e4ef50c4d0aea09128c500ea8480c312a47109..de86585cb13e4225b82280783c4323802c87d8da 100644
--- a/wizard/ebics_statement_rop_import_wizard.xml
+++ b/wizard/ebics_statement_rop_import_wizard.xml
@@ -50,11 +50,11 @@
<field name="log" colspan="4" nolabel="1" widget="html" readonly="1" />
<footer>
<button
- name="view_statements"
- string="Voir les relevés"
+ name="view_statement"
+ string="Voir le relevé"
type="object"
class="oe_highlight"
- invisible="not context.get('statement_ids', False)"
+ invisible="not context.get('statement_id', False)"
/>
<button string="Annuler" class="oe_link" special="cancel" />
</footer>