Refactor inventory batch "add row" page, per new theme
This commit is contained in:
parent
2c7f2c0fcd
commit
4746b6fae9
4 changed files with 369 additions and 92 deletions
|
@ -705,9 +705,15 @@ class BatchMasterView(MasterView):
|
|||
if self.rows_creatable and not batch.executed and not batch.complete:
|
||||
permission_prefix = self.get_permission_prefix()
|
||||
if self.request.has_perm('{}.create_row'.format(permission_prefix)):
|
||||
link = tags.link_to("Create a new {}".format(self.get_row_model_title()),
|
||||
self.get_action_url('create_row', batch))
|
||||
return HTML.tag('p', c=[link])
|
||||
url = self.get_action_url('create_row', batch)
|
||||
if self.get_use_buefy():
|
||||
return self.make_buefy_button("New Row", url=url,
|
||||
is_primary=True,
|
||||
icon_left='plus')
|
||||
else:
|
||||
text = "Create a new {}".format(self.get_row_model_title())
|
||||
link = tags.link_to(text, url)
|
||||
return HTML.tag('p', c=[link])
|
||||
|
||||
def make_batch_row_grid_tools(self, batch):
|
||||
if self.get_use_buefy():
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2021 Lance Edgar
|
||||
# Copyright © 2010-2023 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -234,40 +234,47 @@ class InventoryBatchView(BatchMasterView):
|
|||
if batch.executed:
|
||||
return self.redirect(self.get_action_url('view', batch))
|
||||
|
||||
use_buefy = self.get_use_buefy()
|
||||
schema = DesktopForm().bind(session=self.Session())
|
||||
form = forms.Form(schema=schema, request=self.request)
|
||||
if form.validate(newstyle=True):
|
||||
form = forms.Form(schema=schema, request=self.request, use_buefy=use_buefy)
|
||||
if self.request.method == 'POST':
|
||||
if form.validate(newstyle=True):
|
||||
|
||||
product = self.Session.query(model.Product).get(form.validated['product'])
|
||||
product = self.Session.query(model.Product).get(form.validated['product'])
|
||||
|
||||
row = None
|
||||
if self.should_aggregate_products(batch):
|
||||
row = self.find_row_for_product(batch, product)
|
||||
if row:
|
||||
row = None
|
||||
if self.should_aggregate_products(batch):
|
||||
row = self.find_row_for_product(batch, product)
|
||||
if row:
|
||||
row.cases = form.validated['cases']
|
||||
row.units = form.validated['units']
|
||||
self.handler.refresh_row(row)
|
||||
|
||||
if not row:
|
||||
row = model.InventoryBatchRow()
|
||||
row.product = product
|
||||
row.upc = form.validated['upc']
|
||||
row.brand_name = form.validated['brand_name']
|
||||
row.description = form.validated['description']
|
||||
row.size = form.validated['size']
|
||||
row.case_quantity = form.validated['case_quantity']
|
||||
row.cases = form.validated['cases']
|
||||
row.units = form.validated['units']
|
||||
self.handler.refresh_row(row)
|
||||
self.handler.capture_current_units(row)
|
||||
self.handler.add_row(batch, row)
|
||||
|
||||
if not row:
|
||||
row = model.InventoryBatchRow()
|
||||
row.product = product
|
||||
row.upc = form.validated['upc']
|
||||
row.brand_name = form.validated['brand_name']
|
||||
row.description = form.validated['description']
|
||||
row.size = form.validated['size']
|
||||
row.case_quantity = form.validated['case_quantity']
|
||||
row.cases = form.validated['cases']
|
||||
row.units = form.validated['units']
|
||||
self.handler.capture_current_units(row)
|
||||
self.handler.add_row(batch, row)
|
||||
description = make_full_description(form.validated['brand_name'],
|
||||
form.validated['description'],
|
||||
form.validated['size'])
|
||||
self.request.session.flash("{} cases, {} units: {} {}".format(
|
||||
form.validated['cases'] or 0, form.validated['units'] or 0,
|
||||
form.validated['upc'].pretty(), description))
|
||||
return self.redirect(self.request.current_route_url())
|
||||
|
||||
description = make_full_description(form.validated['brand_name'],
|
||||
form.validated['description'],
|
||||
form.validated['size'])
|
||||
self.request.session.flash("{} cases, {} units: {} {}".format(
|
||||
form.validated['cases'] or 0, form.validated['units'] or 0,
|
||||
form.validated['upc'].pretty(), description))
|
||||
return self.redirect(self.request.current_route_url())
|
||||
else:
|
||||
dform = form.make_deform_form()
|
||||
msg = "Form did not validate: {}".format(six.text_type(dform.error))
|
||||
self.request.session.flash(msg, 'error')
|
||||
|
||||
title = self.get_instance_title(batch)
|
||||
return self.render_to_response('desktop_form', {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue