Merge branch 'hub-redesign' of https://github.com/netchampfaris/erpnext into hub-redesign

This commit is contained in:
Faris Ansari
2018-07-26 18:39:34 +05:30
6 changed files with 146 additions and 165 deletions

View File

@@ -2,7 +2,7 @@
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe, requests, json
import frappe, requests, json, time
from frappe.utils import now, nowdate, cint
from frappe.utils.nestedset import get_root_of
from frappe.contacts.doctype.contact.contact import get_default_contact
@@ -47,9 +47,15 @@ def get_list(doctype, start=0, limit=20, fields=["*"], filters="{}", order_by=No
#### LOCAL ITEMS
@frappe.whitelist()
def get_valid_items(search_value=''):
items = frappe.get_list('Item', fields=["*"], filters={
'item_name': ['like', '%' + search_value + '%']
})
items = frappe.get_list(
'Item',
fields=["*"],
filters={
'item_name': ['like', '%' + search_value + '%'],
'publish_in_hub': 0
},
order_by="modified desc"
)
valid_items = filter(lambda x: x.image and x.description, items)
@@ -61,12 +67,13 @@ def get_valid_items(search_value=''):
return valid_items
@frappe.whitelist()
def publish_selected_items(items_to_publish, items_to_unpublish):
def publish_selected_items(items_to_publish):
for item_code in json.loads(items_to_publish):
frappe.db.set_value('Item', item_code, 'publish_in_hub', 1)
for item_code in json.loads(items_to_unpublish):
frappe.db.set_value('Item', item_code, 'publish_in_hub', 0)
# frappe.db.set_value("Hub Settings", "Hub Settings", "sync_in_progress", 1)
# time.sleep(10)
# frappe.db.set_value("Hub Settings", "Hub Settings", "sync_in_progress", 0)
hub_settings = frappe.get_doc('Hub Settings')
hub_settings.sync()