Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion account_statement_import_sheet_file_bg/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Account statement import sheet file BG",
"version": "18.0.1.0.1",
"version": "18.0.1.0.2",
"category": "Productivity/Documents",
"summary": "Integration between Documents and Base BG modules",
"depends": [
Expand All @@ -9,6 +9,7 @@
],
"data": [
"data/ir_config_parameter_data.xml",
"views/bg_job_views.xml",
],
"demo": [],
"installable": True,
Expand Down
1 change: 1 addition & 0 deletions account_statement_import_sheet_file_bg/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import account_statement_import
from . import bg_job
40 changes: 40 additions & 0 deletions account_statement_import_sheet_file_bg/models/bg_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2020 CorporateHub (https://corporatehub.eu)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, models
from odoo.exceptions import UserError


class BgJob(models.Model):
_inherit = "bg.job"

def action_retry_batch(self):
"""
Action to retry multiple failed jobs at once
"""
failed_jobs = self.filtered(lambda j: j.state == "failed")
if not failed_jobs:
raise UserError(_("Please select only failed jobs to retry"))
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La validación funciona correctamente, pero el mensaje de error en la línea 17 podría ser más específico. Cuando no hay trabajos fallidos seleccionados, el mensaje actual "Please select only failed jobs to retry" podría interpretarse de múltiples formas.

Sugerencia: Hacer el mensaje más explícito:

  • Si no hay trabajos fallidos: "No failed jobs selected. Please select at least one failed job to retry"
  • O simplificar la lógica validando directamente que todos los trabajos estén fallidos, en cuyo caso un solo mensaje sería suficiente
Suggested change
raise UserError(_("Please select only failed jobs to retry"))
raise UserError(_("No failed jobs selected. Please select at least one failed job to retry"))

Copilot uses AI. Check for mistakes.

other_jobs = self - failed_jobs
if other_jobs:
raise UserError(_("Some selected jobs are not in failed state and cannot be retried"))

failed_jobs.write(
{
"state": "enqueued",
"retry_count": 0,
"error_message": False,
}
)

return {
"type": "ir.actions.client",
"tag": "display_notification",
"params": {
"title": _("Jobs Requeued"),
"type": "success",
"message": _("%s job(s) have been requeued for retry") % len(failed_jobs),
"sticky": False,
},
}
Comment on lines +11 to +40
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El método action_retry_batch no tiene cobertura de tests. Dado que el módulo base base_bg cuenta con tests automatizados (incluyendo tests para action_retry), sería recomendable agregar tests para este nuevo método que verifiquen:

  • El comportamiento con múltiples trabajos fallidos
  • El manejo de errores cuando se seleccionan trabajos en estados diferentes a "failed"
  • La actualización correcta de los campos state, retry_count y error_message
  • El retorno correcto de la notificación de éxito

Copilot uses AI. Check for mistakes.
60 changes: 60 additions & 0 deletions account_statement_import_sheet_file_bg/views/bg_job_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<!-- Inherit List View to add retry button -->
<record id="view_bg_job_list_inherit" model="ir.ui.view">
<field name="name">bg.job.list.inherit</field>
<field name="model">bg.job</field>
<field name="inherit_id" ref="base_bg.view_bg_job_list"/>
<field name="arch" type="xml">
<xpath expr="//list" position="inside">
<header>
<button name="action_retry_batch" string="Retry Selected" type="object" class="btn-primary"/>
</header>
</xpath>
</field>
</record>

<!-- Inherit Search View to add "Statement Import" filter -->
<record id="view_bg_job_search_inherit" model="ir.ui.view">
<field name="name">bg.job.search.inherit</field>
<field name="model">bg.job</field>
<field name="inherit_id" ref="base_bg.view_bg_job_search"/>
<field name="arch" type="xml">
<filter name="failed" position="after">
<separator/>
<filter string="Statement Import Jobs" name="statement_import"
domain="[('model', '=', 'account.statement.import')]"/>
<filter string="Failed Statement Imports" name="failed_statement_import"
domain="[('model', '=', 'account.statement.import'), ('state', '=', 'failed')]"/>
</filter>
</field>
</record>

<!-- Action for Failed Statement Import Jobs -->
<record id="action_failed_statement_import_jobs" model="ir.actions.act_window">
<field name="name">Failed Statement Import Jobs</field>
<field name="res_model">bg.job</field>
<field name="view_mode">list,form</field>
<field name="domain">[('model', '=', 'account.statement.import'), ('state', '=', 'failed')]</field>
<field name="context">{'search_default_failed_statement_import': 1}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
No failed statement import jobs!
</p>
<p>
When a bank statement import job fails during background processing,
it will appear here. You can select failed jobs and use the
"Retry Selected" button to requeue them for processing.
</p>
</field>
</record>

<!-- Menu Item for Failed Statement Import Jobs -->
<menuitem id="menu_failed_statement_import_jobs"
name="Failed Statement Imports"
parent="base_bg.menu_bg_job_root"
action="action_failed_statement_import_jobs"
sequence="20"/>

</odoo>