Skip to content

Commit

Permalink
[FIX] account_background_post: Add validation to bypass the validate_…
Browse files Browse the repository at this point in the history
…move method when running a test and run the original method of odoo
  • Loading branch information
rov-adhoc committed Sep 9, 2024
1 parent af43b31 commit 97a2a09
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions account_background_post/wizards/validate_account_move.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import _, api, fields, models
from odoo import _, api, fields, models, tools
from odoo.exceptions import UserError
import logging

Expand Down Expand Up @@ -45,7 +45,7 @@ def action_background_post(self):
self.env.ref('account_background_post.ir_cron_background_post_invoices')._trigger()

def validate_move(self):
""" Sobre escribimos este metodo por completo para hacer:
""" Sobre escribimos este metodo si no se trata de un test por completo para hacer:
1. Que en lugar de hacer un _post hacemos un _action_post. esto porque odoo hace cosas como lanzar acciones y correr validaciones solo cuando corremos el action_post. y nosotros queremos que esas se apliquen. eso incluye el envio de email cuando validamos la factura.
Expand All @@ -55,6 +55,8 @@ def validate_move(self):
3. Limitamos sui el usuario quiere validar mas facturas que el batch size definido directamente
le pedimos que las valide en background. """

if tools.config['test_enable']:
return super().validate_move()
if self.count_inv > self.batch_size:
raise UserError(_('You can only validate on batches of size < %s invoices. If you need to validate'
' more invoices please use the validate on background option', self.batch_size))
Expand Down

0 comments on commit 97a2a09

Please sign in to comment.