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('size')}
${form.render_field_readonly('unit_size')} ${form.render_field_readonly('unit_size')}
${form.render_field_readonly('unit_of_measure')} ${form.render_field_readonly('unit_of_measure')}
${form.render_field_readonly('unit')} % if instance.is_pack_item():
${form.render_field_readonly('pack_size')} ${form.render_field_readonly('unit')}
${form.render_field_readonly('pack_size')}
${form.render_field_readonly('default_pack')}
% endif
${form.render_field_readonly('case_size')} ${form.render_field_readonly('case_size')}
${self.extra_main_fields(form)} ${self.extra_main_fields(form)}
</%def> </%def>

View file

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