Add menu entry for Transaction Details, w/ multi-db support

This commit is contained in:
Lance Edgar 2020-12-01 21:54:55 -06:00
parent 77665dd488
commit 5674ad8e8d
4 changed files with 25 additions and 11 deletions

View file

@ -40,3 +40,6 @@ register(CoreTransSession)
# empty dict for now, this must populated on app startup # empty dict for now, this must populated on app startup
ExtraCoreOfficeSessions = {} ExtraCoreOfficeSessions = {}
# empty dict for now, this must populated on app startup
ExtraCoreTransSessions = {}

View file

@ -123,12 +123,12 @@ def make_corepos_menu(request):
'url': url('corepos.parameters'), 'url': url('corepos.parameters'),
'perm': 'corepos.parameters.list', 'perm': 'corepos.parameters.list',
}, },
# {'type': 'sep'}, {'type': 'sep'},
# { {
# 'title': "Transaction Details", 'title': "Transaction Details",
# 'url': url('corepos.transaction_details'), 'url': url('corepos.transaction_details'),
# 'perm': 'corepos.transaction_details.list', 'perm': 'corepos.transaction_details.list',
# }, },
], ],
} }

View file

@ -53,6 +53,7 @@ class ProductView(CoreOfficeMasterView):
'subdepartment_number': "Subdept. No.", 'subdepartment_number': "Subdept. No.",
'default_vendor_id': "Default Vendor ID", 'default_vendor_id': "Default Vendor ID",
'current_origin_id': "Current Origin ID", 'current_origin_id': "Current Origin ID",
'tax_rate_id': "Tax Rate ID",
} }
grid_columns = [ grid_columns = [
@ -63,6 +64,7 @@ class ProductView(CoreOfficeMasterView):
'department', 'department',
'vendor', 'vendor',
'normal_price', 'normal_price',
'scale',
'cost', 'cost',
] ]

View file

@ -29,14 +29,13 @@ from corepos.db.office_trans import model as coretrans
from rattail_corepos.corepos.importing.db.square import FromSquareToCoreTrans from rattail_corepos.corepos.importing.db.square import FromSquareToCoreTrans
from .master import CoreOfficeMasterView from .master import CoreOfficeMasterView
from tailbone_corepos.db import CoreTransSession from tailbone_corepos.db import CoreTransSession, ExtraCoreTransSessions
class TransactionDetailView(CoreOfficeMasterView): class TransactionDetailView(CoreOfficeMasterView):
""" """
Master view for transaction details. Master view for transaction details.
""" """
Session = CoreTransSession
model_class = coretrans.TransactionDetail model_class = coretrans.TransactionDetail
model_title = "CORE-POS Transaction Detail" model_title = "CORE-POS Transaction Detail"
url_prefix = '/corepos/transaction-details' url_prefix = '/corepos/transaction-details'
@ -58,8 +57,8 @@ class TransactionDetailView(CoreOfficeMasterView):
'register_number', 'register_number',
'transaction_number', 'transaction_number',
'card_number', 'card_number',
'store_row_id',
'upc', 'upc',
'department_number',
'description', 'description',
'quantity', 'quantity',
'unit_price', 'unit_price',
@ -67,6 +66,18 @@ class TransactionDetailView(CoreOfficeMasterView):
'total', 'total',
] ]
@property
def Session(self):
"""
Which session we return will depend on user's "current" engine.
"""
dbkey = self.get_current_engine_dbkey()
if dbkey != 'default' and dbkey in ExtraCoreTransSessions:
return ExtraCoreTransSessions[dbkey]
return CoreTransSession
def get_bulk_delete_session(self): def get_bulk_delete_session(self):
from corepos.trans.db import Session as CoreTransSession from corepos.trans.db import Session as CoreTransSession
@ -75,7 +86,6 @@ class TransactionDetailView(CoreOfficeMasterView):
def configure_grid(self, g): def configure_grid(self, g):
super(TransactionDetailView, self).configure_grid(g) super(TransactionDetailView, self).configure_grid(g)
g.set_type('date_time', 'datetime_local')
g.set_type('quantity', 'quantity') g.set_type('quantity', 'quantity')
g.set_type('unit_price', 'currency') g.set_type('unit_price', 'currency')
g.set_type('discount', 'currency') g.set_type('discount', 'currency')
@ -94,7 +104,6 @@ class TransactionDetailView(CoreOfficeMasterView):
def configure_form(self, f): def configure_form(self, f):
super(TransactionDetailView, self).configure_form(f) super(TransactionDetailView, self).configure_form(f)
f.set_type('date_time', 'datetime_local')
f.set_type('quantity', 'quantity') f.set_type('quantity', 'quantity')
f.set_type('unit_price', 'currency') f.set_type('unit_price', 'currency')
f.set_type('discount', 'currency') f.set_type('discount', 'currency')