From d28029672fc1b5c2d04fc73d8a3b7ba009eb0388 Mon Sep 17 00:00:00 2001 From: Tanshu Date: Tue, 18 Dec 2012 17:55:57 +0530 Subject: [PATCH] Added TryCatch to get_grid as it may generate errors. --- brewman/brewman/views/services/cost_center.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/brewman/brewman/views/services/cost_center.py b/brewman/brewman/views/services/cost_center.py index 65578c87..50b8380b 100644 --- a/brewman/brewman/views/services/cost_center.py +++ b/brewman/brewman/views/services/cost_center.py @@ -6,17 +6,20 @@ import uuid from pyramid.view import view_config from brewman.models import DBSession +from brewman.models.validation_exception import TryCatchFunction from brewman.models.voucher import Voucher, Journal, VoucherType @view_config(route_name='api_issues_grid', request_param='Source', renderer='json', permission='Issue') +@TryCatchFunction def grid_date(request): date = datetime.datetime.strptime(request.matchdict['date'], '%d-%b-%Y') return get_grid(date, uuid.UUID(request.GET['Source']), uuid.UUID(request.GET['Destination'])) @view_config(route_name='api_issues_grid', renderer='json', permission='Issue') +@TryCatchFunction def grid_voucher(request): voucher = Voucher.by_id(uuid.UUID(request.matchdict['date'])) source = [j.cost_center_id for j in voucher.journals if j.debit == -1]