Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added missing changes

  • Loading branch information...
commit 64ccf5cdf8548ab7d47b245b2af46565c79fb129 1 parent ac11d70
@scaphilo authored
View
24 crm/admin.py
@@ -4,14 +4,14 @@
from django.core.urlresolvers import reverse
from datetime import date
from crm.models import *
+from crm.views import *
+from plugin import *
from django.utils.translation import ugettext as _
from django.contrib import admin
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.core.servers.basehttp import FileWrapper
-
-
class ContractPostalAddress(admin.StackedInline):
model = PostalAddressForContract
@@ -181,6 +181,8 @@ class OptionContract(admin.ModelAdmin):
}),
)
inlines = [ContractPostalAddress, ContractPhoneAddress, ContractEmailAddress, InlineQuote, InlineInvoice, InlinePurchaseOrder]
+ pluginProcessor = PluginProcessor()
+ inlines.extend(pluginProcessor.getPluginAdditions("contractInlines"))
def createPurchaseOrder(self, request, queryset):
for obj in queryset:
@@ -215,6 +217,8 @@ def save_model(self, request, obj, form, change):
obj.save()
actions = ['createQuote', 'createInvoice', 'createPurchaseOrder']
+ pluginProcessor = PluginProcessor()
+ actions.extend(pluginProcessor.getPluginAdditions("contractActions"))
class PurchaseOrderInlinePosition(admin.TabularInline):
@@ -242,6 +246,8 @@ class OptionInvoice(admin.ModelAdmin):
)
save_as = True
inlines = [SalesContractInlinePosition, SalesContractPostalAddress, SalesContractPhoneAddress, SalesContractEmailAddress]
+ pluginProcessor = PluginProcessor()
+ inlines.extend(pluginProcessor.getPluginAdditions("invoiceInlines"))
def save_model(self, request, obj, form, change):
if (change == True):
@@ -292,6 +298,8 @@ def registerPaymentInAccounting(self, request, queryset):
registerPaymentInAccounting.short_description = _("Register Payment in Accounting")
actions = ['recalculatePrices', 'createDeliveryOrderPDF', 'createInvoicePDF', 'registerInvoiceInAccounting', 'unregisterInvoiceInAccounting', 'registerPaymentInAccounting']
+ pluginProcessor = PluginProcessor()
+ inlines.extend(pluginProcessor.getPluginAdditions("invoiceActions"))
class OptionQuote(admin.ModelAdmin):
@@ -308,6 +316,8 @@ class OptionQuote(admin.ModelAdmin):
)
save_as = True
inlines = [SalesContractInlinePosition, SalesContractPostalAddress, SalesContractPhoneAddress, SalesContractEmailAddress]
+ pluginProcessor = PluginProcessor()
+ inlines.extend(pluginProcessor.getPluginAdditions("quoteInlines"))
def save_model(self, request, obj, form, change):
if (change == True):
@@ -348,6 +358,8 @@ def createPurchaseConfirmationPDF(self, request, queryset):
createPurchaseConfirmationPDF.short_description = _("Create PDF of Purchase Confirmation")
actions = ['recalculatePrices', 'createInvoice', 'createQuotePDF', 'createPurchaseConfirmationPDF']
+ pluginProcessor = PluginProcessor()
+ inlines.extend(pluginProcessor.getPluginAdditions("quoteActions"))
class OptionPurchaseOrder(admin.ModelAdmin):
list_display = ('id', 'description', 'contract', 'supplier', 'status', 'currency', 'staff', 'lastmodifiedby', 'lastCalculatedPrice', 'lastPricingDate', 'lastmodification')
@@ -373,9 +385,13 @@ def createPurchseOrderPDF(self, request, queryset):
createPurchseOrderPDF.short_description = _("Create PDF of Purchase Order")
actions = ['createPurchseOrderPDF']
+ pluginProcessor = PluginProcessor()
+ actions.extend(pluginProcessor.getPluginAdditions("purchaseOrderActions"))
save_as = True
inlines = [PurchaseOrderInlinePosition, PurchaseOrderPostalAddress, PurchaseOrderPhoneAddress, PurchaseOrderEmailAddress]
+ pluginProcessor = PluginProcessor()
+ inlines.extend(pluginProcessor.getPluginAdditions("purchaseOrderInlines"))
class ProductPrice(admin.TabularInline):
model = Price
@@ -448,6 +464,8 @@ class OptionCustomer(admin.ModelAdmin):
ordering = ('id', 'name')
search_fields = ('id', 'name')
inlines = [ContactPostalAddress, ContactPhoneAddress, ContactEmailAddress]
+ pluginProcessor = PluginProcessor()
+ inlines.extend(pluginProcessor.getPluginAdditions("customerInline"))
def createContract(self, request, queryset):
for obj in queryset:
@@ -478,6 +496,8 @@ def save_model(self, request, obj, form, change):
obj.staff = request.user
obj.save()
actions = ['createContract', 'createInvoice', 'createQuote']
+ pluginProcessor = PluginProcessor()
+ inlines.extend(pluginProcessor.getPluginAdditions("customerActions"))
class OptionCustomerGroup(admin.ModelAdmin):
list_display = ('id', 'name' )
View
22 crm/models.py
@@ -21,18 +21,18 @@
import copy
class Currency (models.Model):
- description = models.CharField(verbose_name = _("Description"), max_length=100)
- shortName = models.CharField(verbose_name = _("Displayed Name After Price In The Position"), max_length=3)
- rounding = models.DecimalField(max_digits=5, decimal_places=2, verbose_name = _("Rounding"), blank=True, null=True)
+ description = models.CharField(verbose_name = _("Description"), max_length=100)
+ shortName = models.CharField(verbose_name = _("Displayed Name After Price In The Position"), max_length=3)
+ rounding = models.DecimalField(max_digits=5, decimal_places=2, verbose_name = _("Rounding"), blank=True, null=True)
- def __unicode__(self):
- return self.shortName
-
- class Meta:
- app_label = "crm"
- #app_label_koalix = _('Customer Relationship Management (CRM)')
- verbose_name = _('Currency')
- verbose_name_plural = _('Currency')
+ def __unicode__(self):
+ return self.shortName
+
+ class Meta:
+ app_label = "crm"
+ #app_label_koalix = _('Customer Relationship Management (CRM)')
+ verbose_name = _('Currency')
+ verbose_name_plural = _('Currency')
class PostalAddress(models.Model):
prefix = models.CharField(max_length=1, choices=POSTALADDRESSPREFIX, verbose_name = _("Prefix"), blank=True, null=True)
View
10 crm/views.py
@@ -6,6 +6,7 @@
from exceptions import TemplateSetMissing
from exceptions import UserExtensionMissing
from django.core.servers.basehttp import FileWrapper
+from django.utils.translation import ugettext as _
def createQuotePDF(request, quoteid):
try:
@@ -59,4 +60,13 @@ def createPurchaseOrderPDF(request, purchaseorderid):
def selectaddress(invoiceid):
invoice = Invoice.objects.get(id=invoiceid)
address = invoice.contract
+
+def test(self, request, queryset):
+ for obj in queryset:
+ invoice = obj.createInvoice()
+ self.message_user(request, _("Invoice created"))
+ response = HttpResponseRedirect('/admin/crm/invoice/'+str(invoice.id))
+ return response
+test.short_description = _("Test")
+
View
4 settings.default.py
@@ -87,6 +87,10 @@
'/var/www/koalixcrm/templates'
)
+KOALIXCRM_PLUGINS = (
+ 'subscriptions',
+)
+
INSTALLED_APPS = (
'grappelli.dashboard',
'grappelli',
View
51 subscriptions/admin.py
@@ -3,7 +3,7 @@
from django import forms
from django.core.urlresolvers import reverse
from datetime import date
-from crm.models import *
+from crm import models as crmmodels
from crm.admin import *
from django.utils.translation import ugettext as _
from django.contrib import admin
@@ -11,6 +11,7 @@
from django.http import HttpResponseRedirect
from django.core.servers.basehttp import FileWrapper
from subscriptions.models import *
+
class AdminSubscriptionEvent(admin.TabularInline):
model = SubscriptionEvent
@@ -23,15 +24,24 @@ class AdminSubscriptionEvent(admin.TabularInline):
)
allow_add = True
+class InlineSubscription(admin.TabularInline):
+ model = Subscription
+ extra = 1
+ classes = ('collapse-open',)
+ fieldsets = (
+ (_('Basics'), {
+ 'fields': ( 'contract', 'subscriptiontype' )
+ }),
+ )
+ allow_add = False
+
class OptionSubscription(admin.ModelAdmin):
- list_display = ('id', 'defaultcustomer','defaultcurrency','subscriptiontype' , 'startdate', 'cancelingdate', 'staff', 'lastmodification', 'lastmodifiedby')
- list_display_links = ('id', )
- list_filter = ('defaultcustomer', 'subscriptiontype')
- ordering = ('id', 'defaultcustomer', 'subscriptiontype')
- search_fields = ('id', 'defaultcustomer')
+ list_display = ('id', 'contract', 'subscriptiontype' , )
+ ordering = ('id', 'contract', 'subscriptiontype')
+ search_fields = ('id', 'contract', )
fieldsets = (
(_('Basics'), {
- 'fields': ('defaultcustomer','defaultcurrency','subscriptiontype' , 'startdate', 'cancelingdate', 'staff',)
+ 'fields': ('contract', 'subscriptiontype' , )
}),
)
inlines = [AdminSubscriptionEvent]
@@ -42,6 +52,12 @@ def createInvoice(self, request, queryset):
response = HttpResponseRedirect('/admin/crm/invoice/'+str(invoice.id))
return response
+ def createQuote(self, request, queryset):
+ for obj in queryset:
+ invoice = obj.createInvoice()
+ response = HttpResponseRedirect('/admin/crm/invoice/'+str(invoice.id))
+ return response
+
def save_model(self, request, obj, form, change):
if (change == True):
obj.lastmodifiedby = request.user
@@ -65,7 +81,26 @@ class OptionSubscriptionType(admin.ModelAdmin):
'fields': ('productNumber', 'title', 'description', 'defaultunit', 'tax', 'accoutingProductCategorie', 'cancelationPeriod', 'automaticContractExtension', 'automaticContractExtensionReminder', 'minimumDuration', 'paymentIntervall', 'contractDocument')
}),
)
- inlines = [ProductPrice, ProductUnitTransform]
+
+
+class PluginActions(object):
+ @classmethod
+ def createSubscription(a, b, request, queryset):
+ for contract in queryset:
+ subscription = Subscription()
+ subscription.createSubscriptionFromContract(crmmodels.Contract.objects.get(id=contract.id))
+ response = HttpResponseRedirect('/admin/crm/subscription/'+str(subscription.id))
+ return response
+
+class KoalixcrmPluginInterface(object):
+ contractInlines = [InlineSubscription]
+ contractActions = [PluginActions.createSubscription]
+ invoiceInlines = []
+ invoiceActions = []
+ quoteInlines = []
+ quoteActions = []
+ customerInlines = []
+ customerActions = []
admin.site.register(Subscription, OptionSubscription)
admin.site.register(SubscriptionType, OptionSubscriptionType)
View
39 subscriptions/models.py
@@ -2,15 +2,42 @@
from django.utils.translation import ugettext as _
from filebrowser.fields import FileBrowseField
from const.events import *
+from datetime import *
from crm import models as crmmodels
-class Subscription(crmmodels.Contract):
- subscriptiontype = models.ForeignKey('SubscriptionType', verbose_name=_('Subscription Type'))
- startdate = models.DateField(verbose_name = _("Start Date"), blank=True, null=True)
- cancelingdate = models.DateField(verbose_name = _("Canceling Date"), blank=True, null=True)
-
+class Subscription(models.Model):
+ contract = models.ForeignKey(crmmodels.Contract, verbose_name=_('Subscription Type'))
+ subscriptiontype = models.ForeignKey('SubscriptionType', verbose_name=_('Subscription Type'), null=True)
+
+ def createSubscriptionFromContract(self, contract):
+ self.contract = contract
+ self.save()
+ return self
+
+ def createQuote(self):
+ quote = Quote()
+ quote.contract = self.contract
+ quote.discount = 0
+ quote.staff = self.contract.staff
+ quote.customer = self.contract.defaultcustomer
+ quote.status = 'C'
+ quote.currency = self.contract.defaultcurrency
+ quote.validuntil = date.today().__str__()
+ quote.dateofcreation = date.today().__str__()
+ quote.save()
+ return quote
+
def createInvoice(self):
- Invoice()
+ invoice = crmmodels.Invoice()
+ invoice.contract = self.contract
+ invoice.discount = 0
+ invoice.staff = self.contract.staff
+ invoice.customer = self.contract.defaultcustomer
+ invoice.status = 'C'
+ invoice.currency = self.contract.defaultcurrency
+ invoice.payableuntil = date.today()+timedelta(days=self.contract.defaultcustomer.defaultCustomerBillingCycle.timeToPaymentDate)
+ invoice.dateofcreation = date.today().__str__()
+ invoice.save()
return invoice
class Meta:
Please sign in to comment.
Something went wrong with that request. Please try again.