Expose CORE vendorItems
data
This commit is contained in:
parent
338cdd578a
commit
aca23ffe6d
|
@ -1,3 +1,13 @@
|
||||||
## -*- coding: utf-8; -*-
|
## -*- coding: utf-8; -*-
|
||||||
<%inherit file="/core-pos/master/view.mako" />
|
<%inherit file="/core-pos/master/view.mako" />
|
||||||
|
|
||||||
|
<%def name="modify_this_page_vars()">
|
||||||
|
${parent.modify_this_page_vars()}
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
${form.component_studly}Data.vendorItemsData = ${json.dumps(vendor_items_data)|n}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</%def>
|
||||||
|
|
||||||
${parent.body()}
|
${parent.body()}
|
||||||
|
|
12
tailbone_corepos/templates/core-pos/vendor-items/index.mako
Normal file
12
tailbone_corepos/templates/core-pos/vendor-items/index.mako
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
## -*- coding: utf-8; -*-
|
||||||
|
<%inherit file="/master/index.mako" />
|
||||||
|
|
||||||
|
<%def name="context_menu_items()">
|
||||||
|
${parent.context_menu_items()}
|
||||||
|
% if request.has_perm('corepos.vendors.list'):
|
||||||
|
<li>${h.link_to("View CORE-POS Vendors", url('corepos.vendors'))}</li>
|
||||||
|
% endif
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
|
||||||
|
${parent.body()}
|
12
tailbone_corepos/templates/core-pos/vendors/index.mako
vendored
Normal file
12
tailbone_corepos/templates/core-pos/vendors/index.mako
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
## -*- coding: utf-8; -*-
|
||||||
|
<%inherit file="/master/index.mako" />
|
||||||
|
|
||||||
|
<%def name="context_menu_items()">
|
||||||
|
${parent.context_menu_items()}
|
||||||
|
% if request.has_perm('corepos.vendor_items.list'):
|
||||||
|
<li>${h.link_to("View CORE-POS Vendor Items", url('corepos.vendor_items'))}</li>
|
||||||
|
% endif
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
|
||||||
|
${parent.body()}
|
|
@ -33,6 +33,7 @@ def includeme(config):
|
||||||
config.include('tailbone_corepos.views.corepos.subdepartments')
|
config.include('tailbone_corepos.views.corepos.subdepartments')
|
||||||
config.include('tailbone_corepos.views.corepos.superdepartments')
|
config.include('tailbone_corepos.views.corepos.superdepartments')
|
||||||
config.include('tailbone_corepos.views.corepos.vendors')
|
config.include('tailbone_corepos.views.corepos.vendors')
|
||||||
|
config.include('tailbone_corepos.views.corepos.vendoritems')
|
||||||
config.include('tailbone_corepos.views.corepos.origins')
|
config.include('tailbone_corepos.views.corepos.origins')
|
||||||
config.include('tailbone_corepos.views.corepos.products')
|
config.include('tailbone_corepos.views.corepos.products')
|
||||||
config.include('tailbone_corepos.views.corepos.scaleitems')
|
config.include('tailbone_corepos.views.corepos.scaleitems')
|
||||||
|
|
|
@ -68,6 +68,70 @@ class ProductView(CoreOfficeMasterView):
|
||||||
'cost',
|
'cost',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
form_fields = [
|
||||||
|
'upc',
|
||||||
|
'id',
|
||||||
|
'brand',
|
||||||
|
'description',
|
||||||
|
'size',
|
||||||
|
'unit_of_measure',
|
||||||
|
'formatted_name',
|
||||||
|
'tare_weight',
|
||||||
|
|
||||||
|
'department_number',
|
||||||
|
'department',
|
||||||
|
'subdepartment_number',
|
||||||
|
'subdepartment',
|
||||||
|
|
||||||
|
'id_enforced',
|
||||||
|
|
||||||
|
'in_use',
|
||||||
|
'quantity_enforced',
|
||||||
|
'scale',
|
||||||
|
'scale_price',
|
||||||
|
'food_stamp',
|
||||||
|
'wicable',
|
||||||
|
'line_item_discountable',
|
||||||
|
'flags',
|
||||||
|
|
||||||
|
'price_method',
|
||||||
|
'group_price',
|
||||||
|
'special_price_method',
|
||||||
|
'special_group_price',
|
||||||
|
'special_quantity',
|
||||||
|
'tax_rate_id',
|
||||||
|
'tax_rate',
|
||||||
|
'mix_match_code',
|
||||||
|
'discount_type',
|
||||||
|
|
||||||
|
'default_vendor_id',
|
||||||
|
'default_vendor',
|
||||||
|
'cost',
|
||||||
|
'vendor_items',
|
||||||
|
|
||||||
|
'normal_price',
|
||||||
|
'quantity',
|
||||||
|
'special_price',
|
||||||
|
'start_date',
|
||||||
|
'end_date',
|
||||||
|
|
||||||
|
'modified',
|
||||||
|
|
||||||
|
'discount',
|
||||||
|
|
||||||
|
'deposit',
|
||||||
|
'local',
|
||||||
|
|
||||||
|
'store_id',
|
||||||
|
'current_origin_id',
|
||||||
|
'last_sold',
|
||||||
|
|
||||||
|
'scale_item',
|
||||||
|
'user_info',
|
||||||
|
'physical_location',
|
||||||
|
'like_code',
|
||||||
|
]
|
||||||
|
|
||||||
def configure_grid(self, g):
|
def configure_grid(self, g):
|
||||||
super(ProductView, self).configure_grid(g)
|
super(ProductView, self).configure_grid(g)
|
||||||
|
|
||||||
|
@ -91,6 +155,9 @@ class ProductView(CoreOfficeMasterView):
|
||||||
g.set_link('brand')
|
g.set_link('brand')
|
||||||
g.set_link('description')
|
g.set_link('description')
|
||||||
|
|
||||||
|
def get_instance_title(self, product):
|
||||||
|
return "{} {}".format(product.upc, product.description)
|
||||||
|
|
||||||
def configure_form(self, f):
|
def configure_form(self, f):
|
||||||
super(ProductView, self).configure_form(f)
|
super(ProductView, self).configure_form(f)
|
||||||
|
|
||||||
|
@ -99,6 +166,8 @@ class ProductView(CoreOfficeMasterView):
|
||||||
|
|
||||||
f.set_renderer('vendor', self.render_corepos_vendor)
|
f.set_renderer('vendor', self.render_corepos_vendor)
|
||||||
|
|
||||||
|
f.set_renderer('vendor_items', self.render_vendor_items)
|
||||||
|
|
||||||
f.set_renderer('flags', self.render_flags)
|
f.set_renderer('flags', self.render_flags)
|
||||||
|
|
||||||
f.set_type('start_date', 'datetime_local')
|
f.set_type('start_date', 'datetime_local')
|
||||||
|
@ -139,6 +208,60 @@ class ProductView(CoreOfficeMasterView):
|
||||||
|
|
||||||
return HTML.tag('ul', c=items)
|
return HTML.tag('ul', c=items)
|
||||||
|
|
||||||
|
def render_vendor_items(self, product, field):
|
||||||
|
route_prefix = self.get_route_prefix()
|
||||||
|
permission_prefix = self.get_permission_prefix()
|
||||||
|
|
||||||
|
factory = self.get_grid_factory()
|
||||||
|
g = factory(
|
||||||
|
key='{}.vendor_items'.format(route_prefix),
|
||||||
|
data=[],
|
||||||
|
columns=[
|
||||||
|
'vendor_item_id',
|
||||||
|
'sku',
|
||||||
|
'vendor_name',
|
||||||
|
'upc',
|
||||||
|
'brand',
|
||||||
|
'description',
|
||||||
|
'size',
|
||||||
|
'units',
|
||||||
|
],
|
||||||
|
labels={
|
||||||
|
'vendor_item_id': "ID",
|
||||||
|
'sku': "SKU",
|
||||||
|
'vendor_name': "Vendor",
|
||||||
|
'upc': "UPC",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return HTML.literal(
|
||||||
|
g.render_buefy_table_element(data_prop='vendorItemsData'))
|
||||||
|
|
||||||
|
def template_kwargs_view(self, **kwargs):
|
||||||
|
kwargs = super(ProductView, self).template_kwargs_view(**kwargs)
|
||||||
|
product = kwargs['instance']
|
||||||
|
|
||||||
|
vendor_items = []
|
||||||
|
for item in product.vendor_items:
|
||||||
|
vendor_items.append({
|
||||||
|
'vendor_item_id': item.vendor_item_id,
|
||||||
|
'sku': item.sku,
|
||||||
|
'vendor_id': item.vendor_id,
|
||||||
|
'vendor_name': item.vendor.name,
|
||||||
|
'upc': item.upc,
|
||||||
|
'brand': item.brand,
|
||||||
|
'description': item.description,
|
||||||
|
'size': item.size,
|
||||||
|
'units': item.units,
|
||||||
|
# 'cost': item.cost,
|
||||||
|
# 'sale_cost': item.sale_cost,
|
||||||
|
'vendor_department_id': item.vendor_department_id,
|
||||||
|
# 'srp': item.srp,
|
||||||
|
# 'modified': item.modified,
|
||||||
|
})
|
||||||
|
kwargs['vendor_items_data'] = vendor_items
|
||||||
|
|
||||||
|
return kwargs
|
||||||
|
|
||||||
def core_office_object_url(self, office_url, product):
|
def core_office_object_url(self, office_url, product):
|
||||||
return '{}/item/ItemEditorPage.php?searchupc={}'.format(
|
return '{}/item/ItemEditorPage.php?searchupc={}'.format(
|
||||||
office_url, product.upc)
|
office_url, product.upc)
|
||||||
|
|
111
tailbone_corepos/views/corepos/vendoritems.py
Normal file
111
tailbone_corepos/views/corepos/vendoritems.py
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
# -*- coding: utf-8; -*-
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Rattail -- Retail Software Framework
|
||||||
|
# Copyright © 2010-2020 Lance Edgar
|
||||||
|
#
|
||||||
|
# This file is part of Rattail.
|
||||||
|
#
|
||||||
|
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||||
|
# terms of the GNU General Public License as published by the Free Software
|
||||||
|
# Foundation, either version 3 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
# details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along with
|
||||||
|
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
"""
|
||||||
|
CORE-POS vendor item views
|
||||||
|
"""
|
||||||
|
|
||||||
|
from corepos.db.office_op import model as corepos
|
||||||
|
|
||||||
|
from .master import CoreOfficeMasterView
|
||||||
|
|
||||||
|
|
||||||
|
class VendorItemView(CoreOfficeMasterView):
|
||||||
|
"""
|
||||||
|
Base class for vendor iem views.
|
||||||
|
"""
|
||||||
|
model_class = corepos.VendorItem
|
||||||
|
model_title = "CORE-POS Vendor Item"
|
||||||
|
url_prefix = '/core-pos/vendor-items'
|
||||||
|
route_prefix = 'corepos.vendor_items'
|
||||||
|
|
||||||
|
labels = {
|
||||||
|
'vendor_item_id': "ID",
|
||||||
|
'sku': "SKU",
|
||||||
|
'vendor_id': "Vendor ID",
|
||||||
|
'upc': "UPC",
|
||||||
|
'vendor_department_id': "Vendor Department ID",
|
||||||
|
'srp': "SRP",
|
||||||
|
}
|
||||||
|
|
||||||
|
grid_columns = [
|
||||||
|
'vendor_item_id',
|
||||||
|
'sku',
|
||||||
|
'vendor',
|
||||||
|
'upc',
|
||||||
|
'brand',
|
||||||
|
'description',
|
||||||
|
'size',
|
||||||
|
'units',
|
||||||
|
'modified',
|
||||||
|
]
|
||||||
|
|
||||||
|
form_fields = [
|
||||||
|
'vendor_item_id',
|
||||||
|
'sku',
|
||||||
|
'vendor_id',
|
||||||
|
'vendor',
|
||||||
|
'upc',
|
||||||
|
'brand',
|
||||||
|
'description',
|
||||||
|
'size',
|
||||||
|
'units',
|
||||||
|
'cost',
|
||||||
|
'sale_cost',
|
||||||
|
'vendor_department_id',
|
||||||
|
'srp',
|
||||||
|
'modified',
|
||||||
|
]
|
||||||
|
|
||||||
|
def configure_grid(self, g):
|
||||||
|
super(VendorItemView, self).configure_grid(g)
|
||||||
|
|
||||||
|
g.filters['upc'].default_active = True
|
||||||
|
g.filters['upc'].default_verb = 'contains'
|
||||||
|
|
||||||
|
g.set_sort_defaults('modified', 'desc')
|
||||||
|
|
||||||
|
g.set_link('vendor_item_id')
|
||||||
|
g.set_link('sku')
|
||||||
|
g.set_link('vendor')
|
||||||
|
g.set_link('upc')
|
||||||
|
g.set_link('brand')
|
||||||
|
g.set_link('description')
|
||||||
|
|
||||||
|
def configure_form(self, f):
|
||||||
|
super(VendorItemView, self).configure_form(f)
|
||||||
|
|
||||||
|
f.set_readonly('vendor')
|
||||||
|
|
||||||
|
if self.creating:
|
||||||
|
f.remove('vendor_item_id')
|
||||||
|
else:
|
||||||
|
f.set_readonly('vendor_item_id')
|
||||||
|
|
||||||
|
if self.creating or self.editing:
|
||||||
|
f.remove('modified')
|
||||||
|
else:
|
||||||
|
f.set_readonly('modified')
|
||||||
|
|
||||||
|
|
||||||
|
def includeme(config):
|
||||||
|
VendorItemView.defaults(config)
|
Loading…
Reference in a new issue