Tweak how vendor link is rendered for readonly field

This commit is contained in:
Lance Edgar 2021-01-27 22:24:23 -06:00
parent 797a65e9c8
commit b3867d9c89
2 changed files with 5 additions and 12 deletions

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar
# Copyright © 2010-2021 Lance Edgar
#
# This file is part of Rattail.
#
@ -953,8 +953,9 @@ class MasterView(View):
vendor = getattr(obj, field)
if not vendor:
return ""
if vendor.id:
text = "({}) {}".format(vendor.id, vendor.name)
short = vendor.id or vendor.abbreviation
if short:
text = "({}) {}".format(short, vendor.name)
else:
text = six.text_type(vendor)
url = self.request.route_url('vendors.view', uuid=vendor.uuid)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar
# Copyright © 2010-2021 Lance Edgar
#
# This file is part of Rattail.
#
@ -409,14 +409,6 @@ class PurchasingBatchView(BatchMasterView):
url = self.request.route_url('purchases.view', uuid=purchase.uuid)
return tags.link_to(text, url)
def render_vendor(self, batch, field):
vendor = batch.vendor
if not vendor:
return ""
text = "({}) {}".format(vendor.id, vendor.name)
url = self.request.route_url('vendors.view', uuid=vendor.uuid)
return tags.link_to(text, url)
def render_vendor_email(self, batch, field):
if batch.vendor.email:
return batch.vendor.email.address