More basic field tweaks for mobile "view product" page
This commit is contained in:
parent
3a91ab6bec
commit
3b0292029d
|
@ -80,6 +80,7 @@ class ProductsView(MasterView):
|
|||
has_versions = True
|
||||
|
||||
labels = {
|
||||
'upc': "UPC",
|
||||
'status_code': "Status",
|
||||
}
|
||||
|
||||
|
@ -116,6 +117,8 @@ class ProductsView(MasterView):
|
|||
'regular_price',
|
||||
'current_price',
|
||||
'current_price_ends',
|
||||
'vendor',
|
||||
'cost',
|
||||
'deposit_link',
|
||||
'tax',
|
||||
'organic',
|
||||
|
@ -135,8 +138,6 @@ class ProductsView(MasterView):
|
|||
'last_sold',
|
||||
'inventory_on_hand',
|
||||
'inventory_on_order',
|
||||
'vendor',
|
||||
'cost',
|
||||
]
|
||||
|
||||
mobile_form_fields = form_fields
|
||||
|
@ -300,13 +301,51 @@ class ProductsView(MasterView):
|
|||
g.set_link('item_id')
|
||||
g.set_link('description')
|
||||
|
||||
g.set_label('upc', "UPC")
|
||||
g.set_label('vendor', "Vendor (preferred)")
|
||||
g.set_label('vendor_any', "Vendor (any)")
|
||||
g.set_label('vendor', "Pref. Vendor")
|
||||
|
||||
def configure_common_form(self, f):
|
||||
super(ProductsView, self).configure_common_form(f)
|
||||
product = f.model_instance
|
||||
|
||||
# upc
|
||||
f.set_type('upc', 'gpc')
|
||||
|
||||
# unit_size
|
||||
f.set_type('unit_size', 'quantity')
|
||||
|
||||
# unit_of_measure
|
||||
f.set_enum('unit_of_measure', self.enum.UNIT_OF_MEASURE)
|
||||
f.set_label('unit_of_measure', "Unit of Measure")
|
||||
|
||||
# packs
|
||||
if self.creating:
|
||||
f.remove_field('packs')
|
||||
elif self.viewing and product.packs:
|
||||
f.set_renderer('packs', self.render_packs)
|
||||
f.set_label('packs', "Pack Items")
|
||||
else:
|
||||
f.remove_field('packs')
|
||||
|
||||
# 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')
|
||||
|
||||
# unit
|
||||
if self.creating:
|
||||
f.remove_field('unit')
|
||||
elif self.viewing and product.is_pack_item():
|
||||
f.set_renderer('unit', self.render_unit)
|
||||
f.set_label('unit', "Unit Item")
|
||||
else:
|
||||
f.remove_field('unit')
|
||||
|
||||
# regular_price
|
||||
if self.creating:
|
||||
|
@ -344,6 +383,29 @@ class ProductsView(MasterView):
|
|||
f.set_label('cost', "Preferred Unit Cost")
|
||||
f.set_renderer('cost', self.render_cost)
|
||||
|
||||
# last_sold
|
||||
if self.creating:
|
||||
f.remove_field('last_sold')
|
||||
else:
|
||||
f.set_readonly('last_sold')
|
||||
f.set_renderer('last_sold', self.render_last_sold)
|
||||
|
||||
# inventory_on_hand
|
||||
if self.creating:
|
||||
f.remove_field('inventory_on_hand')
|
||||
else:
|
||||
f.set_readonly('inventory_on_hand')
|
||||
f.set_renderer('inventory_on_hand', self.render_inventory_on_hand)
|
||||
f.set_label('inventory_on_hand', "On Hand")
|
||||
|
||||
# inventory_on_order
|
||||
if self.creating:
|
||||
f.remove_field('inventory_on_order')
|
||||
else:
|
||||
f.set_readonly('inventory_on_order')
|
||||
f.set_renderer('inventory_on_order', self.render_inventory_on_order)
|
||||
f.set_label('inventory_on_order', "On Order")
|
||||
|
||||
def render_cost(self, product, field):
|
||||
cost = getattr(product, field)
|
||||
if cost:
|
||||
|
@ -423,10 +485,6 @@ class ProductsView(MasterView):
|
|||
super(ProductsView, self).configure_form(f)
|
||||
product = f.model_instance
|
||||
|
||||
# upc
|
||||
f.set_type('upc', 'gpc')
|
||||
f.set_label('upc', "UPC")
|
||||
|
||||
# department
|
||||
if self.creating or self.editing:
|
||||
if 'department' in f.fields:
|
||||
|
@ -559,47 +617,6 @@ class ProductsView(MasterView):
|
|||
field_display=brand_display, service_url=brands_url))
|
||||
f.set_label('brand_uuid', "Brand")
|
||||
|
||||
# unit_size
|
||||
f.set_type('unit_size', 'quantity')
|
||||
|
||||
# unit_of_measure
|
||||
f.set_enum('unit_of_measure', self.enum.UNIT_OF_MEASURE)
|
||||
f.set_label('unit_of_measure', "Unit of Measure")
|
||||
|
||||
# packs
|
||||
if self.creating:
|
||||
f.remove_field('packs')
|
||||
elif self.viewing and product.packs:
|
||||
f.set_renderer('packs', self.render_packs)
|
||||
f.set_label('packs', "Pack Items")
|
||||
else:
|
||||
f.remove_field('packs')
|
||||
|
||||
# unit
|
||||
if self.creating:
|
||||
f.remove_field('unit')
|
||||
elif self.viewing and product.is_pack_item():
|
||||
f.set_renderer('unit', self.render_unit)
|
||||
f.set_label('unit', "Unit Item")
|
||||
else:
|
||||
f.remove_field('unit')
|
||||
|
||||
# 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')
|
||||
|
||||
# last_sold
|
||||
if self.creating:
|
||||
f.remove_field('last_sold')
|
||||
else:
|
||||
f.set_readonly('last_sold')
|
||||
|
||||
# status_code
|
||||
f.set_label('status_code', "Status")
|
||||
|
||||
|
@ -609,22 +626,6 @@ class ProductsView(MasterView):
|
|||
# notes
|
||||
f.set_widget('notes', dfwidget.TextAreaWidget(cols=80, rows=10))
|
||||
|
||||
# inventory_on_hand
|
||||
if self.creating:
|
||||
f.remove_field('inventory_on_hand')
|
||||
else:
|
||||
f.set_readonly('inventory_on_hand')
|
||||
f.set_renderer('inventory_on_hand', self.render_inventory_on_hand)
|
||||
f.set_label('inventory_on_hand', "On Hand")
|
||||
|
||||
# inventory_on_order
|
||||
if self.creating:
|
||||
f.remove_field('inventory_on_order')
|
||||
else:
|
||||
f.set_readonly('inventory_on_order')
|
||||
f.set_renderer('inventory_on_order', self.render_inventory_on_order)
|
||||
f.set_label('inventory_on_order', "On Order")
|
||||
|
||||
if not self.request.has_perm('products.view_deleted'):
|
||||
f.remove('deleted')
|
||||
|
||||
|
@ -676,7 +677,7 @@ class ProductsView(MasterView):
|
|||
else:
|
||||
code = pack.item_id
|
||||
text = "({}) {}".format(code, pack.full_description)
|
||||
url = self.get_action_url('view', pack)
|
||||
url = self.get_action_url('view', pack, mobile=self.mobile)
|
||||
links.append(tags.link_to(text, url))
|
||||
|
||||
items = [HTML.tag('li', c=[link]) for link in links]
|
||||
|
@ -695,7 +696,7 @@ class ProductsView(MasterView):
|
|||
code = unit.item_id
|
||||
|
||||
text = "({}) {}".format(code, unit.full_description)
|
||||
url = self.get_action_url('view', unit)
|
||||
url = self.get_action_url('view', unit, mobile=self.mobile)
|
||||
return tags.link_to(text, url)
|
||||
|
||||
def render_current_price_ends(self, product, field):
|
||||
|
@ -706,6 +707,9 @@ class ProductsView(MasterView):
|
|||
return ""
|
||||
return raw_datetime(self.request.rattail_config, value)
|
||||
|
||||
def render_last_sold(self, product, field):
|
||||
return "TODO: add default renderer for last sold"
|
||||
|
||||
def render_inventory_on_hand(self, product, field):
|
||||
if not product.inventory:
|
||||
return ""
|
||||
|
|
Loading…
Reference in a new issue