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
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'),
'perm': 'corepos.parameters.list',
},
# {'type': 'sep'},
# {
# 'title': "Transaction Details",
# 'url': url('corepos.transaction_details'),
# 'perm': 'corepos.transaction_details.list',
# },
{'type': 'sep'},
{
'title': "Transaction Details",
'url': url('corepos.transaction_details'),
'perm': 'corepos.transaction_details.list',
},
],
}

View file

@ -53,6 +53,7 @@ class ProductView(CoreOfficeMasterView):
'subdepartment_number': "Subdept. No.",
'default_vendor_id': "Default Vendor ID",
'current_origin_id': "Current Origin ID",
'tax_rate_id': "Tax Rate ID",
}
grid_columns = [
@ -63,6 +64,7 @@ class ProductView(CoreOfficeMasterView):
'department',
'vendor',
'normal_price',
'scale',
'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 .master import CoreOfficeMasterView
from tailbone_corepos.db import CoreTransSession
from tailbone_corepos.db import CoreTransSession, ExtraCoreTransSessions
class TransactionDetailView(CoreOfficeMasterView):
"""
Master view for transaction details.
"""
Session = CoreTransSession
model_class = coretrans.TransactionDetail
model_title = "CORE-POS Transaction Detail"
url_prefix = '/corepos/transaction-details'
@ -58,8 +57,8 @@ class TransactionDetailView(CoreOfficeMasterView):
'register_number',
'transaction_number',
'card_number',
'store_row_id',
'upc',
'department_number',
'description',
'quantity',
'unit_price',
@ -67,6 +66,18 @@ class TransactionDetailView(CoreOfficeMasterView):
'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):
from corepos.trans.db import Session as CoreTransSession
@ -75,7 +86,6 @@ class TransactionDetailView(CoreOfficeMasterView):
def configure_grid(self, g):
super(TransactionDetailView, self).configure_grid(g)
g.set_type('date_time', 'datetime_local')
g.set_type('quantity', 'quantity')
g.set_type('unit_price', 'currency')
g.set_type('discount', 'currency')
@ -94,7 +104,6 @@ class TransactionDetailView(CoreOfficeMasterView):
def configure_form(self, f):
super(TransactionDetailView, self).configure_form(f)
f.set_type('date_time', 'datetime_local')
f.set_type('quantity', 'quantity')
f.set_type('unit_price', 'currency')
f.set_type('discount', 'currency')