Update entity properties
This commit is contained in:
parent
6ee035ba5b
commit
2073959bb8
@ -35,15 +35,17 @@ def get_categories(parent='All Categories'):
|
|||||||
# get categories info with parent category and stuff
|
# get categories info with parent category and stuff
|
||||||
connection = get_client_connection()
|
connection = get_client_connection()
|
||||||
categories = connection.get_list('Hub Category', filters={'parent_hub_category': parent})
|
categories = connection.get_list('Hub Category', filters={'parent_hub_category': parent})
|
||||||
# print("============================================================")
|
|
||||||
# print(categories)
|
|
||||||
response = [{'value': c.get('name'), 'expandable': c.get('is_group')} for c in categories]
|
response = [{'value': c.get('name'), 'expandable': c.get('is_group')} for c in categories]
|
||||||
return response
|
return response
|
||||||
|
|
||||||
# return [
|
@frappe.whitelist()
|
||||||
# {'value': 'Men', 'expandable': 1},
|
def update_category(item_name, category):
|
||||||
# {'value': 'Women', 'expandable': 0}
|
connection = get_hub_connection()
|
||||||
# ]
|
response = connection.update('Hub Item', dict(
|
||||||
|
hub_category = category
|
||||||
|
), item_name)
|
||||||
|
return response.ok
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_details(hub_sync_id=None, doctype='Hub Item'):
|
def get_details(hub_sync_id=None, doctype='Hub Item'):
|
||||||
@ -53,11 +55,6 @@ def get_details(hub_sync_id=None, doctype='Hub Item'):
|
|||||||
details = connection.get_doc(doctype, hub_sync_id)
|
details = connection.get_doc(doctype, hub_sync_id)
|
||||||
return details
|
return details
|
||||||
|
|
||||||
# @frappe.whitelist()
|
|
||||||
# def get_company_details(hub_sync_id):
|
|
||||||
# connection = get_client_connection()
|
|
||||||
# return connection.get_doc('Hub Company', hub_sync_id)
|
|
||||||
|
|
||||||
def get_client_connection():
|
def get_client_connection():
|
||||||
# frappeclient connection
|
# frappeclient connection
|
||||||
hub_connection = get_hub_connection()
|
hub_connection = get_hub_connection()
|
||||||
|
@ -484,7 +484,7 @@ erpnext.patches.v10_0.enabled_regional_print_format_based_on_country
|
|||||||
erpnext.patches.v10_0.update_asset_calculate_depreciation
|
erpnext.patches.v10_0.update_asset_calculate_depreciation
|
||||||
erpnext.patches.v10_0.add_guardian_role_for_parent_portal
|
erpnext.patches.v10_0.add_guardian_role_for_parent_portal
|
||||||
erpnext.patches.v10_0.set_numeric_ranges_in_template_if_blank
|
erpnext.patches.v10_0.set_numeric_ranges_in_template_if_blank
|
||||||
#erpnext.patches.v10_0.update_reserved_qty_for_purchase_order
|
erpnext.patches.v10_0.update_reserved_qty_for_purchase_order
|
||||||
erpnext.patches.v10_0.fichier_des_ecritures_comptables_for_france
|
erpnext.patches.v10_0.fichier_des_ecritures_comptables_for_france
|
||||||
erpnext.patches.v10_0.update_assessment_plan
|
erpnext.patches.v10_0.update_assessment_plan
|
||||||
erpnext.patches.v10_0.update_assessment_result
|
erpnext.patches.v10_0.update_assessment_result
|
||||||
@ -493,4 +493,4 @@ erpnext.patches.v10_0.workflow_leave_application #2018-01-24 #2018-02-02 #2018-0
|
|||||||
erpnext.patches.v10_0.set_default_payment_terms_based_on_company
|
erpnext.patches.v10_0.set_default_payment_terms_based_on_company
|
||||||
erpnext.patches.v10_0.update_sales_order_link_to_purchase_order
|
erpnext.patches.v10_0.update_sales_order_link_to_purchase_order
|
||||||
erpnext.patches.v10_0.added_extra_gst_custom_field_in_gstr2
|
erpnext.patches.v10_0.added_extra_gst_custom_field_in_gstr2
|
||||||
#erpnext.patches.v10_0.item_barcode_childtable_migrate
|
erpnext.patches.v10_0.item_barcode_childtable_migrate
|
||||||
|
@ -15,30 +15,33 @@ frappe.views.HubFactory = frappe.views.Factory.extend({
|
|||||||
'/assets/erpnext/css/hub.css',
|
'/assets/erpnext/css/hub.css',
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
frappe.model.with_doc('Hub Settings', 'Hub Settings', () => {
|
||||||
|
this.hub_settings = frappe.get_doc('Hub Settings');
|
||||||
|
|
||||||
if (!erpnext.hub.pages[page_name]) {
|
if (!erpnext.hub.pages[page_name]) {
|
||||||
if (!route[2]) {
|
if (!route[2]) {
|
||||||
// page === 'Item' &&
|
frappe.require(assets['List'], () => {
|
||||||
frappe.require(assets['List'], () => {
|
erpnext.hub.pages[page_name] = new erpnext.hub[page+'Listing']({
|
||||||
erpnext.hub.pages[page_name] = new erpnext.hub[page+'Listing']({
|
parent: this.make_page(true, page_name),
|
||||||
doctype: 'Hub Settings',
|
hub_settings: this.hub_settings
|
||||||
parent: this.make_page(true, page_name)
|
});
|
||||||
|
window.hub_page = erpnext.hub.pages[page_name];
|
||||||
});
|
});
|
||||||
window.hub_page = erpnext.hub.pages[page_name];
|
} else {
|
||||||
});
|
frappe.require(assets['Form'], () => {
|
||||||
|
erpnext.hub.pages[page_name] = new erpnext.hub[page+'Page']({
|
||||||
|
unique_id: route[2],
|
||||||
|
doctype: route[2],
|
||||||
|
parent: this.make_page(true, page_name),
|
||||||
|
hub_settings: this.hub_settings
|
||||||
|
});
|
||||||
|
window.hub_page = erpnext.hub.pages[page_name];
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
frappe.require(assets['Form'], () => {
|
frappe.container.change_to(page_name);
|
||||||
erpnext.hub.pages[page_name] = new erpnext.hub[page+'Page']({
|
window.hub_page = erpnext.hub.pages[page_name];
|
||||||
unique_id: route[2],
|
|
||||||
doctype: 'Hub Settings',
|
|
||||||
parent: this.make_page(true, page_name)
|
|
||||||
});
|
|
||||||
window.hub_page = erpnext.hub.pages[page_name];
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
frappe.container.change_to(page_name);
|
|
||||||
window.hub_page = erpnext.hub.pages[page_name];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -4,11 +4,11 @@ erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList {
|
|||||||
setup_defaults() {
|
setup_defaults() {
|
||||||
super.setup_defaults();
|
super.setup_defaults();
|
||||||
this.method = 'erpnext.hub_node.get_details';
|
this.method = 'erpnext.hub_node.get_details';
|
||||||
//doctype, unique_id,
|
const route = frappe.get_route();
|
||||||
|
this.page_name = route[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
set_breadcrumbs() {
|
set_breadcrumbs() {
|
||||||
this.set_title();
|
|
||||||
frappe.breadcrumbs.add({
|
frappe.breadcrumbs.add({
|
||||||
label: __('Hub'),
|
label: __('Hub'),
|
||||||
route: '#Hub/' + this.doctype,
|
route: '#Hub/' + this.doctype,
|
||||||
@ -16,10 +16,6 @@ erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
set_title() {
|
|
||||||
this.page_title = this.data.item_name || this.hub_item_code || 'Hub' + this.doctype;
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_side_bar() {
|
setup_side_bar() {
|
||||||
this.sidebar = new frappe.ui.Sidebar({
|
this.sidebar = new frappe.ui.Sidebar({
|
||||||
wrapper: this.$page.find('.layout-side-section'),
|
wrapper: this.$page.find('.layout-side-section'),
|
||||||
@ -56,15 +52,7 @@ erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList {
|
|||||||
label: image_html
|
label: image_html
|
||||||
});
|
});
|
||||||
|
|
||||||
let fields = [];
|
let fields = this.get_field_configs();
|
||||||
this.fields.map(fieldname => {
|
|
||||||
fields.push({
|
|
||||||
label: toTitle(frappe.model.unscrub(fieldname)),
|
|
||||||
fieldname,
|
|
||||||
fieldtype: 'Data',
|
|
||||||
read_only: 1
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
this.form = new frappe.ui.FieldGroup({
|
this.form = new frappe.ui.FieldGroup({
|
||||||
parent: this.$result,
|
parent: this.$result,
|
||||||
@ -93,39 +81,51 @@ erpnext.hub.ItemPage = class ItemPage extends erpnext.hub.HubForm{
|
|||||||
this.image_field_name = 'image';
|
this.image_field_name = 'image';
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_fields() {
|
get_field_configs() {
|
||||||
this.fields = ['hub_item_code', 'item_name', 'item_code', 'description',
|
let fields = [];
|
||||||
'seller', 'company_name', 'country', 'hub_category'];
|
this.fields.map(fieldname => {
|
||||||
|
fields.push({
|
||||||
|
label: toTitle(frappe.model.unscrub(fieldname)),
|
||||||
|
fieldname,
|
||||||
|
fieldtype: 'Data',
|
||||||
|
read_only: 1
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
let category_field = {
|
||||||
|
label: 'Hub Category',
|
||||||
|
fieldname: 'hub_category',
|
||||||
|
fieldtype: 'Data'
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.data.company_name === this.hub_settings.company) {
|
||||||
|
this.page.set_primary_action(__('Update'), () => {
|
||||||
|
this.update_on_hub();
|
||||||
|
}, 'octicon octicon-plus');
|
||||||
|
} else {
|
||||||
|
category_field.read_only = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fields.push(category_field);
|
||||||
|
|
||||||
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
show_action_modal(item) {
|
update_on_hub() {
|
||||||
return new Promise(res => {
|
return new Promise((resolve, reject) => {
|
||||||
let fields = [
|
frappe.call({
|
||||||
{ label: __('Item Code'), fieldtype: 'Data', fieldname: 'item_code', default: item.item_code },
|
method: 'erpnext.hub_node.update_category',
|
||||||
{ fieldtype: 'Column Break' },
|
args: { item: this.unique_id, category: this.form.get_value('hub_category') },
|
||||||
{ label: __('Item Group'), fieldtype: 'Link', fieldname: 'item_group', default: item.item_group },
|
callback: resolve,
|
||||||
{ label: __('Supplier Details'), fieldtype: 'Section Break' },
|
freeze: true
|
||||||
{ label: __('Supplier Name'), fieldtype: 'Data', fieldname: 'supplier_name', default: item.company_name },
|
}).fail(reject);
|
||||||
{ label: __('Supplier Email'), fieldtype: 'Data', fieldname: 'supplier_email', default: item.seller },
|
|
||||||
{ fieldtype: 'Column Break' },
|
|
||||||
{ label: __('Supplier Type'), fieldname: 'supplier_type',
|
|
||||||
fieldtype: 'Link', options: 'Supplier Type' }
|
|
||||||
];
|
|
||||||
fields = fields.map(f => { f.reqd = 1; return f; });
|
|
||||||
|
|
||||||
const d = new frappe.ui.Dialog({
|
|
||||||
title: __('Request for Quotation'),
|
|
||||||
fields: fields,
|
|
||||||
primary_action_label: __('Send'),
|
|
||||||
primary_action: (values) => {
|
|
||||||
res(values);
|
|
||||||
d.hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
d.show();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setup_fields() {
|
||||||
|
this.fields = ['hub_item_code', 'item_name', 'item_code', 'description',
|
||||||
|
'seller', 'company_name', 'country'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
erpnext.hub.CompanyPage = class CompanyPage extends erpnext.hub.HubForm{
|
erpnext.hub.CompanyPage = class CompanyPage extends erpnext.hub.HubForm{
|
||||||
@ -135,6 +135,20 @@ erpnext.hub.CompanyPage = class CompanyPage extends erpnext.hub.HubForm{
|
|||||||
this.image_field_name = 'company_logo';
|
this.image_field_name = 'company_logo';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_field_configs() {
|
||||||
|
let fields = [];
|
||||||
|
this.fields.map(fieldname => {
|
||||||
|
fields.push({
|
||||||
|
label: toTitle(frappe.model.unscrub(fieldname)),
|
||||||
|
fieldname,
|
||||||
|
fieldtype: 'Data',
|
||||||
|
read_only: 1
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
setup_fields() {
|
setup_fields() {
|
||||||
this.fields = ['company_name', 'description', 'route', 'country', 'seller', 'site_name'];
|
this.fields = ['company_name', 'description', 'route', 'country', 'seller', 'site_name'];
|
||||||
}
|
}
|
||||||
|
@ -126,6 +126,21 @@ erpnext.hub.ItemListing = class ItemListing extends erpnext.hub.HubListing {
|
|||||||
this.update_category(node.label);
|
this.update_category(node.label);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.sidebar.add_item({
|
||||||
|
label: this.hub_settings.company,
|
||||||
|
on_click: () => frappe.set_route('Form', 'Company', this.hub_settings.company)
|
||||||
|
}, __("Account"));
|
||||||
|
|
||||||
|
this.sidebar.add_item({
|
||||||
|
label: __('Companies'),
|
||||||
|
on_click: () => frappe.set_route('Hub', 'Company')
|
||||||
|
});
|
||||||
|
|
||||||
|
this.sidebar.add_item({
|
||||||
|
label: __("My Orders"),
|
||||||
|
on_click: () => frappe.set_route('List', 'Request for Quotation')
|
||||||
|
}, __("Account"));
|
||||||
}
|
}
|
||||||
|
|
||||||
update_category(label) {
|
update_category(label) {
|
||||||
@ -171,9 +186,10 @@ erpnext.hub.ItemListing = class ItemListing extends erpnext.hub.HubListing {
|
|||||||
<h5 class="bold">
|
<h5 class="bold">
|
||||||
${ title }
|
${ title }
|
||||||
</h5>
|
</h5>
|
||||||
<p>${ company_name }</p>
|
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
<a href="${'#Hub/Company/'+company_name}"><p>${ company_name }</p></a>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user