fix: create unpublish log on the hub

This commit is contained in:
Mangesh-Khairnar 2019-12-09 19:24:29 +05:30
parent d249d4c947
commit 0cb2783f80
3 changed files with 15 additions and 19 deletions

View File

@ -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():

View File

@ -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() {

View File

@ -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`);