From e906c01e6477876651f7626081e57eda697dd3a5 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 8 Dec 2021 21:59:41 -0600 Subject: [PATCH] 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 --- tailbone/templates/receiving/view.mako | 61 +++++++++-- tailbone/templates/receiving/view_row.mako | 119 +++++++++++++++++++-- tailbone/views/purchasing/batch.py | 24 +++++ tailbone/views/purchasing/receiving.py | 22 ++++ 4 files changed, 212 insertions(+), 14 deletions(-) diff --git a/tailbone/templates/receiving/view.mako b/tailbone/templates/receiving/view.mako index df42de47..0fe3636a 100644 --- a/tailbone/templates/receiving/view.mako +++ b/tailbone/templates/receiving/view.mako @@ -286,17 +286,15 @@ <%def name="object_helpers()"> ${parent.object_helpers()} % if master.has_perm('auto_receive') and master.can_auto_receive(batch): +

Tools

% if use_buefy: - ${h.form(url('{}.auto_receive'.format(route_prefix), uuid=batch.uuid), ref='auto_receive_all_form')} - ${h.csrf_token(request)} - - - ${h.end_form()} + + Auto-Receive All Items + % else: ${h.form(url('{}.auto_receive'.format(route_prefix), uuid=batch.uuid), class_='autodisable')} ${h.csrf_token(request)} @@ -305,9 +303,58 @@ % endif
+ + % if use_buefy: + + + + % endif % endif +<%def name="modify_this_page_vars()"> + ${parent.modify_this_page_vars()} + + + ${parent.body()} diff --git a/tailbone/templates/receiving/view_row.mako b/tailbone/templates/receiving/view_row.mako index 744f58f3..53f426df 100644 --- a/tailbone/templates/receiving/view_row.mako +++ b/tailbone/templates/receiving/view_row.mako @@ -1,14 +1,77 @@ ## -*- coding: utf-8; -*- <%inherit file="/master/view_row.mako" /> +<%def name="extra_styles()"> + ${parent.extra_styles()} + + + <%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():

Receiving Tools

- % 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')} +
+
+
+ % endif + + +<%def name="page_content()"> + % if use_buefy: + + + ${form.render_field_readonly('sequence')} + ${form.render_field_readonly('status_code')} + + +
+ + + + + +
+ +
+ + + + + +
+ + + + % else: + ## legacy / not buefy + ${parent.page_content()} % endif + ${parent.body()} diff --git a/tailbone/views/purchasing/batch.py b/tailbone/views/purchasing/batch.py index c75c9fa3..96e7fda9 100644 --- a/tailbone/views/purchasing/batch.py +++ b/tailbone/views/purchasing/batch.py @@ -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 "" diff --git a/tailbone/views/purchasing/receiving.py b/tailbone/views/purchasing/receiving.py index f0fc3e12..48b5fc00 100644 --- a/tailbone/views/purchasing/receiving.py +++ b/tailbone/views/purchasing/receiving.py @@ -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)