From 5674ad8e8dfef52b4754fafa81282555ddb5bc86 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 1 Dec 2020 21:54:55 -0600 Subject: [PATCH] Add menu entry for Transaction Details, w/ multi-db support --- tailbone_corepos/db.py | 3 +++ tailbone_corepos/menus.py | 12 ++++++------ tailbone_corepos/views/corepos/products.py | 2 ++ .../views/corepos/transactions.py | 19 ++++++++++++++----- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/tailbone_corepos/db.py b/tailbone_corepos/db.py index b11b65d..20459ef 100644 --- a/tailbone_corepos/db.py +++ b/tailbone_corepos/db.py @@ -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 = {} diff --git a/tailbone_corepos/menus.py b/tailbone_corepos/menus.py index 4487dd6..2f650c7 100644 --- a/tailbone_corepos/menus.py +++ b/tailbone_corepos/menus.py @@ -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', + }, ], } diff --git a/tailbone_corepos/views/corepos/products.py b/tailbone_corepos/views/corepos/products.py index 2033a0e..9206118 100644 --- a/tailbone_corepos/views/corepos/products.py +++ b/tailbone_corepos/views/corepos/products.py @@ -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', ] diff --git a/tailbone_corepos/views/corepos/transactions.py b/tailbone_corepos/views/corepos/transactions.py index 7da84b9..7188d63 100644 --- a/tailbone_corepos/views/corepos/transactions.py +++ b/tailbone_corepos/views/corepos/transactions.py @@ -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')