Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

New created salescontract documents like invoices and quotes will now…

… calculate the total salescontract prices direclty after saving, the action 'recalculate prices' is no longer required - but still available
  • Loading branch information...
commit efc87a2421abacebf4f16db77caeb4e76f640f37 1 parent 441c153
@scaphilo authored
Showing with 34 additions and 2 deletions.
  1. +33 −1 crm/admin.py
  2. +1 −1  crm/models.py
View
34 crm/admin.py
@@ -267,7 +267,23 @@ class OptionInvoice(admin.ModelAdmin):
inlines = [SalesContractInlinePosition, SalesContractPostalAddress, SalesContractPhoneAddress, SalesContractEmailAddress, InlineBookings]
pluginProcessor = PluginProcessor()
inlines.extend(pluginProcessor.getPluginAdditions("invoiceInlines"))
-
+
+ def response_add(self, request, new_object):
+ obj = self.after_saving_model_and_related_inlines(request, new_object)
+ return super(OptionInvoice, self).response_add(request, obj)
+
+ def response_change(self, request, new_object):
+ obj = self.after_saving_model_and_related_inlines(request, new_object)
+ return super(OptionInvoice, self).response_add(request, obj)
+
+ def after_saving_model_and_related_inlines(self, request, obj):
+ try:
+ obj.recalculatePrices(date.today())
+ self.message_user(request, "Successfully calculated Prices")
+ except Product.NoPriceFound as e :
+ self.message_user(request, "Unsuccessfull in updating the Prices "+ e.__str__())
+ return obj
+
def save_model(self, request, obj, form, change):
if (change == True):
obj.lastmodifiedby = request.user
@@ -353,7 +369,23 @@ class OptionQuote(admin.ModelAdmin):
inlines = [SalesContractInlinePosition, SalesContractPostalAddress, SalesContractPhoneAddress, SalesContractEmailAddress]
pluginProcessor = PluginProcessor()
inlines.extend(pluginProcessor.getPluginAdditions("quoteInlines"))
+
+ def response_add(self, request, new_object):
+ obj = self.after_saving_model_and_related_inlines(request, new_object)
+ return super(OptionQuote, self).response_add(request, obj)
+
+ def response_change(self, request, new_object):
+ obj = self.after_saving_model_and_related_inlines(request, new_object)
+ return super(OptionQuote, self).response_change(request, obj)
+ def after_saving_model_and_related_inlines(self, request, obj):
+ try:
+ obj.recalculatePrices(date.today())
+ self.message_user(request, "Successfully calculated Prices")
+ except Product.NoPriceFound as e :
+ self.message_user(request, "Unsuccessfull in updating the Prices "+ e.__str__())
+ return obj
+
def save_model(self, request, obj, form, change):
if (change == True):
obj.lastmodifiedby = request.user
View
2  crm/models.py
@@ -5,7 +5,6 @@
from const.postaladdressprefix import *
from const.purpose import *
from const.status import *
-from django.db.models import signals
from datetime import *
from django.utils.translation import ugettext as _
from decimal import Decimal
@@ -913,3 +912,4 @@ class Meta:
def __unicode__(self):
return str(self.email)
+

1 comment on commit efc87a2

@okuznetsov

Where can i find requirements.txt?

Please sign in to comment.
Something went wrong with that request. Please try again.