mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 11:19:09 +00:00
[hub] remove test code
This commit is contained in:
@@ -73,18 +73,14 @@ def publish_selected_items(items_to_publish):
|
|||||||
if not len(items_to_publish):
|
if not len(items_to_publish):
|
||||||
return
|
return
|
||||||
|
|
||||||
# TODO: sync
|
for item_code in items_to_publish:
|
||||||
# for item_code in items_to_publish:
|
frappe.db.set_value('Item', item_code, 'publish_in_hub', 1)
|
||||||
# frappe.db.set_value('Item', item_code, 'publish_in_hub', 1)
|
|
||||||
|
|
||||||
# hub_settings = frappe.get_doc('Hub Settings')
|
|
||||||
# remote_id = item_sync_preprocess()
|
|
||||||
# hub_settings.sync(remote_id)
|
|
||||||
|
|
||||||
# return remote_id
|
|
||||||
|
|
||||||
hub_settings = frappe.get_doc('Hub Settings')
|
hub_settings = frappe.get_doc('Hub Settings')
|
||||||
hub_settings.sync('TEST')
|
remote_id = item_sync_preprocess()
|
||||||
|
hub_settings.sync(remote_id)
|
||||||
|
|
||||||
|
return remote_id
|
||||||
|
|
||||||
def item_sync_preprocess():
|
def item_sync_preprocess():
|
||||||
# Call Hub to make a new activity
|
# Call Hub to make a new activity
|
||||||
|
|||||||
@@ -41,27 +41,8 @@ class HubSettings(Document):
|
|||||||
'trigger_name': 'items-sync'
|
'trigger_name': 'items-sync'
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
time.sleep(2)
|
self.sync_in_progress = 1
|
||||||
frappe.publish_realtime('items-sync', {"progress_percent": 20})
|
doc.run()
|
||||||
print("=======================")
|
|
||||||
|
|
||||||
time.sleep(2)
|
|
||||||
frappe.publish_realtime('items-sync', {"progress_percent": 40})
|
|
||||||
print("=======================")
|
|
||||||
|
|
||||||
time.sleep(1)
|
|
||||||
frappe.publish_realtime('items-sync', {"progress_percent": 80})
|
|
||||||
print("=======================")
|
|
||||||
|
|
||||||
time.sleep(2)
|
|
||||||
frappe.publish_realtime('items-sync', {"progress_percent": 100})
|
|
||||||
print("=======================")
|
|
||||||
|
|
||||||
frappe.db.set_value('Hub Settings', 'Hub Settings', 'last_sync_datetime', frappe.utils.now())
|
|
||||||
|
|
||||||
# TODO: sync
|
|
||||||
# self.sync_in_progress = 1
|
|
||||||
# doc.run()
|
|
||||||
else:
|
else:
|
||||||
frappe.throw("No remote ID specified")
|
frappe.throw("No remote ID specified")
|
||||||
|
|
||||||
|
|||||||
@@ -832,7 +832,7 @@ erpnext.hub.Publish = class Publish extends SubPage {
|
|||||||
frappe.realtime.on("items-sync", (data) => {
|
frappe.realtime.on("items-sync", (data) => {
|
||||||
this.$wrapper.find('.progress-bar').css('width', data.progress_percent+'%');
|
this.$wrapper.find('.progress-bar').css('width', data.progress_percent+'%');
|
||||||
|
|
||||||
if(data.progress_percent === 100) {
|
if(data.progress_percent === 100 || data.progress_percent === '100') {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
hub.settings.sync_in_progress = 0;
|
hub.settings.sync_in_progress = 0;
|
||||||
frappe.db.get_doc('Hub Settings')
|
frappe.db.get_doc('Hub Settings')
|
||||||
@@ -1039,13 +1039,7 @@ erpnext.hub.Publish = class Publish extends SubPage {
|
|||||||
});
|
});
|
||||||
this.items_to_publish = items_to_publish;
|
this.items_to_publish = items_to_publish;
|
||||||
|
|
||||||
return frappe.db.set_value("Hub Settings", "Hub Settings", {
|
return this.set_sync(items_to_publish)
|
||||||
custom_data: JSON.stringify(items_to_publish),
|
|
||||||
// TODO: sync
|
|
||||||
// sync_in_progress: 1
|
|
||||||
}).then(() => {
|
|
||||||
hub.settings.sync_in_progress = 1;
|
|
||||||
})
|
|
||||||
.then(frappe.call(
|
.then(frappe.call(
|
||||||
'erpnext.hub_node.publish_selected_items',
|
'erpnext.hub_node.publish_selected_items',
|
||||||
{
|
{
|
||||||
@@ -1053,6 +1047,22 @@ erpnext.hub.Publish = class Publish extends SubPage {
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_sync(items_to_publish) {
|
||||||
|
hub.settings.sync_in_progress = 1;
|
||||||
|
return frappe.db.set_value("Hub Settings", "Hub Settings", {
|
||||||
|
custom_data: JSON.stringify(items_to_publish),
|
||||||
|
sync_in_progress: 1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
reset_sync() {
|
||||||
|
hub.settings.sync_in_progress = 0;
|
||||||
|
return frappe.db.set_value("Hub Settings", "Hub Settings", {
|
||||||
|
custom_data: '',
|
||||||
|
sync_in_progress: 0
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
erpnext.hub.PublishedProducts = class PublishedProducts extends SubPage {
|
erpnext.hub.PublishedProducts = class PublishedProducts extends SubPage {
|
||||||
|
|||||||
Reference in New Issue
Block a user