예제 #1
0
 def wm_import_suppliers(self):
   for supplier in Supplier.objects.all():
     supplier.delete()
   wm_suppliers = WorkflowmaxSupplier.objects.all()
   for wm_supplier in wm_suppliers:
     supplier = Supplier()
     supplier.wm_import(wm_supplier)
예제 #2
0
def import_suppliers(request):
  context_vars = dict()
  context_vars['header'] = capfirst(_('import suppliers from workflowmax'))
  context_vars['comment'] = capfirst(_('this will destroy all your local suppliers, please confirm your decision.'))
  if request.method == "POST":
    for supplier in Supplier.objects.all():
      supplier.delete()
    wm_suppliers = WorkflowmaxSupplier.objects.all()
    for wm_supplier in wm_suppliers:
      supplier = Supplier()
      supplier.wm_import(wm_supplier)
    return HttpResponseRedirect(reverse('supplier-list'))
  
  return direct_to_template(request, template='supplier/import.html', extra_context=context_vars)