add trade action iun devices when this device is insert in a lot with a trade

This commit is contained in:
Cayo Puigdefabregas 2022-02-18 11:29:12 +01:00
parent a2b074e707
commit b72f9f37c6

View file

@ -55,6 +55,12 @@ class LotDeviceForm(FlaskForm):
return bool(self._devices) return bool(self._devices)
def save(self): 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) self._lot.devices.update(self._devices)
db.session.add(self._lot) db.session.add(self._lot)
db.session.commit() db.session.commit()