Tweak how some "pack item" fields are displayed when viewing product

This commit is contained in:
Lance Edgar 2018-07-03 20:47:32 -05:00
parent ad5444d270
commit 9a0a280d7d
2 changed files with 17 additions and 3 deletions

View file

@ -68,8 +68,11 @@
${form.render_field_readonly('size')}
${form.render_field_readonly('unit_size')}
${form.render_field_readonly('unit_of_measure')}
% if instance.is_pack_item():
${form.render_field_readonly('unit')}
${form.render_field_readonly('pack_size')}
${form.render_field_readonly('default_pack')}
% endif
${form.render_field_readonly('case_size')}
${self.extra_main_fields(form)}
</%def>

View file

@ -104,6 +104,7 @@ class ProductsView(MasterView):
'size',
'unit',
'pack_size',
'default_pack',
'case_size',
'weighed',
'department',
@ -364,6 +365,7 @@ class ProductsView(MasterView):
def configure_form(self, f):
super(ProductsView, self).configure_form(f)
product = f.model_instance
# upc
f.set_type('upc', 'gpc')
@ -511,13 +513,22 @@ class ProductsView(MasterView):
# unit
if self.creating:
f.remove_field('unit')
elif self.viewing and not product.is_pack_item():
f.remove_field('unit')
else:
f.set_renderer('unit', self.render_unit)
f.set_label('unit', "Unit Item")
# pack_size
if self.viewing and not product.is_pack_item():
f.remove_field('pack_size')
else:
f.set_type('pack_size', 'quantity')
# default_pack
if self.viewing and not product.is_pack_item():
f.remove_field('default_pack')
# regular_price
if self.creating:
f.remove_field('regular_price')