diff --git a/wizard/ebics_statement_rop_import_wizard.py b/wizard/ebics_statement_rop_import_wizard.py index 550b7695880368bb10d52e75f772d176e98e93a6..3c03960b5b99b3c82fb4cf71248a500519197a4b 100644 --- a/wizard/ebics_statement_rop_import_wizard.py +++ b/wizard/ebics_statement_rop_import_wizard.py @@ -52,15 +52,15 @@ class EbicsStatementRopImport(models.TransientModel): if ebics_mvt_file: # Process EBICS MVT (= create bank statement) ebics_mvt_file.process() - bank_statement = ebics_mvt_file.bank_statement_ids - bank_statement.ensure_one() + bank_statement_ids = ebics_mvt_file.bank_statement_ids self.log += f""" <strong><u>Import des mouvements enrichis<u></strong><br/> - 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} € + {ebics_mvt_file.note_process} + - 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} € <hr/> """ else: @@ -90,15 +90,15 @@ 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: + if ebics_rop_file and bank_statement_ids: # Process EBICS ROP file ebics_rop_file.ensure_one() # Suppression de lignes CORPORATE - line_to_delete = bank_statement.line_ids.filtered( + lines_to_delete = bank_statement_ids.line_ids.filtered( lambda line: "CORPORATE CARD" in line.name ) - line_nb = len(line_to_delete) - line_to_delete.unlink() + line_nb = len(lines_to_delete) + lines_to_delete.unlink() self.log += f""" <strong><u>Suppression de lignes CORPORATE<u></strong><br/> Suppression de {line_nb} lignes. @@ -108,9 +108,12 @@ class EbicsStatementRopImport(models.TransientModel): # Ajout des lignes ROP rop_lines = self._get_rop_lines(ebics_rop_file.data) for ropl in rop_lines: - ropl.update({"statement_id": bank_statement.id}) + statement_id = bank_statement_ids.filtered( + lambda st: ropl["date"] == st.date + )[0] + ropl.update({"statement_id": statement_id.id}) self.env["account.bank.statement.line"].create(ropl) - ebics_rop_file.state = "done" + ebics_rop_file.set_to_done() self.log += f""" <strong><u>Création des lignes ROP<u></strong><br/> @@ -136,19 +139,20 @@ class EbicsStatementRopImport(models.TransientModel): "view_mode": "form", "res_model": "ebics.statement.import.wizard", "view_id": result_view.id, - "context": {"statement_id": bank_statement.id if ebics_mvt_file else None}, + "context": { + "statement_ids": bank_statement_ids.ids if ebics_mvt_file else None + }, "target": "new", "type": "ir.actions.act_window", } - 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 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 _get_rop_lines(self, data): """ diff --git a/wizard/ebics_statement_rop_import_wizard.xml b/wizard/ebics_statement_rop_import_wizard.xml index de86585cb13e4225b82280783c4323802c87d8da..57e4ef50c4d0aea09128c500ea8480c312a47109 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_statement" - string="Voir le relevé" + name="view_statements" + string="Voir les relevés" type="object" class="oe_highlight" - invisible="not context.get('statement_id', False)" + invisible="not context.get('statement_ids', False)" /> <button string="Annuler" class="oe_link" special="cancel" /> </footer>