|
|
|
|
@ -1,13 +1,11 @@ |
|
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
import simplejson as json |
|
|
|
|
|
|
|
|
|
from django.shortcuts import render, get_object_or_404, redirect |
|
|
|
|
from django.http import HttpResponseBadRequest, HttpResponse |
|
|
|
|
from django.core import serializers |
|
|
|
|
|
|
|
|
|
# use django.apps.apps.get_model since Django 1.9 |
|
|
|
|
from django.db.models.loading import get_model |
|
|
|
|
from django.views.decorators.csrf import csrf_protect |
|
|
|
|
|
|
|
|
|
from docs.models import Invoice |
|
|
|
|
from customer.utils import raise_if_no_profile |
|
|
|
|
@ -24,7 +22,7 @@ def get_invoices(request, client_id=None): |
|
|
|
|
if client_id: |
|
|
|
|
invoices = invoices.filter(client_id=client_id) |
|
|
|
|
|
|
|
|
|
invoices = {invoice.id: '№ %s от %s' % (invoice.doc_num, invoice.doc_date) for invoice in invoices} |
|
|
|
|
invoices = {invoice.id: invoice.to_string_for_json() for invoice in invoices} |
|
|
|
|
|
|
|
|
|
return HttpResponse(json.dumps(invoices), content_type='application/json') |
|
|
|
|
|
|
|
|
|
@ -49,7 +47,8 @@ def get_client_by_invoice(request, invoice_id): |
|
|
|
|
|
|
|
|
|
invoice = Invoice.objects.get(company=request.user.profile, pk=invoice_id) |
|
|
|
|
|
|
|
|
|
return HttpResponse(json.dumps([invoice.client.id, invoice.client.name]), content_type='application/json') |
|
|
|
|
return HttpResponse(json.dumps([invoice.client.id, invoice.client.name]), |
|
|
|
|
content_type='application/json') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def toggle_doc_status(request, doc_type, doc_id, doc_attr): |
|
|
|
|
|