here is my model-
from django.db import models
import useraccounts
from librehatti.catalog.models import *
from django.contrib.auth.models import User

class QuotedOrder(models.Model):
    quote_buyer_id = models.ForeignKey(User)
    quote_is_debit = models.BooleanField()
    quote_delivery_address = models.ForeignKey('useraccounts.Address')
    quote_organisation = 
models.ForeignKey('useraccounts.AdminOrganisations')
    quote_date_time = models.DateTimeField(auto_now_add=True)
    def __unicode__(self):
        return '%s' % (self.quote_buyer_id) +' - ' '%s' % 
(self.quote_date_time.strftime ('%b %d, %Y'))

class QuotedItem(models.Model):
    quote_order = models.ForeignKey(PurchaseOrder)
    quote_price = models.IntegerField()
    quote_qty = models.IntegerField()
    quote_discount= models.IntegerField()
    quote_item = models.ForeignKey(Product)
    status = models.IntegerField(default=0)
    def save(self):
        if not self.id:
            self.quote_price = self.quote_item.price * self.quote_qty
        super(QuotedItem,self).save()

    def __unicode__(self):
        return '%s' % (self.quote_item) + ' - ' '%s' % (self.quote_order)


    
    
here is my forms.py-
from django import forms
from librehatti.bills.models import *

#class ConfirmForm(forms.Form):
    #quote_item = forms.CharField()
    #quote_qty = forms.IntegerField()


class ConfirmForm(ModelForm):
     class Meta:
         model = QuotedItem
         fields = ('quote_item', 'quote_qty')


here is my html-file-
<html>
<head>
    <title>display items</title>
</head>
<body>

    <h1>CONFIRM ITEMS</h1>
    <form 
action="/bills/confirm/final/{{quoted_order.quote_buyer_id.username}}/" 
method="POST"> {% csrf_token %}
    <table>
    <tr>
    <th>Item</th>
    <th>Quantity</th>
    </tr>

     {% for i in quoted_item %}
      
    <tr>
         
    <td>Item:<input type="text" name = "quote_item" 
value="{{i.quote_item.name}}"></td>  
    <td>Quantity:<input type="text" name="quote_qty" 
value="{{i.quote_qty}}"></td>
       
   
    </tr> 
      
   {% endfor %} 
   </table

     
    
    <a href="/bills/confirm/final/{{quoted_order.quote_buyer_id.username}}">
    <input type="submit" value="Submit" name="submit"/> </a>
    </form>
</body>
</html>



here is catalog models, where i want to save the values, input by user in 
form-

from django.db import models
from django.forms import ModelForm
import useraccounts
from django.contrib.auth.models import User

class Category(models.Model):
    name = models.CharField(max_length=100)
    parent = models.ForeignKey('self', blank=True, null=True)
    def __unicode__(self):
        return unicode(self.name)


class Product(models.Model):
    name = models.CharField(max_length=100)
    category = models.ForeignKey(Category)
    price = models.IntegerField()
    organisation = models.ForeignKey('useraccounts.AdminOrganisations')
    def __unicode__(self):
        return self.name


class Attributes(models.Model):
    name = models.CharField(max_length=200)
    is_number = models.BooleanField()
    is_string = models.BooleanField()
    def __unicode__(self):
        return self.name


class PurchaseOrder(models.Model):
    buyer_id = models.ForeignKey(User)
    is_debit = models.BooleanField()
    delivery_address = models.ForeignKey('useraccounts.Address')
    organisation = models.ForeignKey('useraccounts.AdminOrganisations')
    date_time = models.DateTimeField(auto_now_add=True)
    def __unicode__(self):
        return '%s' % (self.buyer_id) +' - ' '%s' % (self.date_time.strftime
               ('%b %d, %Y'))


class PurchasedItem(models.Model):
    purchase_order = models.ForeignKey(PurchaseOrder)
    price = models.IntegerField()
    qty = models.IntegerField()
    discount= models.IntegerField()
    item = models.ForeignKey(Product)
    
    def save(self):
        if not self.id:
            self.price = self.item.price * self.qty
        super(PurchasedItem,self).save()

    def __unicode__(self):
        return '%s' % (self.item) + ' - ' '%s' % (self.purchase_order)


class Catalog(models.Model):
    attribute = models.ForeignKey(Attributes)
    value = models.CharField(max_length=200)
    product = models.ForeignKey(Product)
    def __unicode__(self):
        return self.attribute.name;


how to save now? and to generate bills also?

here is bill.html-


<!DOCTYPE html>
<html lang="en">

<head>
    
<meta charset='UTF-8'>

    <link rel="stylesheet" type="text/css" href="style.css" />

    <title>bill</title>
      
</head>

<body>

<div style="text-align:center">
     
<h1>{{quoted_order.quote_organisation.organisation_type}}</h1>
<p>{{quoted_order.quote_organisation.tagline}}</p>       
<h1 style="font-sixe:14px">{{quoted_order.quote_organisation.title}}
</h1>  
<p>{{quoted_order.quote_organisation.address}}</p> 
<p><i>Website :</i> {{quoted_order.quoted_organisation.quote_url}}
 <i>Email:</i>{{quoted_order.quoted_organisation.quote_email1}}  <i>Ph 
:</i> 
{{quoted_order.quote_organisation.telephone}} 
 <i>Fax :</i> {{quoted_order.quote_organisation.fax}}</p>
<br><br>  
<h2 style="text-align:center;font-size:175%;"> Bill</h2>

</div>
<div style="font-size:100%;">
<p>STC No. {{ STC_NO }}</P>
<p>PAN No. {{ PAN_No. }}
</div>

<div style="position:absolute;top:290px;left:35px;">
No. : GNDEC/TCC/B/{{ job_no }}</div>
<div style="position:absolute;top:290px;right:0px;">
Dated : {{quoted_order.date_time}} </div>
<br>
<br>
<br>

</br> To,
</br> {{quote_delivery_address}}
</br> Organisation:{{quote_organisation}}
</br> Buyer Id : {{ purchased_order.buyer_id.username }}
</br> Ref: Your Letter No.{{L_No.}}, 
dated:{{quoted_order.date_time}} , respectively.
 
</br>
</br>
</br>

<table>
<tr>

  <th>S.no.</th>
  <th>Charges For Following</th>
  <th>Price</th>
  <th>Per</th>
  <th>Total</h>

</tr>

{% if QuotedItem %}
{% for i in QuotedItem %}

<tr> 
  <td>{{ forloop.counter }}</td>
  <td>{{ i.quote_item }}</td>
  <td>{{ i.quote_price }} </td>
  <td>{{ i.quote_qty  }}</td> 
  <td>{{ i.total }}</td>
</tr>

{% endfor %}
{% endif %}

<tr>
    <td><b>Total </b></td>
    <td colspan="3"></td>
        <td align="right"> <b>{{total_cost}}</b></td>
</tr> 

</br>
{% if bill.trans_total != None %}
<tr>
     <td>Transportation Charges</td>
     <td colspan="3"></td>
     <td align="right">{{bill.trans_total}}</td>
</tr>

<tr>
     <td>Total Amount</td>
     <td colspan="3"></td>
     <td align="right">{{bill.trans_net_total}}</td>
</tr>
{% endif %}

<tr>
     <td>Service Tax  @ {{ servicetaxprint }}% </td>
     <td colspan="3"></td>
     <td align="right">{{ bill.service_tax }}</td>
</tr>

<tr>
     <td>Education Cess  @ {{ educationtaxprint }}% </td>
     <td colspan="3"></td>
     <td align="right">{{ bill.education_tax }}</td>
</tr>


<tr>
     <td><b>G.Total (Rupees {{ net_total_eng }} only)</b> </td>
     <td colspan="3"></td>
     <td  align="right"><b>{{ cdftotal }} {{ bill.net_total}}</b></td>
</tr>    

       
</table>


<div style="position:absolute;right:30px;top:1050px;">

<!-- Dean is liable to change-->
<p> Dean Training And Consultancy Cell </p> 
</div>

<br><div style="position:absolute;top:1050px;">
I/We here by agree to the terms & conditions as mentioned above</div>

<div style="position:absolute;right:30px;top:1100px;">
(Signature of Client/Deptt. Representative)</div>
</body>

</html>



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8326cb3a-e338-4649-bede-7bdc7ff1141c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to