diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py
index 89c8c835..e9430e63 100644
--- a/ereuse_devicehub/inventory/forms.py
+++ b/ereuse_devicehub/inventory/forms.py
@@ -477,6 +477,7 @@ class NewActionForm(FlaskForm):
date = DateField(u'Date', validators=(validators.Optional(),))
severity = SelectField(u'Severity', choices=[(v.name, v.name) for v in Severity])
description = TextAreaField(u'Description')
+ lot = HiddenField()
type = HiddenField()
def validate(self, extra_validators=None):
diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py
index 70dd5e53..83c0a09d 100644
--- a/ereuse_devicehub/inventory/views.py
+++ b/ereuse_devicehub/inventory/views.py
@@ -289,9 +289,14 @@ class NewActionView(View):
def dispatch_request(self):
self.form = self._form()
+
+ next_url = url_for('inventory.devices.devicelist')
+ lot_id = self.form.lot.data
+ if lot_id:
+ next_url = url_for('inventory.devices.lotdevicelist', lot_id=lot_id)
+
if self.form.validate_on_submit():
self.form.save()
- next_url = request.referrer or url_for('inventory.devices.devicelist')
return flask.redirect(next_url)
@@ -300,11 +305,13 @@ class NewAllocateView(NewActionView, DeviceListMix):
_form = AllocateForm
def dispatch_request(self, lot_id=None):
+ self.form = self._form()
+
next_url = url_for('inventory.devices.devicelist')
+ lot_id = self.form.lot.data
if lot_id:
next_url = url_for('inventory.devices.lotdevicelist', lot_id=lot_id)
- self.form = self._form()
if self.form.validate_on_submit():
self.form.save()
return flask.redirect(next_url)
@@ -316,8 +323,6 @@ class NewAllocateView(NewActionView, DeviceListMix):
devices.add_url_rule('/action/add/', view_func=NewActionView.as_view('action_add'))
devices.add_url_rule('/action/allocate/add/', view_func=NewAllocateView.as_view('allocate_add'))
-devices.add_url_rule('/lot/