Tweak how product key field is handled for product views

This commit is contained in:
Lance Edgar 2022-02-05 15:59:36 -06:00
parent 091b479a02
commit a36f775752

View file

@ -97,7 +97,7 @@ class ProductView(MasterView):
}
grid_columns = [
'upc',
'_product_key_',
'brand',
'description',
'size',
@ -108,9 +108,7 @@ class ProductView(MasterView):
]
form_fields = [
'item_id',
'scancode',
'upc',
'_product_key_',
'brand',
'description',
'unit_size',
@ -254,6 +252,15 @@ class ProductView(MasterView):
return q.outerjoin(ProductCostCodeAny,
ProductCostCodeAny.product_uuid == model.Product.uuid)
# product key
key = self.rattail_config.product_key()
field = self.product_key_fields.get(key, key)
g.filters[field].default_active = True
g.filters[field].default_verb = 'equal'
g.set_sort_defaults(field)
g.set_link(field)
# brand
g.joiners['brand'] = lambda q: q.outerjoin(model.Brand)
# department
@ -305,8 +312,6 @@ class ProductView(MasterView):
g.set_sorter('on_order', model.ProductInventory.on_order)
g.set_filter('on_order', model.ProductInventory.on_order)
g.filters['upc'].default_active = True
g.filters['upc'].default_verb = 'equal'
g.filters['description'].default_active = True
g.filters['description'].default_verb = 'contains'
g.filters['brand'] = g.make_filter('brand', model.Brand.name,
@ -367,8 +372,6 @@ class ProductView(MasterView):
g.set_joiner('report_code_name', lambda q: q.outerjoin(model.ReportCode))
g.set_filter('report_code_name', model.ReportCode.name)
g.set_sort_defaults('upc')
if self.expose_label_printing and self.has_perm('print_labels'):
if use_buefy:
g.more_actions.append(self.make_action(
@ -377,13 +380,10 @@ class ProductView(MasterView):
else:
g.more_actions.append(grids.GridAction('print_label', icon='print'))
g.set_type('upc', 'gpc')
g.set_renderer('regular_price', self.render_price)
g.set_renderer('on_hand', self.render_on_hand)
g.set_renderer('on_order', self.render_on_order)
g.set_link('upc')
g.set_link('item_id')
g.set_link('description')
@ -395,9 +395,6 @@ class ProductView(MasterView):
super(ProductView, self).configure_common_form(f)
product = f.model_instance
# upc
f.set_type('upc', 'gpc')
# unit_size
f.set_type('unit_size', 'quantity')
@ -1173,8 +1170,10 @@ class ProductView(MasterView):
product = kwargs['instance']
use_buefy = self.get_use_buefy()
key = self.rattail_config.product_key()
kwargs['product_key_field'] = self.product_key_fields.get(key, key)
kwargs['image_url'] = self.product_handler.get_image_url(product)
kwargs['product_key_field'] = self.rattail_config.product_key()
# add price history, if user has access
if self.rattail_config.versioning_enabled() and self.has_perm('versions'):