예제 #1
0
def get_provisiongdata_for_kb(kommissionierbelegnr):
    """Returns the Provisioning-Data from kernelE for a KB-No. The returned data could be used to create
    Provisioning-Objects in Django."""
    ret = []
    k = Kerneladapter()
    pipeline_info = k.provpipeline_info(kommissionierbelegnr)
    for provlist in pipeline_info[0]['provisioninglists']:
        data = []
        prov_info = k.provisioninglist_info(provlist)
        data.append(provlist)
        data.append(kommissionierbelegnr)
        data.append(prov_info['destination'])
        data.append(prov_info['parts'])
        data.append(prov_info['attributes'])
        data.append([])
        for pickid in prov_info['provisioning_ids']:
            if pickid[0] == 'P':
                pick_info = k.pick_info(pickid)
                data[5].append([pickid, pick_info['from_unit'], pick_info['from_location'], 
                                pick_info['quantity'], pick_info['product']])
            else: 
                pick_info = k.movement_info(pickid)
                data[5].append([pickid, pick_info['mui'], pick_info['from_location'], 
                                pick_info['quantity'], pick_info['product']])
        ret.append(data)
        
    return ret
예제 #2
0
 def _confirm_picklist_to_kernel(self, missing_pos_ids=None):
     """Confirms the picklist to kernelE"""
     kerneladapter = Kerneladapter()
     if self.get_provisioning_type == 'retrieval':
         ret = kerneladapter.commit_retrieval(self.mypl_id)
     else:
         ret = kerneladapter.commit_picklist(self.mypl_id)
     return ret
예제 #3
0
def get_ls_positions(date_to=None):
    """Returns the number of delivery-note-positions in kernele, that is new in the processing pipeline.
       When a date is given as parameter, all positions to deliver before and on that date are returned.
    """
    k = Kerneladapter()
    pipeline = k.provpipeline_list_new()
    ls_positions = 0
    for kb in pipeline:
        if not date_to or kb['versandtermin'] <= date_to:
            ls_positions += len(kb['orderlines'])
    return ls_positions
예제 #4
0
def get_products_in_provpipeline_list_new():
    """Returns a list of all products pending in provpipeline
    """
    k = Kerneladapter()
    pipeline = k.provpipeline_list_new()
    products = {}
    for kb in pipeline:
        for orderline in kb['orderlines']:
            products[orderline['product']] = products.get(orderline['product'], 0) + 1

    return products
예제 #5
0
def get_kbs_for_articles_in_pipeline(artnr):
    """Returns the KB-Numbers and the quantities (as a tupel) of the KBs in the Provisioning-Pipeline 
       that contain the given article-number
    """
    k = Kerneladapter()
    pipeline = k.provpipeline_list_new()
    kbs = []
    for kb in pipeline:
        for orderline in kb['orderlines']:
            if orderline['product'] == artnr:
                kbs.append((kb['id'], orderline['quantity']))
    return kbs
예제 #6
0
def get_products_to_ship_today():
    """
    Create a dictionary with article numbers as keys and quantities as values
    of products that have to be shipped today
    (taken from pending orders in provpipeline)
    """

    products = {}
    kernel = Kerneladapter()
    for kommi in kernel.provpipeline_list_new():
        if kommi['shouldprocess'] == 'yes':
            for orderline in kommi['orderlines']:
                artnr = orderline['product']
                products[artnr] = products.get(artnr, 0) + orderline['quantity']
    return products
예제 #7
0
    def generate_xml(self, locations):
        """Generates the XML File used by Jasperreports"""

        ET.SubElement(self.root, 'generator').text = __revision__
        ET.SubElement(self.root, 'generated_at').text = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

        xmlroot = self.root
        kernel = Kerneladapter()

        for locname in locations:
            xml_location = ET.SubElement(xmlroot, 'location')
            location = kernel.location_info(locname)
            ET.SubElement(xml_location, "location").text = unicode(locname)
            ET.SubElement(xml_location, "height").text = unicode(location['height'])
            ET.SubElement(xml_location, "attributes").text = unicode(location['attributes'])
            ET.SubElement(xml_location, "floorlevel").text = unicode(location['floorlevel'])
            ET.SubElement(xml_location, "preference").text = unicode(location['preference'])
            ET.SubElement(xml_location, "info").text = unicode(location['info'])
            ET.SubElement(xml_location, "reserved_for").text = unicode(location['reserved_for'])

            for mui in location['allocated_by']:
                unit = kernel.unit_info(mui)
                xml_unit = ET.SubElement(xml_location, "unit")
                ET.SubElement(xml_unit, "mui").text = unicode(unit['mui'])
                ET.SubElement(xml_unit, "quantity").text = unicode(unit['quantity'])
                ET.SubElement(xml_unit, "artnr").text = unicode(unit['product'])
                ET.SubElement(xml_unit, "height").text = unicode(unit['height'])
                ET.SubElement(xml_unit, "pick_quantity").text = unicode(unit['pick_quantity'])
                ET.SubElement(xml_unit, 'created_at').text = unit['created_at'].strftime('%Y-%m-%d %H:%M:%S')
                ET.SubElement(xml_unit, "movements").text = unicode(unit['movements'])
                ET.SubElement(xml_unit, "picks").text = unicode(unit['picks'])
                ET.SubElement(xml_unit, "attributes").text = unicode(unit['attributes'])
                try:
                    product = produktpass.models.Product.objects.get(artnr=unit['product'])
                    ET.SubElement(xml_unit, "product_name").text = unicode(product.name)
                except produktpass.models.Product.DoesNotExist:
                    ET.SubElement(xml_unit, "product_name").text = '???'

        return xmlroot