now is possible delete a temporary lot when this lot have one or more devices
This commit is contained in:
parent
4fbed3c5ef
commit
9d43299592
|
@ -113,7 +113,7 @@ class LotForm(FlaskForm):
|
|||
return self.id
|
||||
|
||||
def remove(self):
|
||||
if self.instance and not self.instance.devices:
|
||||
if self.instance and not self.instance.trade:
|
||||
self.instance.delete()
|
||||
db.session.commit()
|
||||
return self.instance
|
||||
|
|
|
@ -211,9 +211,8 @@ class LotDeleteView(View):
|
|||
|
||||
def dispatch_request(self, id):
|
||||
form = LotForm(id=id)
|
||||
if form.instance.devices:
|
||||
msg = ("Sorry, the lot cannot be deleted because it still "
|
||||
"has associated devices. Only empty lots can be deleted")
|
||||
if form.instance.trade:
|
||||
msg = "Sorry, the lot cannot be deleted because have a trade action "
|
||||
messages.error(msg)
|
||||
next_url = url_for('inventory.devices.lotdevicelist', lot_id=id)
|
||||
return flask.redirect(next_url)
|
||||
|
|
Reference in New Issue