Improve display of VendorItem records when viewing a CORE Product

This commit is contained in:
Lance Edgar 2021-01-30 13:18:32 -06:00
parent b14e4b09fc
commit bd1be88be4

View file

@ -227,20 +227,16 @@ class ProductView(CoreOfficeMasterView):
key='{}.vendor_items'.format(route_prefix), key='{}.vendor_items'.format(route_prefix),
data=[], data=[],
columns=[ columns=[
'vendor_item_id',
'sku',
'vendor_name', 'vendor_name',
'upc', 'sku',
'brand',
'description',
'size', 'size',
'cost_display',
'units', 'units',
], ],
labels={ labels={
'vendor_item_id': "ID",
'sku': "SKU", 'sku': "SKU",
'vendor_name': "Vendor", 'vendor_name': "Vendor",
'upc': "UPC", 'cost_display': "Cost",
}, },
) )
return HTML.literal( return HTML.literal(
@ -249,24 +245,16 @@ class ProductView(CoreOfficeMasterView):
def template_kwargs_view(self, **kwargs): def template_kwargs_view(self, **kwargs):
kwargs = super(ProductView, self).template_kwargs_view(**kwargs) kwargs = super(ProductView, self).template_kwargs_view(**kwargs)
product = kwargs['instance'] product = kwargs['instance']
app = self.get_rattail_app()
vendor_items = [] vendor_items = []
for item in product.vendor_items: for item in product.vendor_items:
vendor_items.append({ vendor_items.append({
'vendor_item_id': item.vendor_item_id,
'sku': item.sku, 'sku': item.sku,
'vendor_id': item.vendor_id,
'vendor_name': item.vendor.name, 'vendor_name': item.vendor.name,
'upc': item.upc,
'brand': item.brand,
'description': item.description,
'size': item.size, 'size': item.size,
'cost_display': app.render_currency(item.cost),
'units': item.units, 'units': item.units,
# 'cost': item.cost,
# 'sale_cost': item.sale_cost,
'vendor_department_id': item.vendor_department_id,
# 'srp': item.srp,
# 'modified': item.modified,
}) })
kwargs['vendor_items_data'] = vendor_items kwargs['vendor_items_data'] = vendor_items