From 21740ea2fd662ac714c79cf17a0c2eae4293e43c Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 9 Aug 2018 15:59:57 -0500 Subject: [PATCH] Show links to claiming rows for truck dump parent row --- tailbone/views/purchasing/receiving.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tailbone/views/purchasing/receiving.py b/tailbone/views/purchasing/receiving.py index 2bcae43b..0a8991f0 100644 --- a/tailbone/views/purchasing/receiving.py +++ b/tailbone/views/purchasing/receiving.py @@ -234,6 +234,7 @@ class ReceivingBatchView(PurchasingBatchView): 'invoice_unit_cost', 'invoice_total', 'status_code', + 'claims', 'credits', ] @@ -679,12 +680,30 @@ class ReceivingBatchView(PurchasingBatchView): def configure_row_form(self, f): super(ReceivingBatchView, self).configure_row_form(f) + batch = self.get_instance() + f.set_readonly('cases_ordered') f.set_readonly('units_ordered') f.set_readonly('po_unit_cost') f.set_readonly('po_total') f.set_readonly('invoice_total') + # claims + if batch.is_truck_dump_parent(): + f.set_renderer('claims', self.render_row_claims) + else: + f.remove_field('claims') + + def render_row_claims(self, row, field): + items = [] + for claim in row.claims: + child_row = claim.claiming_row + child_batch = child_row.batch + text = child_batch.id_str + url = self.get_row_action_url('view', child_row) + items.append(HTML.tag('li', c=[tags.link_to(text, url)])) + return HTML.tag('ul', c=items) + def validate_row_form(self, form): # if normal validation fails, stop there