예제 #1
0
 def create_pdf(self):
     #shipping.update_acknowledgement_data()
     #Initialize and create pdf
     pdf = ShippingPDF(customer=self.customer, shipping=self,
                       products=self.items.all().order_by('id'))
     filename = pdf.create()
     
     return filename
예제 #2
0
    def create_pdf(self):
        #shipping.update_acknowledgement_data()
        #Initialize and create pdf
        pdf = ShippingPDF(customer=self.customer,
                          shipping=self,
                          products=self.items.all().order_by('id'),
                          employee=self.employee)
        filename = pdf.create()

        return filename
예제 #3
0
    def create(cls, user=None, override_id=False, **kwargs):
        data = kwargs
        shipping = cls()
        if override_id and 'id' in kwargs:
            shipping.id = kwargs['id']
        #Set the data from the shippping
        shipping.acknowledgement = Acknowledgement.objects.get(
            id=data["acknowledgement"]['id'])
        try:
            shipping.customer = Customer.objects.get(id=data['customer']['id'])
        except KeyError:
            shipping.customer = shipping.acknowledgement.customer
        shipping.employee = user
        try:
            shipping.delivery_date = data["delivery_date"]
        except KeyError:
            shipping.delivery_date = shipping.acknowledgement.delivery_date

        if "comments" in data:
            shipping.comments = data["comments"]
        else:
            shipping.comments = shipping.acknowledgement.remarks

        shipping.save()

        try:
            shipping.process_items(kwargs['items'])
        except:
            shipping.process_items([{
                'id': item.id
            } for item in shipping.acknowledgement.items.all()])

        #shipping.update_acknowledgement_data()
        #Initialize and create pdf
        pdf = ShippingPDF(customer=shipping.customer,
                          shipping=shipping,
                          products=shipping.item_set.all().order_by('id'))
        shipping_filename = pdf.create()
        #Upload and return the url
        shipping.pdf = S3Object.create(
            shipping_filename, "shipping/Shipping-{0}.pdf".format(shipping.id),
            'document.dellarobbiathailand.com')
        shipping.save()

        return shipping
예제 #4
0
    def create(cls, user=None, override_id=False, **kwargs):
        data = kwargs
        shipping = cls()
        if override_id and 'id' in kwargs:
            shipping.id = kwargs['id']
        #Set the data from the shippping
        shipping.acknowledgement = Acknowledgement.objects.get(id=data["acknowledgement"]['id'])
        try:
            shipping.customer = Customer.objects.get(id=data['customer']['id'])
        except KeyError:
            shipping.customer = shipping.acknowledgement.customer
        shipping.employee = user
        try:
            shipping.delivery_date = data["delivery_date"]
        except KeyError:
            shipping.delivery_date = shipping.acknowledgement.delivery_date
            
        if "comments" in data:
            shipping.comments = data["comments"]
        else:
            shipping.comments = shipping.acknowledgement.remarks
            
        shipping.save()

        try:
            shipping.process_items(kwargs['items'])
        except:
            shipping.process_items([{'id':item.id} for item in shipping.acknowledgement.items.all()])

        #shipping.update_acknowledgement_data()
        #Initialize and create pdf
        pdf = ShippingPDF(customer=shipping.customer, shipping=shipping,
                          products=shipping.item_set.all().order_by('id'))
        shipping_filename = pdf.create()
        #Upload and return the url
        shipping.pdf = S3Object.create(shipping_filename,
                                   "shipping/Shipping-{0}.pdf".format(shipping.id),
                                   'document.dellarobbiathailand.com')
        shipping.save()

        return shipping