diff options
author | Filipp Lepalaan <filipp@mac.com> | 2015-09-29 11:01:51 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2015-09-29 11:01:51 +0300 |
commit | 450667c5135c2e933682d6b825da992a1f4bff2f (patch) | |
tree | cc8966611557715619eab5c0e8b89cf06bb8a6ca | |
parent | 396a3458eda07858b1142477666e8af134a00db3 (diff) | |
download | Servo-450667c5135c2e933682d6b825da992a1f4bff2f.tar.gz Servo-450667c5135c2e933682d6b825da992a1f4bff2f.tar.bz2 Servo-450667c5135c2e933682d6b825da992a1f4bff2f.zip |
Added Location field to Invoice
-rw-r--r-- | servo/migrations/0032_auto_20150929_1101.py | 24 | ||||
-rw-r--r-- | servo/models/invoices.py | 24 | ||||
-rw-r--r-- | servo/views/device.py | 2 |
3 files changed, 44 insertions, 6 deletions
diff --git a/servo/migrations/0032_auto_20150929_1101.py b/servo/migrations/0032_auto_20150929_1101.py new file mode 100644 index 0000000..e7b17ec --- /dev/null +++ b/servo/migrations/0032_auto_20150929_1101.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('servo', '0031_auto_20150929_0010'), + ] + + operations = [ + migrations.AddField( + model_name='invoice', + name='location', + field=models.ForeignKey(blank=True, editable=False, to='servo.Location', null=True), + ), + migrations.AlterField( + model_name='invoice', + name='is_paid', + field=models.BooleanField(default=False, verbose_name='Paid'), + ), + ] diff --git a/servo/models/invoices.py b/servo/models/invoices.py index 7fa4287..8d5d8f2 100644 --- a/servo/models/invoices.py +++ b/servo/models/invoices.py @@ -8,8 +8,8 @@ from django.utils.translation import ugettext_lazy as _ from django.dispatch import receiver from django.db.models.signals import post_save -from servo import defaults -from servo.models import User, Customer, Order, ServiceOrderItem, AbstractOrderItem +from servo.models import (User, Customer, Order, Location, + AbstractOrderItem, ServiceOrderItem,) class Invoice(models.Model): @@ -32,9 +32,15 @@ class Invoice(models.Model): verbose_name=_("Payment Method") ) - is_paid = models.BooleanField(default=False, verbose_name=_("paid")) + is_paid = models.BooleanField(default=False, verbose_name=_("Paid")) paid_at = models.DateTimeField(null=True, editable=False) order = models.ForeignKey(Order, editable=False) + location = models.ForeignKey( + Location, + null=True, + blank=True, + editable=False + ) customer = models.ForeignKey( Customer, null=True, @@ -42,8 +48,8 @@ class Invoice(models.Model): on_delete=models.SET_NULL ) - # We remember the following the following so that the customer info - # on the invoice doesn't change if the customer is modified or deleted + # We remember the following so that the customer info on the invoice + # doesn't change if the customer is modified or deleted customer_name = models.CharField( max_length=255, default=_("Walk-in"), @@ -97,6 +103,9 @@ class Invoice(models.Model): return [x.get_method_display() for x in payments] def dispatch(self, products): + """ + Dispatches the products in this invoice from the inventory + """ for p in products: soi = ServiceOrderItem.objects.get(pk=p) InvoiceItem.from_soi(soi, self) @@ -109,6 +118,11 @@ class Invoice(models.Model): from django.core.urlresolvers import reverse return reverse("invoices-view_invoice", args=[self.pk]) + def save(self, *args, **kwargs): + if self.location is None: + self.location = self.order.location + return super(Invoice, self).save(*args, **kwargs) + class Meta: ordering = ('-id',) app_label = 'servo' diff --git a/servo/views/device.py b/servo/views/device.py index a955b1c..9babbd2 100644 --- a/servo/views/device.py +++ b/servo/views/device.py @@ -232,7 +232,7 @@ def diagnostics(request, pk): diagnostics = DiagnosticResults(diagnostics) return render(request, "devices/diagnostic_ios.html", locals()) return render(request, "devices/diagnostic_results.html", locals()) - except gsxws.GsxError, e: + except gsxws.GsxError as e: return render(request, "devices/diagnostic_error.html", {'error': e}) return render(request, "devices/diagnostics.html", locals()) |