Skip to content
Extraits de code Groupes Projets
Valider db449a65 rédigé par Rémi - Le Filament's avatar Rémi - Le Filament
Parcourir les fichiers

[FIX] multi statement creation

parent ac899779
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -52,15 +52,15 @@ class EbicsStatementRopImport(models.TransientModel): ...@@ -52,15 +52,15 @@ class EbicsStatementRopImport(models.TransientModel):
if ebics_mvt_file: if ebics_mvt_file:
# Process EBICS MVT (= create bank statement) # Process EBICS MVT (= create bank statement)
ebics_mvt_file.process() ebics_mvt_file.process()
bank_statement = ebics_mvt_file.bank_statement_ids bank_statement_ids = ebics_mvt_file.bank_statement_ids
bank_statement.ensure_one()
self.log += f""" self.log += f"""
<strong><u>Import des mouvements enrichis<u></strong><br/> <strong><u>Import des mouvements enrichis<u></strong><br/>
Référence : {bank_statement.name} {ebics_mvt_file.note_process}
- Journal : {bank_statement.journal_id.name} - Journal : {bank_statement_ids[0].journal_id.name}
- Date : {bank_statement.date} <br/> - Du : {bank_statement_ids[0].date}
Solde Initial : {bank_statement.balance_start} €<br/> au : {bank_statement_ids[-1].date} <br/>
Solde Final : {bank_statement.balance_end} Solde Initial : {bank_statement_ids[0].balance_start} €<br/>
Solde Final : {bank_statement_ids[-1].balance_end}
<hr/> <hr/>
""" """
else: else:
...@@ -90,15 +90,15 @@ class EbicsStatementRopImport(models.TransientModel): ...@@ -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_id = ebics_rop_wizard_act.get("context").get("ebics_file_ids")
ebics_rop_file = self.env["ebics.file"].browse(ebics_rop_file_id) 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 # Process EBICS ROP file
ebics_rop_file.ensure_one() ebics_rop_file.ensure_one()
# Suppression de lignes CORPORATE # 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 lambda line: "CORPORATE CARD" in line.name
) )
line_nb = len(line_to_delete) line_nb = len(lines_to_delete)
line_to_delete.unlink() lines_to_delete.unlink()
self.log += f""" self.log += f"""
<strong><u>Suppression de lignes CORPORATE<u></strong><br/> <strong><u>Suppression de lignes CORPORATE<u></strong><br/>
Suppression de {line_nb} lignes. Suppression de {line_nb} lignes.
...@@ -108,9 +108,12 @@ class EbicsStatementRopImport(models.TransientModel): ...@@ -108,9 +108,12 @@ class EbicsStatementRopImport(models.TransientModel):
# Ajout des lignes ROP # Ajout des lignes ROP
rop_lines = self._get_rop_lines(ebics_rop_file.data) rop_lines = self._get_rop_lines(ebics_rop_file.data)
for ropl in rop_lines: 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) self.env["account.bank.statement.line"].create(ropl)
ebics_rop_file.state = "done" ebics_rop_file.set_to_done()
self.log += f""" self.log += f"""
<strong><u>Création des lignes ROP<u></strong><br/> <strong><u>Création des lignes ROP<u></strong><br/>
...@@ -136,19 +139,20 @@ class EbicsStatementRopImport(models.TransientModel): ...@@ -136,19 +139,20 @@ class EbicsStatementRopImport(models.TransientModel):
"view_mode": "form", "view_mode": "form",
"res_model": "ebics.statement.import.wizard", "res_model": "ebics.statement.import.wizard",
"view_id": result_view.id, "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", "target": "new",
"type": "ir.actions.act_window", "type": "ir.actions.act_window",
} }
def view_statement(self): def view_statements(self):
statement_id = self.env.context.get("statement_id") action = self.env["ir.actions.act_window"]._for_xml_id(
return { "account.action_bank_statement_tree"
"res_id": statement_id, )
"view_mode": "form", domain = [("id", "in", self.env.context.get("statement_ids"))]
"res_model": "account.bank.statement", action["domain"] = domain
"type": "ir.actions.act_window", return action
}
def _get_rop_lines(self, data): def _get_rop_lines(self, data):
""" """
......
...@@ -50,11 +50,11 @@ ...@@ -50,11 +50,11 @@
<field name="log" colspan="4" nolabel="1" widget="html" readonly="1" /> <field name="log" colspan="4" nolabel="1" widget="html" readonly="1" />
<footer> <footer>
<button <button
name="view_statement" name="view_statements"
string="Voir le relevé" string="Voir les relevés"
type="object" type="object"
class="oe_highlight" 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" /> <button string="Annuler" class="oe_link" special="cancel" />
</footer> </footer>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter