Fix price fields, add pref. vendor/cost fields for mobile product view
This commit is contained in:
parent
66f1ed0e41
commit
3a91ab6bec
|
@ -135,6 +135,8 @@ class ProductsView(MasterView):
|
|||
'last_sold',
|
||||
'inventory_on_hand',
|
||||
'inventory_on_order',
|
||||
'vendor',
|
||||
'cost',
|
||||
]
|
||||
|
||||
mobile_form_fields = form_fields
|
||||
|
@ -303,6 +305,53 @@ class ProductsView(MasterView):
|
|||
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)
|
||||
|
||||
# regular_price
|
||||
if self.creating:
|
||||
f.remove_field('regular_price')
|
||||
else:
|
||||
f.set_readonly('regular_price')
|
||||
f.set_renderer('regular_price', self.render_price)
|
||||
|
||||
# current_price
|
||||
if self.creating:
|
||||
f.remove_field('current_price')
|
||||
else:
|
||||
f.set_readonly('current_price')
|
||||
f.set_renderer('current_price', self.render_price)
|
||||
|
||||
# current_price_ends
|
||||
if self.creating:
|
||||
f.remove_field('current_price_ends')
|
||||
else:
|
||||
f.set_readonly('current_price_ends')
|
||||
f.set_renderer('current_price_ends', self.render_current_price_ends)
|
||||
|
||||
# vendor
|
||||
if self.creating:
|
||||
f.remove_field('vendor')
|
||||
else:
|
||||
f.set_readonly('vendor')
|
||||
f.set_label('vendor', "Preferred Vendor")
|
||||
|
||||
# cost
|
||||
if self.creating:
|
||||
f.remove_field('cost')
|
||||
else:
|
||||
f.set_readonly('cost')
|
||||
f.set_label('cost', "Preferred Unit Cost")
|
||||
f.set_renderer('cost', self.render_cost)
|
||||
|
||||
def render_cost(self, product, field):
|
||||
cost = getattr(product, field)
|
||||
if cost:
|
||||
if cost.unit_cost:
|
||||
return "$ {:0.2f}".format(cost.unit_cost)
|
||||
else:
|
||||
return "TODO: does this item have a cost?"
|
||||
|
||||
def render_price(self, product, column):
|
||||
price = product[column]
|
||||
if price:
|
||||
|
@ -545,20 +594,6 @@ class ProductsView(MasterView):
|
|||
if self.viewing and not product.is_pack_item():
|
||||
f.remove_field('default_pack')
|
||||
|
||||
# regular_price
|
||||
if self.creating:
|
||||
f.remove_field('regular_price')
|
||||
else:
|
||||
f.set_readonly('regular_price')
|
||||
f.set_renderer('regular_price', self.render_price)
|
||||
|
||||
# current_price
|
||||
if self.creating:
|
||||
f.remove_field('current_price')
|
||||
else:
|
||||
f.set_readonly('current_price')
|
||||
f.set_renderer('current_price', self.render_price)
|
||||
|
||||
# last_sold
|
||||
if self.creating:
|
||||
f.remove_field('last_sold')
|
||||
|
@ -574,13 +609,6 @@ class ProductsView(MasterView):
|
|||
# notes
|
||||
f.set_widget('notes', dfwidget.TextAreaWidget(cols=80, rows=10))
|
||||
|
||||
# current_price_ends
|
||||
if self.creating:
|
||||
f.remove_field('current_price_ends')
|
||||
else:
|
||||
f.set_readonly('current_price_ends')
|
||||
f.set_renderer('current_price_ends', self.render_current_price_ends)
|
||||
|
||||
# inventory_on_hand
|
||||
if self.creating:
|
||||
f.remove_field('inventory_on_hand')
|
||||
|
|
Loading…
Reference in a new issue