now is possible delete a temporary lot when this lot have one or more devices

This commit is contained in:
Cayo Puigdefabregas 2022-03-07 10:20:18 +01:00
parent 4fbed3c5ef
commit 9d43299592
2 changed files with 3 additions and 4 deletions

View File

@ -113,7 +113,7 @@ class LotForm(FlaskForm):
return self.id return self.id
def remove(self): def remove(self):
if self.instance and not self.instance.devices: if self.instance and not self.instance.trade:
self.instance.delete() self.instance.delete()
db.session.commit() db.session.commit()
return self.instance return self.instance

View File

@ -211,9 +211,8 @@ class LotDeleteView(View):
def dispatch_request(self, id): def dispatch_request(self, id):
form = LotForm(id=id) form = LotForm(id=id)
if form.instance.devices: if form.instance.trade:
msg = ("Sorry, the lot cannot be deleted because it still " msg = "Sorry, the lot cannot be deleted because have a trade action "
"has associated devices. Only empty lots can be deleted")
messages.error(msg) messages.error(msg)
next_url = url_for('inventory.devices.lotdevicelist', lot_id=id) next_url = url_for('inventory.devices.lotdevicelist', lot_id=id)
return flask.redirect(next_url) return flask.redirect(next_url)