diff --git a/models/product.py b/models/product.py index c3b0652f59e78adb3848ffbb2408fc14f1079a73..877dd11172a19df9255fe7f4ceee0e96ad7c2588 100644 --- a/models/product.py +++ b/models/product.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from odoo import api, models, exceptions +from odoo import _, api, models, exceptions import logging _logger = logging.getLogger(__name__) @@ -14,18 +14,16 @@ class Product(models.Model): @api.constrains('barcode') def const_barcode(self): for rec in self: - if len(rec.barcode) > 13: + if rec.barcode and len(rec.barcode) > 13: raise exceptions.UserError( - "El codigo de barras supera los 13 " - "caracteres requeridos por afip" + _("The barcode exceeds the 13 characters required by afip") ) @api.multi @api.constrains('default_code') def const_default_code(self): for rec in self: - if len(rec.barcode) > 50: + if rec.default_code and len(rec.default_code) > 50: raise exceptions.UserError( - "Referencia interna supera los 50 " - "caracteres requeridos por afip", + _("The internal reference exceeds the 50 characters required by afip") ) diff --git a/models/ws_caea_configuration.py b/models/ws_caea_configuration.py index 66edff0333e0e85036501d19c33121274ecc97f7..64e1f753ae4cc994c46c00f0f50ab88a434beaa6 100644 --- a/models/ws_caea_configuration.py +++ b/models/ws_caea_configuration.py @@ -134,7 +134,10 @@ class WsCaeaConfiguration(models.Model): if no_cache: client = Client(self.url, cache=NoCache()) - ws = MTXCAEasywsy(self, url=self.url, client=client) + try: + ws = MTXCAEasywsy(self, url=self.url, client=client) + except Exception as e: + raise exceptions.ValidationError(str(e)) return ws def get_errors(self, error):