From b72f9f37c6036305526da506f632c1c1281ba0bd Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 18 Feb 2022 11:29:12 +0100 Subject: [PATCH] add trade action iun devices when this device is insert in a lot with a trade --- ereuse_devicehub/inventory/forms.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 5e9a3cd8..68a2573c 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -55,6 +55,12 @@ class LotDeviceForm(FlaskForm): return bool(self._devices) def save(self): + trade = self._lot.trade + if trade: + for dev in self._devices: + if not trade in dev.actions: + trade.devices.add(dev) + self._lot.devices.update(self._devices) db.session.add(self._lot) db.session.commit()