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
1 changed files with 6 additions and 0 deletions

View File

@ -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()