source: rattail-demo/rattail_demo/web/views/corepos/products.py @ e20a9b8

Last change on this file since e20a9b8 was e20a9b8, checked in by Lance Edgar <lance@…>, 14 months ago

Add basic CORE-POS table views

  • Property mode set to 100644
File size: 2.6 KB
Line 
1# -*- coding: utf-8; -*-
2"""
3CORE-POS product views
4"""
5
6from __future__ import unicode_literals, absolute_import
7
8from corepos.db import model as corepos
9
10from .master import CoreMasterView
11
12
13class ProductView(CoreMasterView):
14    """
15    Base class for product views.
16    """
17    model_class = corepos.Product
18    model_title = "CORE-POS Product"
19    url_prefix = '/core-pos/products'
20    route_prefix = 'corepos.products'
21
22    labels = {
23        'id': "ID",
24        'upc': "UPC",
25        'pricemethod': "Price Method",
26        'groupprice': "Group Price",
27        'specialpricemethod': "Special Price Method",
28        'specialgroupprice': "Special Group Price",
29        'specialquantity': "Special Quantity",
30        'dept_no': "Dept. No.",
31        'foodstamp': "Food Stamp",
32        'scaleprice': "Scale Price",
33        'mixmatchcode': "Mix Match Code",
34        'tareweight': "Tare Weight",
35        'discounttype': "Discount Type",
36        'unitofmeasure': "Unit of Measure",
37        'qttyEnforced': "Qty. Enforced",
38        'idEnforced': "ID Enforced",
39        'inUse': "In Use",
40        'numflag': "Num. Flag",
41        'subdept': "Subdept. No.",
42        'default_vendor_id': "Default Vendor ID",
43        'current_origin_id': "Current Origin ID",
44    }
45
46    grid_columns = [
47        'upc',
48        'brand',
49        'description',
50        'size',
51        'department',
52        'vendor',
53        'normal_price',
54        'cost',
55    ]
56
57    def configure_grid(self, g):
58        super(ProductView, self).configure_grid(g)
59
60        g.set_joiner('department', lambda q: q.outerjoin(corepos.Department))
61        g.set_sorter('department', corepos.Department.dept_name)
62
63        g.set_joiner('vendor', lambda q: q.outerjoin(corepos.Vendor))
64        g.set_sorter('vendor', corepos.Vendor.vendorName)
65
66        g.filters['upc'].default_active = True
67        g.filters['upc'].default_verb = 'equal'
68
69        g.set_type('cost', 'currency')
70        g.set_type('normal_price', 'currency')
71
72        g.set_sort_defaults('upc')
73
74        g.set_link('upc')
75        g.set_link('brand')
76        g.set_link('description')
77
78    def configure_form(self, f):
79        super(ProductView, self).configure_form(f)
80
81        f.set_type('start_date', 'datetime_local')
82        f.set_type('end_date', 'datetime_local')
83        f.set_type('modified', 'datetime_local')
84
85        f.set_type('normal_price', 'currency')
86        f.set_type('groupprice', 'currency')
87        f.set_type('special_price', 'currency')
88        f.set_type('specialgroupprice', 'currency')
89        f.set_type('cost', 'currency')
90        f.set_type('deposit', 'currency')
91
92
93def includeme(config):
94    ProductView.defaults(config)
Note: See TracBrowser for help on using the repository browser.