Permalink
Browse files

updated the pdf creation of the crm application according to the acco…

…unting application. Now the crm application also provides error messages when fop pdf creation fails. added an initial migration schemamigration data for the crm and for the djangoUserExtension
  • Loading branch information...
1 parent db95dab commit 7dea06ad27d72d17f3ecfc3a43e560fda032510c @scaphilo committed Jan 2, 2013
View
@@ -22,12 +22,23 @@ class AccountingPeriod(models.Model):
@staticmethod
def getCurrentValidAccountingPeriod():
- currentValidAccountingPeriod = None
- for accountingPeriod in AccountingPeriod.objects.all():
- if accountingPeriod.begin < date.today() and accountingPeriod.end > date.today():
- return accountingPeriod
- if currentValidAccountingPeriod == None:
- raise NoFeasableAccountingPeriodFound()
+ """Returns the accounting period that is currently valid. Valid is an accountingPeriod when the current date
+ lies between begin and end of the accountingPeriod
+
+ Args:
+ no arguments
+
+ Returns:
+ accoutingPeriod (AccoutingPeriod)
+
+ Raises:
+ NoFeasableAccountingPeriodFound when there is no valid accounting Period"""
+ currentValidAccountingPeriod = None
+ for accountingPeriod in AccountingPeriod.objects.all():
+ if accountingPeriod.begin < date.today() and accountingPeriod.end > date.today():
+ return accountingPeriod
+ if currentValidAccountingPeriod == None:
+ raise NoFeasableAccountingPeriodFound()
def createPDF(self, raisedbyuser, whatToCreate):
userExtension = djangoUserExtension.models.UserExtension.objects.filter(user=raisedbyuser.id)
View
@@ -283,15 +283,15 @@ def recalculatePrices(self, request, queryset):
recalculatePrices.short_description = _("Recalculate Prices")
def createInvoicePDF(self, request, queryset):
- for obj in queryset:
- response = HttpResponseRedirect('/export/invoice/'+str(obj.id))
- return response
+ for obj in queryset:
+ response = exportPDF(self, request, obj, "invoice", "/admin/crm/invoice/")
+ return response
createInvoicePDF.short_description = _("Create PDF of Invoice")
def createDeliveryOrderPDF(self, request, queryset):
for obj in queryset:
- response = HttpResponseRedirect('/export/deilveryorder/'+str(obj.id))
- return response
+ response = exportPDF(self, request, obj, "deliveryorder", "/admin/crm/invoice/")
+ return response
createDeliveryOrderPDF.short_description = _("Create PDF of Delivery Order")
def registerInvoiceInAccounting(self, request, queryset):
@@ -300,11 +300,11 @@ def registerInvoiceInAccounting(self, request, queryset):
self.message_user(request, _("Successfully registered Invoice in the Accounting"))
registerInvoiceInAccounting.short_description = _("Register Invoice in Accounting")
- def unregisterInvoiceInAccounting(self, request, queryset):
- for obj in queryset:
- obj.createPDF(deliveryorder=True)
- self.message_user(request, _("Successfully unregistered Invoice in the Accounting"))
- unregisterInvoiceInAccounting.short_description = _("Unregister Invoice in Accounting")
+ #def unregisterInvoiceInAccounting(self, request, queryset):
+ #for obj in queryset:
+ #obj.createPDF(deliveryorder=True)
+ #self.message_user(request, _("Successfully unregistered Invoice in the Accounting"))
+ #unregisterInvoiceInAccounting.short_description = _("Unregister Invoice in Accounting")
def registerPaymentInAccounting(self, request, queryset):
for obj in queryset:
@@ -362,14 +362,14 @@ def createInvoice(self, request, queryset):
def createQuotePDF(self, request, queryset):
for obj in queryset:
- response = HttpResponseRedirect('/export/quote/'+str(obj.id))
- return response
+ response = exportPDF(self, request, obj, "quote", "/admin/crm/quote/")
+ return response
createQuotePDF.short_description = _("Create PDF of Quote")
def createPurchaseConfirmationPDF(self, request, queryset):
for obj in queryset:
- response = HttpResponseRedirect('/export/purchaseconfirmation/'+str(obj.id))
- return response
+ response = exportPDF(self, request, obj, "purchaseconfirmation", "/admin/crm/quote/")
+ return response
createPurchaseConfirmationPDF.short_description = _("Create PDF of Purchase Confirmation")
actions = ['recalculatePrices', 'createInvoice', 'createQuotePDF', 'createPurchaseConfirmationPDF']
@@ -390,13 +390,17 @@ class OptionPurchaseOrder(admin.ModelAdmin):
)
def save_model(self, request, obj, form, change):
- obj.staff = request.user
- obj.save()
+ if (change == True):
+ obj.lastmodifiedby = request.user
+ else:
+ obj.lastmodifiedby = request.user
+ obj.staff = request.user
+ obj.save()
def createPurchseOrderPDF(self, request, queryset):
for obj in queryset:
- response = HttpResponseRedirect('/export/purchaseorder/'+str(obj.id))
- return response
+ response = exportPDF(self, request, obj, "purchaseorder", "/admin/crm/purchaseorder/")
+ return response
createPurchseOrderPDF.short_description = _("Create PDF of Purchase Order")
actions = ['createPurchseOrderPDF']
Oops, something went wrong.

0 comments on commit 7dea06a

Please sign in to comment.