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

[FIX] get working wizard

parent dcd30901
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
from . import models
from . import wizard from . import wizard
...@@ -9,5 +9,8 @@ class EbicsFile(models.Model): ...@@ -9,5 +9,8 @@ class EbicsFile(models.Model):
def _split_cfonb(self, res): def _split_cfonb(self, res):
# Avoid splitting cfonb in one statement per day # Avoid splitting cfonb in one statement per day
datas = [] datas = []
datas.append({"data": base64.b64encode(self.data)}) datas.append({
"company_id": self.env.company.id,
"data": self.data
})
return datas return datas
...@@ -58,15 +58,16 @@ class EbicsStatementRopImport(models.TransientModel): ...@@ -58,15 +58,16 @@ class EbicsStatementRopImport(models.TransientModel):
_logger.debug("Creating statements for retrieved enriched moves") _logger.debug("Creating statements for retrieved enriched moves")
ebics_mvt_file.with_context(active_model="ebics.file").process() ebics_mvt_file.with_context(active_model="ebics.file").process()
bank_statement_ids = ebics_mvt_file.bank_statement_ids bank_statement = ebics_mvt_file.bank_statement_ids
_logger.debug(f"Created statements : {bank_statement_ids.mapped('date')}") bank_statement.ensure_one()
_logger.debug(f"Created statement : {bank_statement.date}")
self.log += f""" self.log += f"""
<strong><u>Import des mouvements enrichis<u></strong><br/> <strong><u>Import des mouvements enrichis<u></strong><br/>
- Journal : {bank_statement_ids[0].journal_id.name} Référence : {bank_statement.name}
- Du : {bank_statement_ids[0].date} - Journal : {bank_statement.journal_id.name}
au : {bank_statement_ids[-1].date} <br/> - Date : {bank_statement.date} <br/>
Solde Initial : {bank_statement_ids[0].balance_start} €<br/> Solde Initial : {bank_statement.balance_start} €<br/>
Solde Final : {bank_statement_ids[-1].balance_end} Solde Final : {bank_statement.balance_end}
<hr/> <hr/>
""" """
else: else:
...@@ -98,17 +99,17 @@ class EbicsStatementRopImport(models.TransientModel): ...@@ -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_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_ids: if ebics_rop_file and bank_statement:
_logger.debug(f"Processing ROP file {ebics_rop_file.name}") _logger.debug(f"Processing ROP file {ebics_rop_file.name}")
# 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
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 lambda line: "CORPORATE CARD" in line.payment_ref
) )
line_nb = len(lines_to_delete) line_nb = len(lines_to_delete)
_logger.debug(f"Deleting {line_nb} statement lines : {lines_to_delete.ids}") _logger.debug(f"Deleting {line_nb} statement lines : {lines_to_delete.ids}")
lines_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.
...@@ -120,11 +121,10 @@ class EbicsStatementRopImport(models.TransientModel): ...@@ -120,11 +121,10 @@ class EbicsStatementRopImport(models.TransientModel):
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:
_logger.debug(f"Adding {ropl['payment_ref']} - {ropl['date']}") _logger.debug(f"Adding {ropl['payment_ref']} - {ropl['date']}")
_logger.debug( ropl.update({
f"List of statement_ids : {bank_statement_ids.mapped('date')}" "statement_id": bank_statement.id,
) "journal_id": ebics_conf_id.journal_ids[0].id
})
ropl.update({"statement_id": bank_statement_ids[0].id})
self.env["account.bank.statement.line"].create(ropl) self.env["account.bank.statement.line"].create(ropl)
ebics_rop_file.set_to_done() ebics_rop_file.set_to_done()
...@@ -156,19 +156,20 @@ class EbicsStatementRopImport(models.TransientModel): ...@@ -156,19 +156,20 @@ class EbicsStatementRopImport(models.TransientModel):
"res_model": "ebics.statement.import.wizard", "res_model": "ebics.statement.import.wizard",
"view_id": result_view.id, "view_id": result_view.id,
"context": { "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", "target": "new",
"type": "ir.actions.act_window", "type": "ir.actions.act_window",
} }
def view_statements(self): def view_statement(self):
action = self.env["ir.actions.act_window"]._for_xml_id( statement_id = self.env.context.get("statement_id")
"account.action_bank_statement_tree" return {
) "res_id": statement_id,
domain = [("id", "in", self.env.context.get("statement_ids"))] "view_mode": form,
action["domain"] = domain "res_model": "account.bank.statement",
return action "type": "ir.actions.act_window",
}
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_statements" name="view_statement"
string="Voir les relevés" string="Voir le relevé"
type="object" type="object"
class="oe_highlight" 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" /> <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