Fix basic product editing feature

limit which fields are supported
This commit is contained in:
Lance Edgar 2020-02-28 18:12:16 -06:00
parent db70870921
commit ece361a0e6
2 changed files with 70 additions and 1 deletions

View file

@ -24,7 +24,7 @@ def includeme(config):
config.include('tailbone.views.families') config.include('tailbone.views.families')
config.include('tailbone.views.messages') config.include('tailbone.views.messages')
config.include('rattail_demo.web.views.people') config.include('rattail_demo.web.views.people')
config.include('tailbone.views.products') config.include('rattail_demo.web.views.products')
config.include('tailbone.views.reportcodes') config.include('tailbone.views.reportcodes')
config.include('tailbone.views.roles') config.include('tailbone.views.roles')
config.include('rattail_demo.web.views.settings') config.include('rattail_demo.web.views.settings')

View file

@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-
"""
Product views
"""
from __future__ import unicode_literals, absolute_import
from tailbone.views import products as base
class ProductsView(base.ProductsView):
"""
Product overrides for online demo
"""
def configure_form(self, f):
super(ProductsView, self).configure_form(f)
if self.editing:
f.fields = [
'upc',
'brand_uuid',
'description',
'unit_size',
'unit_of_measure',
'size',
'pack_size',
'default_pack',
'case_size',
'weighed',
'department_uuid',
'subdepartment_uuid',
'category_uuid',
'family_uuid',
'report_code_uuid',
'regular_price_amount',
'deposit_link_uuid',
'tax_uuid',
'tax1',
'tax2',
'tax3',
'organic',
'kosher',
'vegan',
'vegetarian',
'gluten_free',
'sugar_free',
'discountable',
'special_order',
'not_for_sale',
'ingredients',
'notes',
'status',
'discontinued',
'deleted',
]
def includeme(config):
config.add_route('products.autocomplete', '/products/autocomplete')
config.add_view(base.ProductsAutocomplete, route_name='products.autocomplete',
renderer='json', permission='products.list')
config.add_route('products.print_labels', '/products/labels')
config.add_view(base.print_labels, route_name='products.print_labels',
renderer='json', permission='products.print_labels')
ProductsView.defaults(config)