[Enhance] Fetch Customer's Item code based on Customer Name or Customer Group (#13198)
* customer code can be assigned based on customer group * improvise customer group selection * requested changes made
This commit is contained in:
parent
b2f7092f9e
commit
3fd634783d
@ -170,6 +170,35 @@ frappe.ui.form.on('Item Reorder', {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
frappe.ui.form.on('Item Customer Detail', {
|
||||||
|
customer_items_add: function(frm, cdt, cdn) {
|
||||||
|
frappe.model.set_value(cdt, cdn, 'customer_group', "");
|
||||||
|
},
|
||||||
|
customer_name: function(frm, cdt, cdn) {
|
||||||
|
set_customer_group(frm, cdt, cdn);
|
||||||
|
},
|
||||||
|
customer_group: function(frm, cdt, cdn) {
|
||||||
|
if(set_customer_group(frm, cdt, cdn)){
|
||||||
|
frappe.msgprint(__("Changing Customer Group for the selected Customer is not allowed."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var set_customer_group = function(frm, cdt, cdn) {
|
||||||
|
var row = frappe.get_doc(cdt, cdn);
|
||||||
|
|
||||||
|
if (!row.customer_name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
frappe.model.with_doc("Customer", row.customer_name, function() {
|
||||||
|
var customer = frappe.model.get_doc("Customer", row.customer_name);
|
||||||
|
row.customer_group = customer.customer_group;
|
||||||
|
refresh_field("customer_group", cdn, "customer_items");
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$.extend(erpnext.item, {
|
$.extend(erpnext.item, {
|
||||||
setup_queries: function(frm) {
|
setup_queries: function(frm) {
|
||||||
frm.fields_dict['expense_account'].get_query = function(doc) {
|
frm.fields_dict['expense_account'].get_query = function(doc) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"allow_copy": 0,
|
"allow_copy": 0,
|
||||||
|
"allow_guest_to_view": 0,
|
||||||
"allow_import": 0,
|
"allow_import": 0,
|
||||||
"allow_rename": 0,
|
"allow_rename": 0,
|
||||||
"autoname": "hash",
|
"autoname": "hash",
|
||||||
@ -12,16 +13,20 @@
|
|||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 1,
|
"bold": 1,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
"fieldname": "customer_name",
|
"fieldname": "customer_name",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
|
"in_global_search": 0,
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 0,
|
||||||
"label": "Customer Name",
|
"label": "Customer Name",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
@ -33,24 +38,62 @@
|
|||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"print_width": "180px",
|
"print_width": "180px",
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 1,
|
"reqd": 0,
|
||||||
"search_index": 1,
|
"search_index": 1,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0,
|
"unique": 0,
|
||||||
"width": "180px"
|
"width": "180px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
|
"bold": 1,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "customer_group",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 1,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Customer Group",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"options": "Customer Group",
|
||||||
|
"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_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
"fieldname": "ref_code",
|
"fieldname": "ref_code",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
|
"in_global_search": 0,
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 0,
|
||||||
"label": "Ref Code",
|
"label": "Ref Code",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
@ -61,25 +104,27 @@
|
|||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"print_width": "120px",
|
"print_width": "120px",
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 1,
|
"search_index": 1,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0,
|
"unique": 0,
|
||||||
"width": "120px"
|
"width": "120px"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"has_web_view": 0,
|
||||||
"hide_heading": 0,
|
"hide_heading": 0,
|
||||||
"hide_toolbar": 0,
|
"hide_toolbar": 0,
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"image_view": 0,
|
"image_view": 0,
|
||||||
"in_create": 0,
|
"in_create": 0,
|
||||||
"in_dialog": 0,
|
|
||||||
"is_submittable": 0,
|
"is_submittable": 0,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2016-07-11 03:28:00.992064",
|
"modified": "2018-03-08 14:22:38.019369",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Item Customer Detail",
|
"name": "Item Customer Detail",
|
||||||
@ -88,5 +133,7 @@
|
|||||||
"quick_entry": 0,
|
"quick_entry": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"read_only_onload": 0,
|
"read_only_onload": 0,
|
||||||
|
"show_name_in_global_search": 0,
|
||||||
|
"track_changes": 0,
|
||||||
"track_seen": 0
|
"track_seen": 0
|
||||||
}
|
}
|
@ -396,8 +396,16 @@ def validate_conversion_rate(args, meta):
|
|||||||
|
|
||||||
def get_party_item_code(args, item_doc, out):
|
def get_party_item_code(args, item_doc, out):
|
||||||
if args.transaction_type=="selling" and args.customer:
|
if args.transaction_type=="selling" and args.customer:
|
||||||
|
out.customer_item_code = None
|
||||||
customer_item_code = item_doc.get("customer_items", {"customer_name": args.customer})
|
customer_item_code = item_doc.get("customer_items", {"customer_name": args.customer})
|
||||||
out.customer_item_code = customer_item_code[0].ref_code if customer_item_code else None
|
|
||||||
|
if customer_item_code:
|
||||||
|
out.customer_item_code = customer_item_code[0].ref_code
|
||||||
|
else:
|
||||||
|
customer_group = frappe.db.get_value("Customer", args.customer, "customer_group")
|
||||||
|
customer_group_item_code = item_doc.get("customer_items", {"customer_group": customer_group})
|
||||||
|
if customer_group_item_code and not customer_group_item_code[0].customer_name:
|
||||||
|
out.customer_item_code = customer_group_item_code[0].ref_code
|
||||||
|
|
||||||
if args.transaction_type=="buying" and args.supplier:
|
if args.transaction_type=="buying" and args.supplier:
|
||||||
item_supplier = item_doc.get("supplier_items", {"supplier": args.supplier})
|
item_supplier = item_doc.get("supplier_items", {"supplier": args.supplier})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user