From 1a7c2f3a0132cfb1a16bedd4e7e778c8a6e87a05 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 19 Apr 2023 16:17:29 +0200 Subject: [PATCH] fix required in form --- ereuse_devicehub/inventory/forms.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 9995ace9..ff083908 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -1293,7 +1293,9 @@ class TradeDocumentForm(FlaskForm): ).one() kwargs['obj'] = self._obj - if self._obj: + if not self.file_name.args: + self.file_name.args = ("File", [validators.DataRequired()]) + if doc_id: self.file_name.args = () super().__init__(*args, **kwargs) @@ -1399,7 +1401,9 @@ class DeviceDocumentForm(FlaskForm): ).one() kwargs['obj'] = self._obj - if self._obj: + if not self.file_name.args: + self.file_name.args = ("File", [validators.DataRequired()]) + if doc_id: self.file_name.args = () super().__init__(*args, **kwargs)