Merge pull request #15279 from netchampfaris/marketplace-fixes-3
- feat: Add disable marketplace option in Hub Settings - fix: Rename Hub Settings -> Marketplace Settings
This commit is contained in:
commit
c05bf262f1
@ -8,16 +8,16 @@ def get_data():
|
|||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Hub Settings"
|
"name": "Marketplace Settings"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": _("Hub"),
|
"label": _("Marketplace"),
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"type": "page",
|
"type": "page",
|
||||||
"name": "hub"
|
"name": "marketplace/home"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -6,12 +6,12 @@ import frappe
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def enable_hub():
|
def enable_hub():
|
||||||
hub_settings = frappe.get_doc('Hub Settings')
|
hub_settings = frappe.get_doc('Marketplace Settings')
|
||||||
hub_settings.register()
|
hub_settings.register()
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
return hub_settings
|
return hub_settings
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def sync():
|
def sync():
|
||||||
hub_settings = frappe.get_doc('Hub Settings')
|
hub_settings = frappe.get_doc('Marketplace Settings')
|
||||||
hub_settings.sync()
|
hub_settings.sync()
|
||||||
|
@ -24,7 +24,7 @@ def map_fields(items):
|
|||||||
field_mappings = get_field_mappings()
|
field_mappings = get_field_mappings()
|
||||||
table_fields = [d.fieldname for d in frappe.get_meta('Item').get_table_fields()]
|
table_fields = [d.fieldname for d in frappe.get_meta('Item').get_table_fields()]
|
||||||
|
|
||||||
hub_seller = frappe.db.get_value('Hub Settings' , 'Hub Settings', 'company_email')
|
hub_seller = frappe.db.get_value('Marketplace Settings' , 'Marketplace Settings', 'company_email')
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
for fieldname in table_fields:
|
for fieldname in table_fields:
|
||||||
@ -106,7 +106,7 @@ def item_sync_preprocess(intended_item_publish_count):
|
|||||||
})
|
})
|
||||||
|
|
||||||
if response:
|
if response:
|
||||||
frappe.db.set_value("Hub Settings", "Hub Settings", "sync_in_progress", 1)
|
frappe.db.set_value("Marketplace Settings", "Marketplace Settings", "sync_in_progress", 1)
|
||||||
return response
|
return response
|
||||||
else:
|
else:
|
||||||
frappe.throw('Unable to update remote activity')
|
frappe.throw('Unable to update remote activity')
|
||||||
@ -114,11 +114,11 @@ def item_sync_preprocess(intended_item_publish_count):
|
|||||||
def item_sync_postprocess():
|
def item_sync_postprocess():
|
||||||
response = call_hub_method('post_items_publish', {})
|
response = call_hub_method('post_items_publish', {})
|
||||||
if response:
|
if response:
|
||||||
frappe.db.set_value('Hub Settings', 'Hub Settings', 'last_sync_datetime', frappe.utils.now())
|
frappe.db.set_value('Marketplace Settings', 'Marketplace Settings', 'last_sync_datetime', frappe.utils.now())
|
||||||
else:
|
else:
|
||||||
frappe.throw('Unable to update remote activity')
|
frappe.throw('Unable to update remote activity')
|
||||||
|
|
||||||
frappe.db.set_value('Hub Settings', 'Hub Settings', 'sync_in_progress', 0)
|
frappe.db.set_value('Marketplace Settings', 'Marketplace Settings', 'sync_in_progress', 0)
|
||||||
|
|
||||||
|
|
||||||
def load_base64_image_from_items(items):
|
def load_base64_image_from_items(items):
|
||||||
@ -162,7 +162,7 @@ def get_hub_connection():
|
|||||||
|
|
||||||
# read-only connection
|
# read-only connection
|
||||||
if read_only:
|
if read_only:
|
||||||
hub_url = frappe.db.get_single_value('Hub Settings', 'hub_url')
|
hub_url = frappe.db.get_single_value('Marketplace Settings', 'hub_url')
|
||||||
hub_connection = FrappeClient(hub_url)
|
hub_connection = FrappeClient(hub_url)
|
||||||
return hub_connection
|
return hub_connection
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
frappe.ui.form.on("Hub Settings", {
|
|
||||||
onload_post_render: function() {},
|
|
||||||
});
|
|
@ -1,23 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
// rename this file from _test_[name] to test_[name] to activate
|
|
||||||
// and remove above this line
|
|
||||||
|
|
||||||
QUnit.test("test: Hub Settings", function (assert) {
|
|
||||||
let done = assert.async();
|
|
||||||
|
|
||||||
// number of asserts
|
|
||||||
assert.expect(1);
|
|
||||||
|
|
||||||
frappe.run_serially('Hub Settings', [
|
|
||||||
// insert a new Hub Settings
|
|
||||||
() => frappe.tests.make([
|
|
||||||
// values to be set
|
|
||||||
{key: 'value'}
|
|
||||||
]),
|
|
||||||
() => {
|
|
||||||
assert.equal(cur_frm.doc.key, 'value');
|
|
||||||
},
|
|
||||||
() => done()
|
|
||||||
]);
|
|
||||||
|
|
||||||
});
|
|
@ -1,10 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
|
|
||||||
# See license.txt
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import frappe
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
class TestHubSettings(unittest.TestCase):
|
|
||||||
pass
|
|
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on('Marketplace Settings', {
|
||||||
|
refresh: function(frm) {
|
||||||
|
$('#toolbar-user .marketplace-link').toggle(!frm.doc.disable_marketplace);
|
||||||
|
},
|
||||||
|
});
|
@ -4,14 +4,80 @@
|
|||||||
"allow_import": 0,
|
"allow_import": 0,
|
||||||
"allow_rename": 0,
|
"allow_rename": 0,
|
||||||
"beta": 1,
|
"beta": 1,
|
||||||
"creation": "2015-02-18 00:59:34.560476",
|
"creation": "2018-08-31 15:54:38.795263",
|
||||||
"custom": 0,
|
"custom": 0,
|
||||||
"description": "",
|
"description": "",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"document_type": "",
|
"document_type": "",
|
||||||
"editable_grid": 0,
|
"editable_grid": 0,
|
||||||
|
"engine": "InnoDB",
|
||||||
"fields": [
|
"fields": [
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "disable_marketplace",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Disable Marketplace",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"depends_on": "eval:!doc.disable_marketplace",
|
||||||
|
"fieldname": "marketplace_settings_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Marketplace Settings",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_in_quick_entry": 0,
|
"allow_in_quick_entry": 0,
|
||||||
@ -20,7 +86,7 @@
|
|||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"default": "https://hubmarket.org",
|
"default": "https://hubmarket.org",
|
||||||
"fieldname": "hub_url",
|
"fieldname": "marketplace_url",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
@ -29,7 +95,7 @@
|
|||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Hub URL",
|
"label": "Marketplace URL",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
@ -86,7 +152,7 @@
|
|||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fieldname": "sync_in_progress",
|
"fieldname": "sync_in_progress",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"hidden": 0,
|
"hidden": 1,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
@ -401,72 +467,6 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 1,
|
|
||||||
"collapsible_depends_on": "",
|
|
||||||
"columns": 0,
|
|
||||||
"depends_on": "enabled",
|
|
||||||
"fieldname": "unregister_section",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Unregister",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "unregister_from_hub",
|
|
||||||
"fieldtype": "Button",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Unregister from Hub",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 0,
|
"has_web_view": 0,
|
||||||
@ -479,12 +479,12 @@
|
|||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-08-29 17:46:30.413159",
|
"modified": "2018-08-31 15:54:38.795263",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "netchamp@rawcoderz.com",
|
||||||
"module": "Hub Node",
|
"module": "Hub Node",
|
||||||
"name": "Hub Settings",
|
"name": "Marketplace Settings",
|
||||||
"name_case": "",
|
"name_case": "",
|
||||||
"owner": "Administrator",
|
"owner": "netchamp@rawcoderz.com",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
"amend": 0,
|
"amend": 0,
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and contributors
|
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors and contributors
|
||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
@ -10,15 +10,13 @@ from frappe import _
|
|||||||
from erpnext.utilities.product import get_price, get_qty_in_stock
|
from erpnext.utilities.product import get_price, get_qty_in_stock
|
||||||
from six import string_types
|
from six import string_types
|
||||||
|
|
||||||
class HubSetupError(frappe.ValidationError): pass
|
class MarketplaceSettings(Document):
|
||||||
|
|
||||||
class HubSettings(Document):
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.site_name = frappe.utils.get_url()
|
self.site_name = frappe.utils.get_url()
|
||||||
|
|
||||||
def get_hub_url(self):
|
def get_marketplace_url(self):
|
||||||
return self.hub_url
|
return self.marketplace_url
|
||||||
|
|
||||||
def register(self):
|
def register(self):
|
||||||
""" Create a User on hub.erpnext.org and return username/password """
|
""" Create a User on hub.erpnext.org and return username/password """
|
||||||
@ -34,7 +32,7 @@ class HubSettings(Document):
|
|||||||
data = {
|
data = {
|
||||||
'profile': self.as_json()
|
'profile': self.as_json()
|
||||||
}
|
}
|
||||||
post_url = self.get_hub_url() + '/api/method/hub.hub.api.register'
|
post_url = self.get_marketplace_url() + '/api/method/hub.hub.api.register'
|
||||||
|
|
||||||
response = requests.post(post_url, data=data, headers = {'accept': 'application/json'})
|
response = requests.post(post_url, data=data, headers = {'accept': 'application/json'})
|
||||||
|
|
||||||
@ -68,7 +66,7 @@ class HubSettings(Document):
|
|||||||
def create_hub_connector(self, message):
|
def create_hub_connector(self, message):
|
||||||
if frappe.db.exists('Data Migration Connector', 'Hub Connector'):
|
if frappe.db.exists('Data Migration Connector', 'Hub Connector'):
|
||||||
hub_connector = frappe.get_doc('Data Migration Connector', 'Hub Connector')
|
hub_connector = frappe.get_doc('Data Migration Connector', 'Hub Connector')
|
||||||
hub_connector.hostname = self.get_hub_url()
|
hub_connector.hostname = self.get_marketplace_url()
|
||||||
hub_connector.username = message['email']
|
hub_connector.username = message['email']
|
||||||
hub_connector.password = message['password']
|
hub_connector.password = message['password']
|
||||||
hub_connector.save()
|
hub_connector.save()
|
||||||
@ -78,19 +76,19 @@ class HubSettings(Document):
|
|||||||
'doctype': 'Data Migration Connector',
|
'doctype': 'Data Migration Connector',
|
||||||
'connector_type': 'Frappe',
|
'connector_type': 'Frappe',
|
||||||
'connector_name': 'Hub Connector',
|
'connector_name': 'Hub Connector',
|
||||||
'hostname': self.get_hub_url(),
|
'hostname': self.get_marketplace_url(),
|
||||||
'username': message['email'],
|
'username': message['email'],
|
||||||
'password': message['password']
|
'password': message['password']
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
def reset_hub_publishing_settings(last_sync_datetime = ""):
|
def reset_hub_publishing_settings(last_sync_datetime = ""):
|
||||||
doc = frappe.get_doc("Hub Settings", "Hub Settings")
|
doc = frappe.get_doc("Marketplace Settings", "Marketplace Settings")
|
||||||
doc.reset_publishing_settings(last_sync_datetime)
|
doc.reset_publishing_settings(last_sync_datetime)
|
||||||
doc.in_callback = 1
|
doc.in_callback = 1
|
||||||
doc.save()
|
doc.save()
|
||||||
|
|
||||||
def reset_hub_settings(last_sync_datetime = ""):
|
def reset_hub_settings(last_sync_datetime = ""):
|
||||||
doc = frappe.get_doc("Hub Settings", "Hub Settings")
|
doc = frappe.get_doc("Marketplace Settings", "Marketplace Settings")
|
||||||
doc.reset_publishing_settings(last_sync_datetime)
|
doc.reset_publishing_settings(last_sync_datetime)
|
||||||
doc.reset_enable()
|
doc.reset_enable()
|
||||||
doc.in_callback = 1
|
doc.in_callback = 1
|
||||||
@ -99,7 +97,7 @@ def reset_hub_settings(last_sync_datetime = ""):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def register_seller(**kwargs):
|
def register_seller(**kwargs):
|
||||||
settings = frappe.get_doc('Hub Settings')
|
settings = frappe.get_doc('Marketplace Settings')
|
||||||
settings.update(kwargs)
|
settings.update(kwargs)
|
||||||
message = settings.register()
|
message = settings.register()
|
||||||
|
|
@ -101,7 +101,7 @@ def make_rfq(item, supplier, contact):
|
|||||||
'doctype': 'Request for Quotation',
|
'doctype': 'Request for Quotation',
|
||||||
'transaction_date': nowdate(),
|
'transaction_date': nowdate(),
|
||||||
'status': 'Draft',
|
'status': 'Draft',
|
||||||
'company': frappe.db.get_single_value('Hub Settings', 'company'),
|
'company': frappe.db.get_single_value('Marketplace Settings', 'company'),
|
||||||
'message_for_supplier': 'Please supply the specified items at the best possible rates',
|
'message_for_supplier': 'Please supply the specified items at the best possible rates',
|
||||||
'suppliers': [
|
'suppliers': [
|
||||||
{ 'supplier': supplier.name, 'contact': contact.name }
|
{ 'supplier': supplier.name, 'contact': contact.name }
|
||||||
@ -126,8 +126,8 @@ def send_opportunity(contact):
|
|||||||
# Make Hub Message on Hub with lead data
|
# Make Hub Message on Hub with lead data
|
||||||
doc = {
|
doc = {
|
||||||
'doctype': 'Lead',
|
'doctype': 'Lead',
|
||||||
'lead_name': frappe.db.get_single_value('Hub Settings', 'company'),
|
'lead_name': frappe.db.get_single_value('Marketplace Settings', 'company'),
|
||||||
'email_id': frappe.db.get_single_value('Hub Settings', 'user')
|
'email_id': frappe.db.get_single_value('Marketplace Settings', 'user')
|
||||||
}
|
}
|
||||||
|
|
||||||
args = frappe._dict(dict(
|
args = frappe._dict(dict(
|
||||||
|
@ -560,6 +560,6 @@ erpnext.patches.v10_0.update_address_template_for_india
|
|||||||
erpnext.patches.v11_0.add_expense_claim_default_account
|
erpnext.patches.v11_0.add_expense_claim_default_account
|
||||||
execute:frappe.delete_doc("Page", "hub")
|
execute:frappe.delete_doc("Page", "hub")
|
||||||
erpnext.patches.v11_0.reset_publish_in_hub_for_all_items
|
erpnext.patches.v11_0.reset_publish_in_hub_for_all_items
|
||||||
erpnext.patches.v11_0.update_hub_url
|
erpnext.patches.v11_0.update_hub_url # 2018-08-31
|
||||||
erpnext.patches.v10_0.set_discount_amount
|
erpnext.patches.v10_0.set_discount_amount
|
||||||
erpnext.patches.v10_0.recalculate_gross_margin_for_project
|
erpnext.patches.v10_0.recalculate_gross_margin_for_project
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
frappe.reload_doc('hub_node', 'doctype', 'Hub Settings')
|
frappe.reload_doc('hub_node', 'doctype', 'Marketplace Settings')
|
||||||
frappe.db.set_value('Hub Settings', 'Hub Settings', 'hub_url', 'https://hubmarket.org')
|
frappe.db.set_value('Marketplace Settings', 'Marketplace Settings', 'hub_url', 'https://hubmarket.org')
|
||||||
|
@ -2,12 +2,20 @@ frappe.provide('erpnext.hub');
|
|||||||
|
|
||||||
frappe.views.marketplaceFactory = class marketplaceFactory extends frappe.views.Factory {
|
frappe.views.marketplaceFactory = class marketplaceFactory extends frappe.views.Factory {
|
||||||
show() {
|
show() {
|
||||||
if (frappe.pages.marketplace) {
|
is_marketplace_disabled()
|
||||||
frappe.container.change_to('marketplace');
|
.then(disabled => {
|
||||||
erpnext.hub.marketplace.refresh();
|
if (disabled) {
|
||||||
} else {
|
frappe.show_not_found('Marketplace');
|
||||||
this.make('marketplace');
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (frappe.pages.marketplace) {
|
||||||
|
frappe.container.change_to('marketplace');
|
||||||
|
erpnext.hub.marketplace.refresh();
|
||||||
|
} else {
|
||||||
|
this.make('marketplace');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
make(page_name) {
|
make(page_name) {
|
||||||
@ -23,10 +31,22 @@ frappe.views.marketplaceFactory = class marketplaceFactory extends frappe.views.
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function is_marketplace_disabled() {
|
||||||
|
return frappe.model.with_doc('Marketplace Settings')
|
||||||
|
.then(doc => doc.disable_marketplace);
|
||||||
|
}
|
||||||
|
|
||||||
$(document).on('toolbar_setup', () => {
|
$(document).on('toolbar_setup', () => {
|
||||||
$('#toolbar-user .navbar-reload').after(`
|
$('#toolbar-user .navbar-reload').after(`
|
||||||
<li>
|
<li>
|
||||||
<a href="#marketplace/home">${__('Marketplace')}
|
<a class="marketplace-link" href="#marketplace/home">${__('Marketplace')}
|
||||||
</li>
|
</li>
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
is_marketplace_disabled()
|
||||||
|
.then(disabled => {
|
||||||
|
if (disabled) {
|
||||||
|
$('#toolbar-user .marketplace-link').hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -20,20 +20,19 @@ erpnext.hub.Marketplace = class Marketplace {
|
|||||||
this.$parent = $(parent);
|
this.$parent = $(parent);
|
||||||
this.page = parent.page;
|
this.page = parent.page;
|
||||||
|
|
||||||
frappe.db.get_doc('Hub Settings')
|
frappe.model.with_doc('Marketplace Settings').then(doc => {
|
||||||
.then(doc => {
|
hub.settings = doc;
|
||||||
hub.settings = doc;
|
const is_registered = hub.settings.registered;
|
||||||
const is_registered = hub.settings.registered;
|
const is_registered_seller = hub.settings.company_email === frappe.session.user;
|
||||||
const is_registered_seller = hub.settings.company_email === frappe.session.user;
|
this.setup_header();
|
||||||
this.setup_header();
|
this.make_sidebar();
|
||||||
this.make_sidebar();
|
this.make_body();
|
||||||
this.make_body();
|
this.setup_events();
|
||||||
this.setup_events();
|
this.refresh();
|
||||||
this.refresh();
|
if (!is_registered && !is_registered_seller && frappe.user_roles.includes('System Manager')) {
|
||||||
if (!is_registered && !is_registered_seller && frappe.user_roles.includes('System Manager')) {
|
this.page.set_primary_action('Become a Seller', this.show_register_dialog.bind(this))
|
||||||
this.page.set_primary_action('Become a Seller', this.show_register_dialog.bind(this))
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_header() {
|
setup_header() {
|
||||||
@ -78,7 +77,7 @@ erpnext.hub.Marketplace = class Marketplace {
|
|||||||
|
|
||||||
erpnext.hub.on('seller-registered', () => {
|
erpnext.hub.on('seller-registered', () => {
|
||||||
this.page.clear_primary_action()
|
this.page.clear_primary_action()
|
||||||
frappe.db.get_doc('Hub Settings').then((doc)=> {
|
frappe.model.with_doc('Marketplace Settings').then((doc)=> {
|
||||||
hub.settings = doc;
|
hub.settings = doc;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -138,7 +138,7 @@ export default {
|
|||||||
)
|
)
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
this.selected_items = [];
|
this.selected_items = [];
|
||||||
return frappe.db.get_doc('Hub Settings');
|
return frappe.db.get_doc('Marketplace Settings');
|
||||||
})
|
})
|
||||||
.then(doc => {
|
.then(doc => {
|
||||||
hub.settings = doc;
|
hub.settings = doc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user