Remove the "add vs. subtract" mode for desktop inventory workflow form
hopefully we can always assume the "mode" based on other things
This commit is contained in:
parent
802f4bfd6b
commit
6ec0ddb94e
|
@ -130,25 +130,11 @@
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#add').click(function() {
|
|
||||||
if (! assert_quantity()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$(this).button('disable').button('option', 'label', "Working...");
|
|
||||||
$('#mode').val('add');
|
|
||||||
$('#inventory-form').submit();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#subtract').click(function() {
|
|
||||||
if (! assert_quantity()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$(this).button('disable').button('option', 'label', "Working...");
|
|
||||||
$('#mode').val('subtract');
|
|
||||||
$('#inventory-form').submit();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#inventory-form').submit(function() {
|
$('#inventory-form').submit(function() {
|
||||||
|
if (! assert_quantity()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
disable_submit_button(this);
|
||||||
$(this).mask("Working...");
|
$(this).mask("Working...");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -200,7 +186,6 @@
|
||||||
<div class="form-wrapper">
|
<div class="form-wrapper">
|
||||||
${h.form(form.action_url, id='inventory-form')}
|
${h.form(form.action_url, id='inventory-form')}
|
||||||
${h.csrf_token(request)}
|
${h.csrf_token(request)}
|
||||||
${h.hidden('mode')}
|
|
||||||
|
|
||||||
<div class="field-wrapper">
|
<div class="field-wrapper">
|
||||||
<label for="upc">Product UPC</label>
|
<label for="upc">Product UPC</label>
|
||||||
|
@ -250,8 +235,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<button type="button" id="add">Add</button>
|
${h.submit('submit', "Submit")}
|
||||||
<button type="button" id="subtract">Subtract</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
${h.end_form()}
|
${h.end_form()}
|
||||||
|
|
|
@ -282,7 +282,6 @@ class InventoryBatchView(BatchMasterView):
|
||||||
form = forms.Form(schema=DesktopForm(), request=self.request)
|
form = forms.Form(schema=DesktopForm(), request=self.request)
|
||||||
if form.validate(newstyle=True):
|
if form.validate(newstyle=True):
|
||||||
|
|
||||||
mode = form.validated['mode']
|
|
||||||
product = self.Session.merge(form.validated['product'])
|
product = self.Session.merge(form.validated['product'])
|
||||||
row = model.InventoryBatchRow()
|
row = model.InventoryBatchRow()
|
||||||
row.product = product
|
row.product = product
|
||||||
|
@ -291,23 +290,14 @@ class InventoryBatchView(BatchMasterView):
|
||||||
row.description = form.validated['description']
|
row.description = form.validated['description']
|
||||||
row.size = form.validated['size']
|
row.size = form.validated['size']
|
||||||
row.case_quantity = form.validated['case_quantity']
|
row.case_quantity = form.validated['case_quantity']
|
||||||
|
row.cases = form.validated['cases']
|
||||||
cases = form.validated['cases']
|
row.units = form.validated['units']
|
||||||
units = form.validated['units']
|
|
||||||
if mode == 'add':
|
|
||||||
row.cases = cases
|
|
||||||
row.units = units
|
|
||||||
else:
|
|
||||||
assert mode == 'subtract'
|
|
||||||
row.cases = (0 - cases) if cases else None
|
|
||||||
row.units = (0 - units) if units else None
|
|
||||||
|
|
||||||
self.handler.add_row(batch, row)
|
self.handler.add_row(batch, row)
|
||||||
description = make_full_description(form.validated['brand_name'],
|
description = make_full_description(form.validated['brand_name'],
|
||||||
form.validated['description'],
|
form.validated['description'],
|
||||||
form.validated['size'])
|
form.validated['size'])
|
||||||
self.request.session.flash("({}) {} cases, {} units: {} {}".format(
|
self.request.session.flash("{} cases, {} units: {} {}".format(
|
||||||
form.validated['mode'], form.validated['cases'] or 0, form.validated['units'] or 0,
|
form.validated['cases'] or 0, form.validated['units'] or 0,
|
||||||
form.validated['upc'].pretty(), description))
|
form.validated['upc'].pretty(), description))
|
||||||
return self.redirect(self.request.current_route_url())
|
return self.redirect(self.request.current_route_url())
|
||||||
|
|
||||||
|
@ -610,10 +600,6 @@ class InventoryForm(colander.MappingSchema):
|
||||||
|
|
||||||
class DesktopForm(colander.Schema):
|
class DesktopForm(colander.Schema):
|
||||||
|
|
||||||
mode = colander.SchemaNode(colander.String(),
|
|
||||||
validator=colander.OneOf(['add',
|
|
||||||
'subtract']))
|
|
||||||
|
|
||||||
product = colander.SchemaNode(forms.types.ProductType())
|
product = colander.SchemaNode(forms.types.ProductType())
|
||||||
|
|
||||||
upc = colander.SchemaNode(forms.types.GPCType())
|
upc = colander.SchemaNode(forms.types.GPCType())
|
||||||
|
|
Loading…
Reference in a new issue