From 1c57e407535de080bba149363df7473757bac278 Mon Sep 17 00:00:00 2001 From: Carlos G?lvez Date: Sun, 24 Nov 2019 21:37:55 +0100 Subject: [PATCH] Catch errors of UserError class and append it to the errors log. --- shipment.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shipment.py b/shipment.py index a0ca5b9..a297920 100644 --- a/shipment.py +++ b/shipment.py @@ -12,6 +12,7 @@ from trytond.modules.edocument_unedifact.edocument import (Message, Serializer) from trytond.modules.edocument_unedifact.edocument import (with_segment_check, separate_section, RewindIterator, DO_NOTHING, NO_ERRORS) from datetime import datetime +from trytond.exceptions import UserError __all__ = ['Move', 'StockConfiguration', 'ShipmentIn', 'Cron'] @@ -206,7 +207,12 @@ class ShipmentIn(EdifactMixin, metaclass=PoolMeta): to_save.append(move) if to_save: - Move.save(to_save) + try: + Move.save(to_save) + except UserError as e: + total_errors.append(e.message) + return None, total_errors + return shipment, total_errors @classmethod