Exemplo n.º 1
0
 def attach_sales_document_positions(self, calling_model):
     if isinstance(calling_model, SalesDocument):
         sales_document_positions = SalesDocumentPosition.objects.filter(
             sales_document=calling_model.id)
         for sales_document_position in list(sales_document_positions):
             new_position = SalesDocumentPosition()
             new_position.create_position(sales_document_position, self)
Exemplo n.º 2
0
 def serialize_to_xml(self):
     from koalixcrm.crm.models import PostalAddressForContact
     from koalixcrm.crm.models import Currency
     from koalixcrm.crm.models import PurchaseOrder
     from koalixcrm.crm.models import SalesDocument
     from koalixcrm.crm.models import SalesDocumentPosition
     from koalixcrm.crm.models import Contact
     from django.contrib import auth
     objects = [self, ]
     position_class = SalesDocumentPosition
     objects += list(SalesDocument.objects.filter(id=self.id))
     if isinstance(self, PurchaseOrder):
         objects += list(Contact.objects.filter(id=self.supplier.id))
         objects += list(PostalAddressForContact.objects.filter(person=self.supplier.id))
         for address in list(PostalAddressForContact.objects.filter(person=self.supplier.id)):
             objects += list(PostalAddress.objects.filter(id=address.id))
     else:
         objects += list(Contact.objects.filter(id=self.customer.id))
         objects += list(PostalAddressForContact.objects.filter(person=self.customer.id))
         for address in list(PostalAddressForContact.objects.filter(person=self.customer.id)):
             objects += list(PostalAddress.objects.filter(id=address.id))
     objects += list(TextParagraphInSalesDocument.objects.filter(sales_document=self.id))
     objects += list(Currency.objects.filter(id=self.currency.id))
     objects += SalesDocumentPosition.add_positions(position_class, self)
     objects += list(auth.models.User.objects.filter(id=self.staff.id))
     objects += UserExtension.objects_to_serialize(self, self.staff)
     main_xml = PDFExport.write_xml(objects)
     return main_xml