Beispiel #1
0
def import_add(request):
    from magonet.connector import MagoNet
    conn = MagoNet()
    conn.connect()
    rows = conn.getcustomer_byid(str(request.GET['code']))
    conn.disconnect()
    row = rows[0]
    cust_list = Customer.objects.filter(origin_code=row['CustSupp'])
    if cust_list:
        newcust = cust_list[0]
    else:
        newcust = Customer()
    newcust.address = row['Address']
    newcust.city = row['City']
    newcust.email = row['EMail']
    newcust.name = row['CompanyName']
    newcust.origin_code = row['CustSupp']
    newcust.telephone = row['Telephone1'] + " " + row['Telephone2'] + " " + row['Fax']
    newcust.save()
    return HttpResponseRedirect(reverse("customers:detail", kwargs={"pk": newcust.id}))
Beispiel #2
0
def import_add(request):
    from magonet.connector import MagoNet
    conn = MagoNet()
    conn.connect()
    rows = conn.getcustomer_byid(str(request.GET['code']))
    conn.disconnect()
    row = rows[0]
    cust_list = Customer.objects.filter(origin_code=row['CustSupp'])
    if cust_list:
        newcust = cust_list[0]
    else:
        newcust = Customer()
    newcust.address = row['Address']
    newcust.city = row['City']
    newcust.email = row['EMail']
    newcust.name = row['CompanyName']
    newcust.origin_code = row['CustSupp']
    newcust.telephone = row['Telephone1'] + " " + row[
        'Telephone2'] + " " + row['Fax']
    newcust.save()
    return HttpResponseRedirect(
        reverse("customers:detail", kwargs={"pk": newcust.id}))
Beispiel #3
0
CUSTOMER_NAMES_TITLE = ["Srl", "Snc", "Sas", "Spa"]
for x in range(25):
    newcust = Customer()
    newcust.name = CUSTOMER_NAMES[random.randint(0, len(CUSTOMER_NAMES) - 1)].title() + ' ' + \
                   CUSTOMER_NAMES[random.randint(0, len(CUSTOMER_NAMES) - 1)] + ' ' + \
                   CUSTOMER_NAMES_TITLE[random.randint(0, len(CUSTOMER_NAMES_TITLE) - 1)]

    newcust.address = 'via {0}'.format(CUSTOMER_NAMES[random.randint(
        0,
        len(CUSTOMER_NAMES) - 1)])
    newcust.city = "City"
    newcust.email = "*****@*****.**"
    newcust.reference_person = CUSTOMER_NAMES[random.randint(
        0,
        len(CUSTOMER_NAMES) - 1)]
    newcust.origin_code = "sample"
    newcust.telephone = "008881123456"
    newcust.save()
    for sx in range(3):
        newws = WorkSite(customer=newcust)
        newws.name = "Branch {0} {1}".format(str(sx), newcust.name)
        newws.address = "via {0}".format(CUSTOMER_NAMES[random.randint(
            0,
            len(CUSTOMER_NAMES) - 1)])
        newws.city = "City"
        newws.email = "*****@*****.**"
        newws.reference_person = CUSTOMER_NAMES[random.randint(
            0,
            len(CUSTOMER_NAMES) - 1)]
        newws.origin_code = "sample"
        newws.telephone = "008881123456"