Make "view row" prettier for receiving batch, for buefy themes
this seems like a good direction; should make "receive product" and "declare item" use b-modal on same page probably
This commit is contained in:
parent
be92075abb
commit
e906c01e64
|
@ -286,17 +286,15 @@
|
|||
<%def name="object_helpers()">
|
||||
${parent.object_helpers()}
|
||||
% if master.has_perm('auto_receive') and master.can_auto_receive(batch):
|
||||
|
||||
<div class="object-helper">
|
||||
<h3>Tools</h3>
|
||||
<div class="object-helper-content">
|
||||
% if use_buefy:
|
||||
${h.form(url('{}.auto_receive'.format(route_prefix), uuid=batch.uuid), ref='auto_receive_all_form')}
|
||||
${h.csrf_token(request)}
|
||||
<once-button type="is-primary"
|
||||
@click="$refs.auto_receive_all_form.submit()"
|
||||
text="Auto-Receive All Items">
|
||||
</once-button>
|
||||
${h.end_form()}
|
||||
<b-button type="is-primary"
|
||||
@click="autoReceiveShowDialog = true">
|
||||
Auto-Receive All Items
|
||||
</b-button>
|
||||
% else:
|
||||
${h.form(url('{}.auto_receive'.format(route_prefix), uuid=batch.uuid), class_='autodisable')}
|
||||
${h.csrf_token(request)}
|
||||
|
@ -305,9 +303,58 @@
|
|||
% endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
% if use_buefy:
|
||||
<b-modal has-modal-card
|
||||
:active.sync="autoReceiveShowDialog">
|
||||
<div class="modal-card">
|
||||
|
||||
<header class="modal-card-head">
|
||||
<p class="modal-card-title">Auto-Receive All Items</p>
|
||||
</header>
|
||||
|
||||
<section class="modal-card-body">
|
||||
<p class="block">
|
||||
You can automatically mark all items as having been
|
||||
received normally.
|
||||
</p>
|
||||
<p class="block">
|
||||
Would you like to do so?
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<footer class="modal-card-foot">
|
||||
<b-button @click="autoReceiveShowDialog = false">
|
||||
Cancel
|
||||
</b-button>
|
||||
${h.form(url('{}.auto_receive'.format(route_prefix), uuid=batch.uuid))}
|
||||
${h.csrf_token(request)}
|
||||
<b-button type="is-primary"
|
||||
native-type="submit"
|
||||
:disabled="autoReceiveSubmitting"
|
||||
@click="autoReceiveSubmitting = true"
|
||||
icon-pack="fas"
|
||||
icon-left="arrow-circle-right">
|
||||
{{ autoReceiveSubmitting ? "Working, please wait..." : "Auto-Receive All Items" }}
|
||||
</b-button>
|
||||
${h.end_form()}
|
||||
</footer>
|
||||
</div>
|
||||
</b-modal>
|
||||
% endif
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
<%def name="modify_this_page_vars()">
|
||||
${parent.modify_this_page_vars()}
|
||||
<script type="text/javascript">
|
||||
|
||||
ThisPageData.autoReceiveShowDialog = false
|
||||
ThisPageData.autoReceiveSubmitting = false
|
||||
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
|
||||
${parent.body()}
|
||||
|
||||
|
|
|
@ -1,14 +1,77 @@
|
|||
## -*- coding: utf-8; -*-
|
||||
<%inherit file="/master/view_row.mako" />
|
||||
|
||||
<%def name="extra_styles()">
|
||||
${parent.extra_styles()}
|
||||
<style type="text/css">
|
||||
% if use_buefy:
|
||||
nav.panel {
|
||||
margin: 0.5rem;
|
||||
}
|
||||
% endif
|
||||
</style>
|
||||
</%def>
|
||||
|
||||
<%def name="object_helpers()">
|
||||
${parent.object_helpers()}
|
||||
% if not batch.executed and not batch.is_truck_dump_child():
|
||||
% if not use_buefy and master.row_editable(row) and not batch.is_truck_dump_child():
|
||||
<div class="object-helper">
|
||||
<h3>Receiving Tools</h3>
|
||||
<div class="object-helper-content">
|
||||
<div style="white-space: nowrap;">
|
||||
% if use_buefy:
|
||||
${h.link_to("Receive Product", url('{}.receive_row'.format(route_prefix), uuid=batch.uuid, row_uuid=row.uuid), class_='button autodisable')}
|
||||
${h.link_to("Declare Credit", url('{}.declare_credit'.format(route_prefix), uuid=batch.uuid, row_uuid=row.uuid), class_='button autodisable')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
<%def name="page_content()">
|
||||
% if use_buefy:
|
||||
|
||||
<b-field grouped>
|
||||
${form.render_field_readonly('sequence')}
|
||||
${form.render_field_readonly('status_code')}
|
||||
</b-field>
|
||||
|
||||
<div style="display: flex;">
|
||||
|
||||
<nav class="panel">
|
||||
<p class="panel-heading">Product</p>
|
||||
<div class="panel-block">
|
||||
<div style="display: flex;">
|
||||
<div>
|
||||
% if not row.product:
|
||||
${form.render_field_readonly('item_entry')}
|
||||
% endif
|
||||
${form.render_field_readonly('upc')}
|
||||
${form.render_field_readonly('vendor_code')}
|
||||
${form.render_field_readonly('product')}
|
||||
${form.render_field_readonly('case_quantity')}
|
||||
${form.render_field_readonly('catalog_unit_cost')}
|
||||
</div>
|
||||
% if image_url:
|
||||
<div class="is-pulled-right">
|
||||
${h.image(image_url, "Product Image")}
|
||||
</div>
|
||||
% endif
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<nav class="panel">
|
||||
<p class="panel-heading">Quantities</p>
|
||||
<div class="panel-block">
|
||||
<div>
|
||||
${form.render_field_readonly('ordered')}
|
||||
${form.render_field_readonly('shipped')}
|
||||
${form.render_field_readonly('received')}
|
||||
${form.render_field_readonly('damaged')}
|
||||
${form.render_field_readonly('expired')}
|
||||
${form.render_field_readonly('mispick')}
|
||||
|
||||
<div class="buttons">
|
||||
<once-button type="is-primary"
|
||||
tag="a" href="${url('{}.receive_row'.format(route_prefix), uuid=batch.uuid, row_uuid=row.uuid)}"
|
||||
text="Receive Product">
|
||||
|
@ -17,14 +80,56 @@
|
|||
tag="a" href="${url('{}.declare_credit'.format(route_prefix), uuid=batch.uuid, row_uuid=row.uuid)}"
|
||||
text="Declare Credit">
|
||||
</once-button>
|
||||
% else:
|
||||
${h.link_to("Receive Product", url('{}.receive_row'.format(route_prefix), uuid=batch.uuid, row_uuid=row.uuid), class_='button autodisable')}
|
||||
${h.link_to("Declare Credit", url('{}.declare_credit'.format(route_prefix), uuid=batch.uuid, row_uuid=row.uuid), class_='button autodisable')}
|
||||
% endif
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
</div>
|
||||
|
||||
<div style="display: flex;">
|
||||
|
||||
<nav class="panel" >
|
||||
<p class="panel-heading">Purchase Order</p>
|
||||
<div class="panel-block">
|
||||
<div>
|
||||
${form.render_field_readonly('po_line_number')}
|
||||
${form.render_field_readonly('po_unit_cost')}
|
||||
${form.render_field_readonly('po_total')}
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<nav class="panel" >
|
||||
<p class="panel-heading">Invoice</p>
|
||||
<div class="panel-block">
|
||||
<div>
|
||||
${form.render_field_readonly('invoice_line_number')}
|
||||
${form.render_field_readonly('invoice_unit_cost')}
|
||||
${form.render_field_readonly('invoice_cost_confirmed')}
|
||||
${form.render_field_readonly('invoice_total')}
|
||||
${form.render_field_readonly('invoice_total_calculated')}
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
</div>
|
||||
|
||||
<nav class="panel" >
|
||||
<p class="panel-heading">Credits</p>
|
||||
<div class="panel-block">
|
||||
<div>
|
||||
${form.render_field_readonly('credits')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
% else:
|
||||
## legacy / not buefy
|
||||
${parent.page_content()}
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
|
||||
${parent.body()}
|
||||
|
|
|
@ -129,14 +129,19 @@ class PurchasingBatchView(BatchMasterView):
|
|||
'description',
|
||||
'size',
|
||||
'case_quantity',
|
||||
'ordered',
|
||||
'cases_ordered',
|
||||
'units_ordered',
|
||||
'received',
|
||||
'cases_received',
|
||||
'units_received',
|
||||
'damaged',
|
||||
'cases_damaged',
|
||||
'units_damaged',
|
||||
'expired',
|
||||
'cases_expired',
|
||||
'units_expired',
|
||||
'mispick',
|
||||
'cases_mispick',
|
||||
'units_mispick',
|
||||
'po_line_number',
|
||||
|
@ -699,6 +704,13 @@ class PurchasingBatchView(BatchMasterView):
|
|||
f.set_readonly('case_quantity')
|
||||
|
||||
# quantity fields
|
||||
f.set_renderer('ordered', self.render_row_quantity)
|
||||
f.set_renderer('shipped', self.render_row_quantity)
|
||||
f.set_renderer('received', self.render_row_quantity)
|
||||
f.set_renderer('damaged', self.render_row_quantity)
|
||||
f.set_renderer('expired', self.render_row_quantity)
|
||||
f.set_renderer('mispick', self.render_row_quantity)
|
||||
|
||||
f.set_type('case_quantity', 'quantity')
|
||||
f.set_type('cases_ordered', 'quantity')
|
||||
f.set_type('units_ordered', 'quantity')
|
||||
|
@ -770,6 +782,18 @@ class PurchasingBatchView(BatchMasterView):
|
|||
else:
|
||||
f.remove_field('product')
|
||||
|
||||
def render_row_quantity(self, row, field):
|
||||
app = self.get_rattail_app()
|
||||
cases = getattr(row, 'cases_{}'.format(field))
|
||||
units = getattr(row, 'units_{}'.format(field))
|
||||
if cases and units:
|
||||
return "{} cases + {} units".format(app.render_quantity(cases),
|
||||
app.render_quantity(units))
|
||||
if cases and not units:
|
||||
return "{} cases".format(app.render_quantity(cases))
|
||||
if units and not cases:
|
||||
return "{} units".format(app.render_quantity(units))
|
||||
|
||||
def render_row_credits(self, row, field):
|
||||
if not row.credits:
|
||||
return ""
|
||||
|
|
|
@ -163,18 +163,25 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
'description',
|
||||
'size',
|
||||
'case_quantity',
|
||||
'ordered',
|
||||
'cases_ordered',
|
||||
'units_ordered',
|
||||
'shipped',
|
||||
'cases_shipped',
|
||||
'units_shipped',
|
||||
'received',
|
||||
'cases_received',
|
||||
'units_received',
|
||||
'damaged',
|
||||
'cases_damaged',
|
||||
'units_damaged',
|
||||
'expired',
|
||||
'cases_expired',
|
||||
'units_expired',
|
||||
'mispick',
|
||||
'cases_mispick',
|
||||
'units_mispick',
|
||||
'catalog_unit_cost',
|
||||
'po_line_number',
|
||||
'po_unit_cost',
|
||||
'po_total',
|
||||
|
@ -607,6 +614,19 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
raise NotImplementedError
|
||||
return kwargs
|
||||
|
||||
def template_kwargs_view_row(self, **kwargs):
|
||||
kwargs = super(ReceivingBatchView, self).template_kwargs_view_row(**kwargs)
|
||||
app = self.get_rattail_app()
|
||||
handler = app.get_products_handler()
|
||||
row = kwargs['instance']
|
||||
|
||||
if row.product:
|
||||
kwargs['image_url'] = handler.get_image_url(row.product)
|
||||
elif row.upc:
|
||||
kwargs['image_url'] = handler.get_image_url(upc=row.upc)
|
||||
|
||||
return kwargs
|
||||
|
||||
def department_for_purchase(self, purchase):
|
||||
pass
|
||||
|
||||
|
@ -816,6 +836,8 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
return css_class
|
||||
|
||||
def get_row_instance_title(self, row):
|
||||
if row.product:
|
||||
return six.text_type(row.product)
|
||||
if row.upc:
|
||||
return row.upc.pretty()
|
||||
return super(ReceivingBatchView, self).get_row_instance_title(row)
|
||||
|
|
Loading…
Reference in a new issue