diff --git a/erpnext/hub_node/api.py b/erpnext/hub_node/api.py index b0b00b2b46..3a5b06fdc4 100644 --- a/erpnext/hub_node/api.py +++ b/erpnext/hub_node/api.py @@ -148,21 +148,17 @@ def publish_selected_items(items_to_publish): frappe.log_error(message=e, title='Hub Sync Error') @frappe.whitelist() -def unpublish_item(item): +def unpublish_item(item_code, hub_item_name): ''' Remove item listing from the marketplace ''' - item = json.loads(item) - item_code = item.get('item_code') - frappe.db.set_value('Item', item_code, 'publish_in_hub', 0) + response = call_hub_method('unpublish_item', { + 'hub_item_name': hub_item_name + }) - item = map_fields([item])[0] - - try: - connection = get_hub_connection() - connection.set_value('Hub Item', item.get('name'), 'published', 0) - - except Exception as e: - frappe.log_error(message=e, title='Hub Sync Error') + if response: + frappe.db.set_value('Item', item_code, 'publish_in_hub', 0) + else: + frappe.throw(_('Unable to update remote activity')) @frappe.whitelist() def get_unregistered_users(): diff --git a/erpnext/public/js/hub/pages/Home.vue b/erpnext/public/js/hub/pages/Home.vue index 84a42367b2..79cfe46e15 100644 --- a/erpnext/public/js/hub/pages/Home.vue +++ b/erpnext/public/js/hub/pages/Home.vue @@ -58,10 +58,10 @@ export default { this.search_value = ''; this.get_items(); }, - watch:{ - $route (to, from){ - this.get_items() - } + mounted() { + frappe.route.on('change', () => { + this.get_items(); + }) }, methods: { get_items() { diff --git a/erpnext/public/js/hub/pages/Item.vue b/erpnext/public/js/hub/pages/Item.vue index e4b0eeaecb..d0c0ebe603 100644 --- a/erpnext/public/js/hub/pages/Item.vue +++ b/erpnext/public/js/hub/pages/Item.vue @@ -309,11 +309,11 @@ export default { }, unpublish_item() { - let me = this; - frappe.confirm(__(`Unpublish ${this.item.item_name}?`), function() { + frappe.confirm(__(`Unpublish ${this.item.item_name}?`), () => { frappe .call('erpnext.hub_node.api.unpublish_item', { - item: me.item + item_code: this.item.item_code, + hub_item_name: this.hub_item_name }) .then(r => { frappe.set_route(`marketplace/home`);