@@ -13,6 +13,8 @@ class StockInfoAdmin(ChangeOnlyModelAdmin, admin.ModelAdmin): |
||
13 | 13 |
list_display = ('vendorProductId', 'vendorProductName', 'inventoryDate', 'totalQuantity', 'estimateDate', 'totalEstimateQuantity', 'costPrice', 'updated_at') |
14 | 14 |
readonly_fields = ('stock_id', 'vendorCode', 'vendorName', 'vendorProductId', 'vendorProductName', 'storeId', 'storeName', 'quantity', 'estimateQuantity', 'status') |
15 | 15 |
|
16 |
+ search_fields = ('vendorProductId', 'vendorProductName') |
|
17 |
+ |
|
16 | 18 |
def save_model(self, request, obj, form, change): |
17 | 19 |
obj.save() |
18 | 20 |
if obj.inventoryDate and obj.estimateDate and ('inventoryDate' in form.changed_data or 'totalQuantity' in form.changed_data or 'estimateDate' in form.changed_data or 'totalEstimateQuantity' in form.changed_data or 'costPrice' in form.changed_data): |
@@ -19,7 +19,7 @@ class StockInfo(BaseModelMixin): |
||
19 | 19 |
|
20 | 20 |
vendorCode = models.CharField(_(u'供应商简码'), max_length=8, blank=True, null=True, help_text=u'供应商简码') |
21 | 21 |
vendorName = models.CharField(_(u'供应商名称'), max_length=32, blank=True, null=True, help_text=u'供应商名称') |
22 |
- vendorProductId = models.CharField(_(u'供应商商品ID'), max_length=32, blank=True, null=True, help_text=u'供应商商品ID', db_index=True) |
|
22 |
+ vendorProductId = models.CharField(_(u'供应商商品ID'), max_length=32, blank=True, null=True, help_text=u'SKU', db_index=True) |
|
23 | 23 |
vendorProductName = models.CharField(_(u'供应商商品名称'), max_length=255, blank=True, null=True, help_text=u'供应商商品名称') |
24 | 24 |
|
25 | 25 |
storeId = models.CharField(_(u'供应商仓库ID'), max_length=8, blank=True, null=True, help_text=u'供应商仓库ID') |
@@ -38,30 +38,30 @@ def refresh_stock_info(): |
||
38 | 38 |
products = f['jingdong_vc_item_products_find_responce']['jos_result_dto']['result'] |
39 | 39 |
print products |
40 | 40 |
|
41 |
- ware_ids = [int(p['ware_id']) for p in products] |
|
42 |
- print ware_ids |
|
41 |
+ # ware_ids = [int(p['ware_id']) for p in products] |
|
42 |
+ # print ware_ids |
|
43 | 43 |
|
44 | 44 |
offset += 50 |
45 | 45 |
a.offset += offset |
46 | 46 |
|
47 |
- if len(ware_ids) < 50: |
|
47 |
+ if len(products) < 50: |
|
48 | 48 |
jcontinue = False |
49 | 49 |
|
50 |
- a = VcAplsStockBatchGetProdStockInfoRequest() |
|
51 |
- a.vendorCode = JOS['vendorCode'] |
|
52 |
- a.skuList = list(set(ware_ids) - set(settings.JOS_SKU_EXCLUDE)) |
|
53 |
- |
|
54 |
- try: |
|
55 |
- f = a.getResponse(JOS['accessToken']) |
|
56 |
- print(json.dumps(f)) |
|
57 |
- except Exception, e: |
|
58 |
- print(e) |
|
59 |
- |
|
60 |
- stocks = f['jingdong_vc_apls_stock_batchGetProdStockInfo_responce']['batchGetProdStockInfoResponse']['stockList'] |
|
61 |
- for stock in stocks: |
|
62 |
- print stock['sku'] |
|
63 |
- s, _ = StockInfo.objects.get_or_create(vendorProductId=stock['sku']) |
|
64 |
- s.vendorProductName = stock['wname'] |
|
50 |
+ # a = VcAplsStockBatchGetProdStockInfoRequest() |
|
51 |
+ # a.vendorCode = JOS['vendorCode'] |
|
52 |
+ # a.skuList = list(set(ware_ids) - set(settings.JOS_SKU_EXCLUDE)) |
|
53 |
+ # |
|
54 |
+ # try: |
|
55 |
+ # f = a.getResponse(JOS['accessToken']) |
|
56 |
+ # print(json.dumps(f)) |
|
57 |
+ # except Exception, e: |
|
58 |
+ # print(e) |
|
59 |
+ |
|
60 |
+ # stocks = f['jingdong_vc_apls_stock_batchGetProdStockInfo_responce']['batchGetProdStockInfoResponse']['stockList'] |
|
61 |
+ for product in products: |
|
62 |
+ print product['ware_id'] |
|
63 |
+ s, _ = StockInfo.objects.get_or_create(vendorProductId=product['ware_id']) |
|
64 |
+ s.vendorProductName = product['ware_name'] |
|
65 | 65 |
s.vendorCode = JOS['vendorCode'] |
66 | 66 |
s.vendorName = JOS['vendorName'] |
67 | 67 |
s.storeId = JOS['storeId'] |