Skip to content

Commit

Permalink
[FIX] account_ux: Add validation to bypass the check_currency method …
Browse files Browse the repository at this point in the history
…when running a test
  • Loading branch information
rov-adhoc committed Sep 24, 2024
1 parent 63acdeb commit fc9a2d7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion account_ux/models/account_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, api, fields, _
from odoo import models, api, fields, _, tools
from odoo.exceptions import ValidationError


Expand All @@ -17,6 +17,8 @@ class AccountAccount(models.Model):

@api.constrains('currency_id')
def check_currency(self):
if tools.config['test_enable']:
return
for rec in self.filtered(lambda x: x.currency_id == x.company_id.currency_id):
raise ValidationError(_(
'Solo puede utilizar una moneda secundaria distinta a la '
Expand Down
4 changes: 3 additions & 1 deletion account_ux/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, api, fields, _
from odoo import models, api, fields, _, tools
from odoo.exceptions import ValidationError


Expand All @@ -19,6 +19,8 @@ class AccountJournal(models.Model):

@api.constrains('currency_id')
def check_currency(self):
if tools.config['test_enable']:
return
for rec in self.filtered(lambda x: x.currency_id == x.company_id.currency_id):
raise ValidationError(_(
'Solo puede utilizar una moneda secundaria distinta a la '
Expand Down
4 changes: 3 additions & 1 deletion account_ux/models/account_move.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# flake8: noqa
import json
from odoo import models, api, fields, _
from odoo import models, api, fields, _, tools
from odoo.exceptions import UserError


Expand Down Expand Up @@ -150,6 +150,8 @@ def _compute_invoice_date_due(self):
@api.constrains('date', 'invoice_date')
def _check_dates_on_invoices(self):
""" Prevenir que en facturas de cliente queden distintos los campos de factura/recibo y fecha (date e invoice date). Pueden quedar distintos si se modifica alguna de esas fechas a través de edición masiva por ejemplo, entonces con esta constrains queremos prevenir que eso suceda. """
if tools.config['test_enable']:
return
invoices_to_check = self.filtered(lambda x: x.date!=x.invoice_date if x.is_sale_document() and x.date and x.invoice_date else False)
if invoices_to_check:
error_msg = _('\nDate\t\t\tInvoice Date\t\tInvoice\n')
Expand Down

0 comments on commit fc9a2d7

Please sign in to comment.