channel-app 0.0.131__py3-none-any.whl → 0.0.135__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- channel_app/app/product/service.py +16 -0
- channel_app/core/commands.py +3 -1
- channel_app/core/tests.py +15 -164
- channel_app/omnitron/commands/tests/test_products.py +494 -0
- {channel_app-0.0.131.dist-info → channel_app-0.0.135.dist-info}/METADATA +1 -1
- channel_app-0.0.135.dist-info/RECORD +60 -0
- {channel_app-0.0.131.dist-info → channel_app-0.0.135.dist-info}/WHEEL +1 -1
- channel_app/channel_app/app/__init__.py +0 -0
- channel_app/channel_app/app/order/__init__.py +0 -0
- channel_app/channel_app/app/order/service.py +0 -230
- channel_app/channel_app/app/product/__init__.py +0 -0
- channel_app/channel_app/app/product/service.py +0 -237
- channel_app/channel_app/app/product_price/__init__.py +0 -0
- channel_app/channel_app/app/product_price/service.py +0 -254
- channel_app/channel_app/app/product_stock/__init__.py +0 -0
- channel_app/channel_app/app/product_stock/service.py +0 -258
- channel_app/channel_app/app/setup/__init__.py +0 -0
- channel_app/channel_app/app/setup/service.py +0 -61
- channel_app/channel_app/channel/__init__.py +0 -0
- channel_app/channel_app/channel/commands/__init__.py +0 -0
- channel_app/channel_app/channel/commands/orders/__init__.py +0 -0
- channel_app/channel_app/channel/commands/orders/orders.py +0 -329
- channel_app/channel_app/channel/commands/product_categories.py +0 -1
- channel_app/channel_app/channel/commands/product_images.py +0 -1
- channel_app/channel_app/channel/commands/product_prices.py +0 -148
- channel_app/channel_app/channel/commands/product_stocks.py +0 -220
- channel_app/channel_app/channel/commands/products.py +0 -161
- channel_app/channel_app/channel/commands/setup.py +0 -948
- channel_app/channel_app/channel/integration.py +0 -84
- channel_app/channel_app/core/__init__.py +0 -0
- channel_app/channel_app/core/clients.py +0 -12
- channel_app/channel_app/core/commands.py +0 -364
- channel_app/channel_app/core/data.py +0 -227
- channel_app/channel_app/core/integration.py +0 -74
- channel_app/channel_app/core/products.py +0 -64
- channel_app/channel_app/core/settings.py +0 -28
- channel_app/channel_app/core/utilities.py +0 -99
- channel_app/channel_app/omnitron/__init__.py +0 -0
- channel_app/channel_app/omnitron/batch_request.py +0 -82
- channel_app/channel_app/omnitron/commands/__init__.py +0 -0
- channel_app/channel_app/omnitron/commands/batch_requests.py +0 -281
- channel_app/channel_app/omnitron/commands/error_reports.py +0 -86
- channel_app/channel_app/omnitron/commands/integration_actions.py +0 -200
- channel_app/channel_app/omnitron/commands/orders/__init__.py +0 -0
- channel_app/channel_app/omnitron/commands/orders/addresses.py +0 -242
- channel_app/channel_app/omnitron/commands/orders/cargo_companies.py +0 -40
- channel_app/channel_app/omnitron/commands/orders/customers.py +0 -72
- channel_app/channel_app/omnitron/commands/orders/orders.py +0 -450
- channel_app/channel_app/omnitron/commands/product_categories.py +0 -1
- channel_app/channel_app/omnitron/commands/product_images.py +0 -1
- channel_app/channel_app/omnitron/commands/product_prices.py +0 -192
- channel_app/channel_app/omnitron/commands/product_stocks.py +0 -229
- channel_app/channel_app/omnitron/commands/products.py +0 -735
- channel_app/channel_app/omnitron/commands/setup.py +0 -839
- channel_app/channel_app/omnitron/constants.py +0 -98
- channel_app/channel_app/omnitron/exceptions.py +0 -42
- channel_app/channel_app/omnitron/integration.py +0 -159
- channel_app/setup.py +0 -21
- channel_app-0.0.131.dist-info/RECORD +0 -110
- /channel_app/{channel_app → omnitron/commands/tests}/__init__.py +0 -0
- {channel_app-0.0.131.dist-info → channel_app-0.0.135.dist-info}/top_level.txt +0 -0
@@ -1,254 +0,0 @@
|
|
1
|
-
from typing import List
|
2
|
-
|
3
|
-
from omnisdk.omnitron.models import ProductPrice, ProductStock, BatchRequest
|
4
|
-
|
5
|
-
from channel_app.core import settings
|
6
|
-
from channel_app.core.data import BatchRequestResponseDto, ErrorReportDto
|
7
|
-
from channel_app.core.settings import OmnitronIntegration, ChannelIntegration
|
8
|
-
from channel_app.omnitron.batch_request import ClientBatchRequest
|
9
|
-
from channel_app.omnitron.constants import ContentType
|
10
|
-
|
11
|
-
|
12
|
-
class PriceService(object):
|
13
|
-
batch_service = ClientBatchRequest
|
14
|
-
|
15
|
-
def update_product_prices(self, is_sync=True, is_success_log=True,
|
16
|
-
add_product_objects=False):
|
17
|
-
with OmnitronIntegration(
|
18
|
-
content_type=ContentType.product_price.value) as omnitron_integration:
|
19
|
-
product_prices = omnitron_integration.do_action(
|
20
|
-
key='get_updated_prices')
|
21
|
-
|
22
|
-
if add_product_objects:
|
23
|
-
product_prices = product_prices and omnitron_integration.do_action(
|
24
|
-
key='get_product_objects', objects=product_prices)
|
25
|
-
|
26
|
-
if not product_prices:
|
27
|
-
return
|
28
|
-
|
29
|
-
product_prices: List[ProductPrice]
|
30
|
-
|
31
|
-
response_data, reports, data = ChannelIntegration().do_action(
|
32
|
-
key='send_updated_prices',
|
33
|
-
objects=product_prices,
|
34
|
-
batch_request=omnitron_integration.batch_request,
|
35
|
-
is_sync=is_sync)
|
36
|
-
|
37
|
-
# tips
|
38
|
-
response_data: List[BatchRequestResponseDto]
|
39
|
-
reports: List[ErrorReportDto]
|
40
|
-
data: List[ProductPrice]
|
41
|
-
|
42
|
-
if not is_sync:
|
43
|
-
if reports[0].is_ok:
|
44
|
-
self.batch_service(
|
45
|
-
settings.OMNITRON_CHANNEL_ID).to_sent_to_remote(
|
46
|
-
batch_request=omnitron_integration.batch_request)
|
47
|
-
else:
|
48
|
-
is_sync = True
|
49
|
-
|
50
|
-
if reports and (is_success_log or not reports[0].is_ok):
|
51
|
-
for report in reports:
|
52
|
-
omnitron_integration.do_action(
|
53
|
-
key='create_error_report',
|
54
|
-
objects=report)
|
55
|
-
|
56
|
-
if is_sync:
|
57
|
-
omnitron_integration.do_action(
|
58
|
-
key='process_price_batch_requests',
|
59
|
-
objects=response_data)
|
60
|
-
|
61
|
-
def insert_product_prices(self, is_sync=True, is_success_log=True,
|
62
|
-
add_product_objects=False):
|
63
|
-
with OmnitronIntegration(
|
64
|
-
content_type=ContentType.product_price.value) as omnitron_integration:
|
65
|
-
product_prices = omnitron_integration.do_action(
|
66
|
-
key='get_inserted_prices')
|
67
|
-
|
68
|
-
if add_product_objects:
|
69
|
-
product_prices = product_prices and omnitron_integration.do_action(
|
70
|
-
key='get_product_objects', objects=product_prices)
|
71
|
-
|
72
|
-
if not product_prices:
|
73
|
-
return
|
74
|
-
|
75
|
-
product_prices: List[ProductPrice]
|
76
|
-
|
77
|
-
response_data, reports, data = ChannelIntegration().do_action(
|
78
|
-
key='send_inserted_prices',
|
79
|
-
objects=product_prices,
|
80
|
-
batch_request=omnitron_integration.batch_request,
|
81
|
-
is_sync=is_sync)
|
82
|
-
|
83
|
-
# tips
|
84
|
-
response_data: List[BatchRequestResponseDto]
|
85
|
-
reports: List[ErrorReportDto]
|
86
|
-
data: List[ProductPrice]
|
87
|
-
|
88
|
-
if not is_sync:
|
89
|
-
if reports[0].is_ok:
|
90
|
-
self.batch_service(
|
91
|
-
settings.OMNITRON_CHANNEL_ID).to_sent_to_remote(
|
92
|
-
batch_request=omnitron_integration.batch_request)
|
93
|
-
else:
|
94
|
-
is_sync = True
|
95
|
-
|
96
|
-
if reports and (is_success_log or not reports[0].is_ok):
|
97
|
-
for report in reports:
|
98
|
-
omnitron_integration.do_action(
|
99
|
-
key='create_error_report',
|
100
|
-
objects=report)
|
101
|
-
|
102
|
-
if is_sync:
|
103
|
-
omnitron_integration.do_action(
|
104
|
-
key='process_price_batch_requests',
|
105
|
-
objects=response_data)
|
106
|
-
|
107
|
-
def insert_product_prices_from_extra_price_list(self, is_sync=True,
|
108
|
-
is_success_log=True,
|
109
|
-
add_product_objects=False):
|
110
|
-
currency_mappings = self.get_currency_mappings()
|
111
|
-
for price_list_id, country_code in currency_mappings.items():
|
112
|
-
with OmnitronIntegration(
|
113
|
-
content_type=ContentType.product_price.value) as omnitron_integration:
|
114
|
-
product_prices = omnitron_integration.do_action(
|
115
|
-
key='get_inserted_prices_from_extra_price_list',
|
116
|
-
objects=price_list_id)
|
117
|
-
if add_product_objects:
|
118
|
-
product_prices = product_prices and omnitron_integration.do_action(
|
119
|
-
key='get_product_objects', objects=product_prices)
|
120
|
-
product_prices: List[ProductPrice]
|
121
|
-
if product_prices:
|
122
|
-
|
123
|
-
response_data, reports, data = ChannelIntegration().do_action(
|
124
|
-
key='send_inserted_prices',
|
125
|
-
objects=(product_prices, country_code),
|
126
|
-
batch_request=omnitron_integration.batch_request,
|
127
|
-
is_sync=is_sync)
|
128
|
-
|
129
|
-
# tips
|
130
|
-
response_data: List[BatchRequestResponseDto]
|
131
|
-
reports: List[ErrorReportDto]
|
132
|
-
data: List[ProductPrice]
|
133
|
-
|
134
|
-
if not is_sync:
|
135
|
-
if reports[0].is_ok:
|
136
|
-
self.batch_service(
|
137
|
-
settings.OMNITRON_CHANNEL_ID).to_sent_to_remote(
|
138
|
-
batch_request=omnitron_integration.batch_request)
|
139
|
-
else:
|
140
|
-
is_sync = True
|
141
|
-
|
142
|
-
if reports and (is_success_log or not reports[0].is_ok):
|
143
|
-
for report in reports:
|
144
|
-
omnitron_integration.do_action(
|
145
|
-
key='create_error_report',
|
146
|
-
objects=report)
|
147
|
-
|
148
|
-
if is_sync:
|
149
|
-
omnitron_integration.do_action(
|
150
|
-
key='process_price_batch_requests',
|
151
|
-
objects=response_data)
|
152
|
-
|
153
|
-
def update_product_prices_from_extra_price_list(self, is_sync=True,
|
154
|
-
is_success_log=True,
|
155
|
-
add_product_objects=False):
|
156
|
-
currency_mappings = self.get_currency_mappings()
|
157
|
-
for price_list_id, country_code in currency_mappings.items():
|
158
|
-
with OmnitronIntegration(
|
159
|
-
content_type=ContentType.product_price.value) as omnitron_integration:
|
160
|
-
product_prices = omnitron_integration.do_action(
|
161
|
-
key='get_updated_prices_from_extra_price_list',
|
162
|
-
objects=price_list_id)
|
163
|
-
if add_product_objects:
|
164
|
-
product_prices = product_prices and omnitron_integration.do_action(
|
165
|
-
key='get_product_objects', objects=product_prices)
|
166
|
-
product_prices: List[ProductPrice]
|
167
|
-
if product_prices:
|
168
|
-
|
169
|
-
response_data, reports, data = ChannelIntegration().do_action(
|
170
|
-
key='send_updated_prices',
|
171
|
-
objects=(product_prices, country_code),
|
172
|
-
batch_request=omnitron_integration.batch_request,
|
173
|
-
is_sync=is_sync)
|
174
|
-
|
175
|
-
# tips
|
176
|
-
response_data: List[BatchRequestResponseDto]
|
177
|
-
reports: List[ErrorReportDto]
|
178
|
-
data: List[ProductPrice]
|
179
|
-
|
180
|
-
if not is_sync:
|
181
|
-
if reports[0].is_ok:
|
182
|
-
self.batch_service(
|
183
|
-
settings.OMNITRON_CHANNEL_ID).to_sent_to_remote(
|
184
|
-
batch_request=omnitron_integration.batch_request)
|
185
|
-
else:
|
186
|
-
is_sync = True
|
187
|
-
|
188
|
-
if reports and (is_success_log or not reports[0].is_ok):
|
189
|
-
for report in reports:
|
190
|
-
omnitron_integration.do_action(
|
191
|
-
key='create_error_report',
|
192
|
-
objects=report)
|
193
|
-
|
194
|
-
if is_sync:
|
195
|
-
omnitron_integration.do_action(
|
196
|
-
key='process_price_batch_requests',
|
197
|
-
objects=response_data)
|
198
|
-
|
199
|
-
def get_price_batch_requests(self, is_success_log=True):
|
200
|
-
with OmnitronIntegration(create_batch=False) as omnitron_integration:
|
201
|
-
batch_request_data = omnitron_integration.do_action(
|
202
|
-
'get_batch_requests',
|
203
|
-
params={
|
204
|
-
"status": ["sent_to_remote", "ongoing"],
|
205
|
-
"content_type": ContentType.product_price.value})
|
206
|
-
# tips
|
207
|
-
batch_request_data: List[BatchRequest]
|
208
|
-
|
209
|
-
for batch_request in batch_request_data:
|
210
|
-
response_data, reports, data = ChannelIntegration().do_action(
|
211
|
-
key='check_prices',
|
212
|
-
objects=batch_request,
|
213
|
-
batch_request=batch_request
|
214
|
-
)
|
215
|
-
|
216
|
-
# tips
|
217
|
-
response_data: List[BatchRequestResponseDto]
|
218
|
-
reports: List[ErrorReportDto]
|
219
|
-
data: BatchRequest
|
220
|
-
|
221
|
-
if reports and (is_success_log or not reports[0].is_ok):
|
222
|
-
for report in reports:
|
223
|
-
omnitron_integration.do_action(
|
224
|
-
key='create_error_report',
|
225
|
-
objects=report)
|
226
|
-
|
227
|
-
if response_data:
|
228
|
-
omnitron_integration.batch_request = batch_request
|
229
|
-
omnitron_integration.do_action(
|
230
|
-
key='process_price_batch_requests',
|
231
|
-
objects=response_data)
|
232
|
-
|
233
|
-
def get_currency_mappings(self):
|
234
|
-
"""
|
235
|
-
Process is like below:
|
236
|
-
We get key value list of the currency mappings, filter Omnitron
|
237
|
-
with key field
|
238
|
-
{
|
239
|
-
"1": "ae",
|
240
|
-
"2": "us"
|
241
|
-
}
|
242
|
-
:return:
|
243
|
-
"""
|
244
|
-
with OmnitronIntegration(create_batch=False) as integration:
|
245
|
-
currency_mappings = integration.channel.conf.get(
|
246
|
-
"CURRENCY_MAPPINGS", {})
|
247
|
-
price_lists = integration.catalog.extra_price_lists
|
248
|
-
if integration.catalog.price_list:
|
249
|
-
price_lists.append(integration.catalog.price_list)
|
250
|
-
filtered_currency_mappings = {
|
251
|
-
price_list: currency_mappings[price_list]
|
252
|
-
for price_list in map(str, price_lists)
|
253
|
-
if price_list in currency_mappings}
|
254
|
-
return filtered_currency_mappings
|
File without changes
|
@@ -1,258 +0,0 @@
|
|
1
|
-
from typing import List
|
2
|
-
|
3
|
-
from omnisdk.omnitron.models import ProductStock, BatchRequest
|
4
|
-
|
5
|
-
from channel_app.core import settings
|
6
|
-
from channel_app.core.settings import OmnitronIntegration, ChannelIntegration
|
7
|
-
from channel_app.core.data import BatchRequestResponseDto, ErrorReportDto
|
8
|
-
from channel_app.omnitron.batch_request import ClientBatchRequest
|
9
|
-
from channel_app.omnitron.constants import ContentType
|
10
|
-
|
11
|
-
|
12
|
-
class StockService(object):
|
13
|
-
batch_service = ClientBatchRequest
|
14
|
-
|
15
|
-
def update_product_stocks(self, is_sync=True, is_success_log=True,
|
16
|
-
add_product_objects=False):
|
17
|
-
with OmnitronIntegration(
|
18
|
-
content_type=ContentType.product_stock.value) as omnitron_integration:
|
19
|
-
product_stocks = omnitron_integration.do_action(
|
20
|
-
key='get_updated_stocks')
|
21
|
-
|
22
|
-
if add_product_objects:
|
23
|
-
product_stocks = product_stocks and omnitron_integration.do_action(
|
24
|
-
key='get_product_objects', objects=product_stocks)
|
25
|
-
|
26
|
-
if not product_stocks:
|
27
|
-
return
|
28
|
-
|
29
|
-
product_stocks: List[ProductStock]
|
30
|
-
response_data, reports, data = ChannelIntegration().do_action(
|
31
|
-
key='send_updated_stocks',
|
32
|
-
objects=product_stocks,
|
33
|
-
batch_request=omnitron_integration.batch_request,
|
34
|
-
is_sync=is_sync)
|
35
|
-
|
36
|
-
# tips
|
37
|
-
response_data: List[BatchRequestResponseDto]
|
38
|
-
reports: List[ErrorReportDto]
|
39
|
-
data: List[ProductStock]
|
40
|
-
|
41
|
-
if not is_sync:
|
42
|
-
if reports[0].is_ok:
|
43
|
-
self.batch_service(
|
44
|
-
settings.OMNITRON_CHANNEL_ID).to_sent_to_remote(
|
45
|
-
batch_request=omnitron_integration.batch_request)
|
46
|
-
else:
|
47
|
-
is_sync = True
|
48
|
-
|
49
|
-
if reports and (is_success_log or not reports[0].is_ok):
|
50
|
-
for report in reports:
|
51
|
-
omnitron_integration.do_action(
|
52
|
-
key='create_error_report',
|
53
|
-
objects=report)
|
54
|
-
|
55
|
-
if is_sync:
|
56
|
-
omnitron_integration.do_action(
|
57
|
-
key='process_stock_batch_requests',
|
58
|
-
objects=response_data)
|
59
|
-
|
60
|
-
|
61
|
-
def update_product_stocks_from_extra_stock_list(self, is_sync=True,
|
62
|
-
is_success_log=True,
|
63
|
-
add_product_objects=False):
|
64
|
-
warehouse_mappings = self.get_warehouse_mappings()
|
65
|
-
for stock_list_id, country_code in warehouse_mappings.items():
|
66
|
-
with OmnitronIntegration(
|
67
|
-
content_type=ContentType.product_stock.value) as omnitron_integration:
|
68
|
-
product_stocks = omnitron_integration.do_action(
|
69
|
-
key='get_updated_stocks_from_extra_stock_list',
|
70
|
-
object=stock_list_id)
|
71
|
-
|
72
|
-
if add_product_objects:
|
73
|
-
product_stocks = product_stocks and omnitron_integration.do_action(
|
74
|
-
key='get_product_objects', objects=product_stocks)
|
75
|
-
|
76
|
-
if not product_stocks:
|
77
|
-
return
|
78
|
-
|
79
|
-
product_stocks: List[ProductStock]
|
80
|
-
response_data, reports, data = ChannelIntegration().do_action(
|
81
|
-
key='send_updated_stocks',
|
82
|
-
objects=(product_stocks, country_code),
|
83
|
-
batch_request=omnitron_integration.batch_request,
|
84
|
-
is_sync=is_sync)
|
85
|
-
|
86
|
-
# tips
|
87
|
-
response_data: List[BatchRequestResponseDto]
|
88
|
-
reports: List[ErrorReportDto]
|
89
|
-
data: List[ProductStock]
|
90
|
-
|
91
|
-
if not is_sync:
|
92
|
-
if reports[0].is_ok:
|
93
|
-
self.batch_service(
|
94
|
-
settings.OMNITRON_CHANNEL_ID).to_sent_to_remote(
|
95
|
-
batch_request=omnitron_integration.batch_request)
|
96
|
-
else:
|
97
|
-
is_sync = True
|
98
|
-
|
99
|
-
if reports and (is_success_log or not reports[0].is_ok):
|
100
|
-
for report in reports:
|
101
|
-
omnitron_integration.do_action(
|
102
|
-
key='create_error_report',
|
103
|
-
objects=report)
|
104
|
-
|
105
|
-
if is_sync:
|
106
|
-
omnitron_integration.do_action(
|
107
|
-
key='process_stock_batch_requests',
|
108
|
-
objects=response_data)
|
109
|
-
|
110
|
-
def insert_product_stocks_from_extra_stock_list(self, is_sync=True,
|
111
|
-
is_success_log=True,
|
112
|
-
add_product_objects=False):
|
113
|
-
warehouse_mappings = self.get_warehouse_mappings()
|
114
|
-
for stock_list_id, country_code in warehouse_mappings.items():
|
115
|
-
with OmnitronIntegration(
|
116
|
-
content_type=ContentType.product_stock.value) as omnitron_integration:
|
117
|
-
product_stocks = omnitron_integration.do_action(
|
118
|
-
key='get_inserted_stocks_from_extra_stock_list',
|
119
|
-
object=stock_list_id)
|
120
|
-
|
121
|
-
if add_product_objects:
|
122
|
-
product_stocks = product_stocks and omnitron_integration.do_action(
|
123
|
-
key='get_product_objects', objects=product_stocks)
|
124
|
-
|
125
|
-
if not product_stocks:
|
126
|
-
return
|
127
|
-
|
128
|
-
product_stocks: List[ProductStock]
|
129
|
-
response_data, reports, data = ChannelIntegration().do_action(
|
130
|
-
key='send_inserted_stocks',
|
131
|
-
objects=(product_stocks, country_code),
|
132
|
-
batch_request=omnitron_integration.batch_request,
|
133
|
-
is_sync=is_sync)
|
134
|
-
|
135
|
-
# tips
|
136
|
-
response_data: List[BatchRequestResponseDto]
|
137
|
-
reports: List[ErrorReportDto]
|
138
|
-
data: List[ProductStock]
|
139
|
-
|
140
|
-
if not is_sync:
|
141
|
-
if reports[0].is_ok:
|
142
|
-
self.batch_service(
|
143
|
-
settings.OMNITRON_CHANNEL_ID).to_sent_to_remote(
|
144
|
-
batch_request=omnitron_integration.batch_request)
|
145
|
-
else:
|
146
|
-
is_sync = True
|
147
|
-
|
148
|
-
if reports and (is_success_log or not reports[0].is_ok):
|
149
|
-
for report in reports:
|
150
|
-
omnitron_integration.do_action(
|
151
|
-
key='create_error_report',
|
152
|
-
objects=report)
|
153
|
-
|
154
|
-
if is_sync:
|
155
|
-
omnitron_integration.do_action(
|
156
|
-
key='process_stock_batch_requests',
|
157
|
-
objects=response_data)
|
158
|
-
|
159
|
-
def insert_product_stocks(self, is_sync=True, is_success_log=True,
|
160
|
-
add_product_objects=False):
|
161
|
-
with OmnitronIntegration(
|
162
|
-
content_type=ContentType.product_stock.value) as omnitron_integration:
|
163
|
-
product_stocks = omnitron_integration.do_action(
|
164
|
-
key='get_inserted_stocks')
|
165
|
-
|
166
|
-
if add_product_objects:
|
167
|
-
product_stocks = product_stocks and omnitron_integration.do_action(
|
168
|
-
key='get_product_objects', objects=product_stocks)
|
169
|
-
|
170
|
-
if not product_stocks:
|
171
|
-
return
|
172
|
-
|
173
|
-
product_stocks: List[ProductStock]
|
174
|
-
response_data, reports, data = ChannelIntegration().do_action(
|
175
|
-
key='send_inserted_stocks',
|
176
|
-
objects=product_stocks,
|
177
|
-
batch_request=omnitron_integration.batch_request,
|
178
|
-
is_sync=is_sync)
|
179
|
-
# tips
|
180
|
-
response_data: List[BatchRequestResponseDto]
|
181
|
-
reports: List[ErrorReportDto]
|
182
|
-
data: List[ProductStock]
|
183
|
-
|
184
|
-
if not is_sync:
|
185
|
-
if reports[0].is_ok:
|
186
|
-
self.batch_service(
|
187
|
-
settings.OMNITRON_CHANNEL_ID).to_sent_to_remote(
|
188
|
-
batch_request=omnitron_integration.batch_request)
|
189
|
-
else:
|
190
|
-
is_sync = True
|
191
|
-
|
192
|
-
if reports and (is_success_log or not reports[0].is_ok):
|
193
|
-
for report in reports:
|
194
|
-
omnitron_integration.do_action(
|
195
|
-
key='create_error_report',
|
196
|
-
objects=report)
|
197
|
-
|
198
|
-
if is_sync:
|
199
|
-
omnitron_integration.do_action(
|
200
|
-
key='process_stock_batch_requests',
|
201
|
-
objects=response_data)
|
202
|
-
|
203
|
-
def get_stock_batch_requests(self, is_success_log=True):
|
204
|
-
with OmnitronIntegration(create_batch=False) as omnitron_integration:
|
205
|
-
batch_request_data = omnitron_integration.do_action(
|
206
|
-
'get_batch_requests',
|
207
|
-
params={
|
208
|
-
"status": ["sent_to_remote", "ongoing"],
|
209
|
-
"content_type": ContentType.product_stock.value})
|
210
|
-
# tips
|
211
|
-
batch_request_data: List[BatchRequest]
|
212
|
-
|
213
|
-
for batch_request in batch_request_data:
|
214
|
-
response_data, reports, data = ChannelIntegration().do_action(
|
215
|
-
key='check_stocks',
|
216
|
-
objects=batch_request,
|
217
|
-
batch_request=batch_request
|
218
|
-
)
|
219
|
-
|
220
|
-
# tips
|
221
|
-
response_data: List[BatchRequestResponseDto]
|
222
|
-
reports: List[ErrorReportDto]
|
223
|
-
data: BatchRequest
|
224
|
-
|
225
|
-
if reports and (is_success_log or not reports[0].is_ok):
|
226
|
-
for report in reports:
|
227
|
-
omnitron_integration.do_action(
|
228
|
-
key='create_error_report',
|
229
|
-
objects=report)
|
230
|
-
|
231
|
-
if response_data:
|
232
|
-
omnitron_integration.batch_request = batch_request
|
233
|
-
omnitron_integration.do_action(
|
234
|
-
key='process_stock_batch_requests',
|
235
|
-
objects=response_data)
|
236
|
-
|
237
|
-
def get_warehouse_mappings(self):
|
238
|
-
"""
|
239
|
-
Process is like below:
|
240
|
-
We get key value list of the warehouse mapping, filter Omnitron
|
241
|
-
with key field
|
242
|
-
{
|
243
|
-
"1": "ae",
|
244
|
-
"2": "us"
|
245
|
-
}
|
246
|
-
:return:
|
247
|
-
"""
|
248
|
-
with OmnitronIntegration(create_batch=False) as integration:
|
249
|
-
warehouse_mapping = integration.channel.conf.get(
|
250
|
-
"WAREHOUSE_CODES", {})
|
251
|
-
stock_lists = integration.catalog.extra_stock_lists
|
252
|
-
if integration.catalog.stock_list:
|
253
|
-
stock_lists.append(integration.catalog.stock_list)
|
254
|
-
filtered_warehouse_mapping = {
|
255
|
-
stock_list: warehouse_mapping[stock_list]
|
256
|
-
for stock_list in map(str, stock_lists)
|
257
|
-
if stock_list in warehouse_mapping}
|
258
|
-
return filtered_warehouse_mapping
|
File without changes
|
@@ -1,61 +0,0 @@
|
|
1
|
-
from channel_app.core.data import CategoryTreeDto, ErrorReportDto
|
2
|
-
from channel_app.core.settings import OmnitronIntegration, ChannelIntegration
|
3
|
-
from channel_app.omnitron.constants import ContentType
|
4
|
-
|
5
|
-
|
6
|
-
class SetupService(object):
|
7
|
-
def create_or_update_category_tree_and_nodes(self, is_success_log=False):
|
8
|
-
with OmnitronIntegration(
|
9
|
-
content_type=ContentType.category_tree.value) as omnitron_integration:
|
10
|
-
channel_integration = ChannelIntegration()
|
11
|
-
category_tree, report, _ = channel_integration.do_action(
|
12
|
-
key='get_category_tree_and_nodes',
|
13
|
-
batch_request=omnitron_integration.batch_request)
|
14
|
-
|
15
|
-
category_tree: CategoryTreeDto
|
16
|
-
report: ErrorReportDto
|
17
|
-
|
18
|
-
if report and (is_success_log or not report.is_ok):
|
19
|
-
omnitron_integration.do_action(
|
20
|
-
key='create_error_report',
|
21
|
-
objects=report)
|
22
|
-
|
23
|
-
omnitron_integration.do_action(
|
24
|
-
key='create_or_update_category_tree_and_nodes',
|
25
|
-
objects=category_tree)
|
26
|
-
|
27
|
-
def create_or_update_category_attributes(self, is_success_log=False):
|
28
|
-
with OmnitronIntegration(
|
29
|
-
content_type=ContentType.attribute.value) as omnitron_integration:
|
30
|
-
channel_integration = ChannelIntegration()
|
31
|
-
category_integration_actions = omnitron_integration.do_action(
|
32
|
-
key='get_category_ids')
|
33
|
-
|
34
|
-
for category_ia in category_integration_actions:
|
35
|
-
if not category_ia.remote_id:
|
36
|
-
continue
|
37
|
-
|
38
|
-
category, report, data = channel_integration.do_action(
|
39
|
-
key='get_category_attributes',
|
40
|
-
objects=category_ia,
|
41
|
-
batch_request=omnitron_integration.batch_request
|
42
|
-
)
|
43
|
-
if report and (is_success_log or not report.is_ok):
|
44
|
-
omnitron_integration.do_action(
|
45
|
-
key='create_error_report',
|
46
|
-
objects=report)
|
47
|
-
|
48
|
-
omnitron_integration.do_action(
|
49
|
-
key='create_or_update_category_attributes',
|
50
|
-
objects=category)
|
51
|
-
|
52
|
-
def update_channel_conf_schema(self):
|
53
|
-
with OmnitronIntegration(
|
54
|
-
content_type=ContentType.channel.value) as omnitron_integration:
|
55
|
-
channel_integration = ChannelIntegration()
|
56
|
-
schema, _, _ = channel_integration.do_action(
|
57
|
-
key='get_channel_conf_schema',
|
58
|
-
batch_request=omnitron_integration.batch_request)
|
59
|
-
|
60
|
-
omnitron_integration.do_action(key="update_channel_conf_schema",
|
61
|
-
objects=schema)
|
File without changes
|
File without changes
|
File without changes
|