Skip to content

Commit

Permalink
feat(selling): added delivery days to customer doctype (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
MyuddinKhatri committed Sep 8, 2020
1 parent 4fb228a commit 1b8f6f2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 10 deletions.
28 changes: 26 additions & 2 deletions erpnext/selling/doctype/customer/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,28 @@ frappe.ui.form.on("Customer", {
}
},

onload: function (frm) {
let days_of_week = moment.weekdays();
let fields = [];
days_of_week.forEach(day => {
fields.push({
"label": __(day),
"value": day,
"checked": frm.doc.delivery_days ? JSON.parse(frm.doc.delivery_days).includes(day) : 0
})
});
frm.days_selected = frappe.ui.form.make_control({
parent: frm.get_field('delivery_days_html').wrapper,
df: {
fieldname: 'days_of_week',
fieldtype: 'MultiCheck',
columns: 4,
options: fields
},
render_input: true
});
},

refresh: function(frm) {
if(frappe.defaults.get_default("cust_master_name")!="Naming Series") {
frm.toggle_display("naming_series", false);
Expand Down Expand Up @@ -153,7 +175,9 @@ frappe.ui.form.on("Customer", {
},
validate: function(frm) {
if(frm.doc.lead_name) frappe.model.clear_doc("Lead", frm.doc.lead_name);

if(frm.days_selected) {
frm.set_value("delivery_days", JSON.stringify(frm.days_selected.get_value()));
}
},
make_dashboard_and_show_progress: function(frm) {
let bars = [];
Expand Down Expand Up @@ -185,4 +209,4 @@ frappe.ui.form.on("Customer", {
frm.dashboard.add_progress(__('Status'), bars, message).appendTo(section)
frm.dashboard.show();
}
});
});
30 changes: 22 additions & 8 deletions erpnext/selling/doctype/customer/customer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"actions": [],
"allow_events_in_timeline": 1,
"allow_import": 1,
"allow_rename": 1,
Expand Down Expand Up @@ -59,6 +58,9 @@
"delivery_start_time",
"column_break_42",
"delivery_end_time",
"delivery_days_section",
"delivery_days_html",
"delivery_days",
"credit_limit_section",
"payment_terms",
"credit_limits",
Expand Down Expand Up @@ -489,10 +491,6 @@
"fieldtype": "Check",
"label": "Allow Sales Invoice Creation Without Delivery Note"
},
{
"fieldname": "column_break_22",
"fieldtype": "Column Break"
},
{
"fieldname": "delivery_end_time",
"fieldtype": "Time",
Expand All @@ -502,7 +500,7 @@
"collapsible": 1,
"fieldname": "delivery_window",
"fieldtype": "Section Break",
"label": "Delivery Window"
"label": "Delivery Preferences"
},
{
"fieldname": "delivery_start_time",
Expand Down Expand Up @@ -535,13 +533,29 @@
"fieldname": "sales_target_sb",
"fieldtype": "Section Break",
"label": "Sales Target"
},
{
"fieldname": "delivery_days",
"fieldtype": "Data",
"hidden": 1,
"label": "Delivery Days"
},
{
"fieldname": "delivery_days_html",
"fieldtype": "HTML",
"label": "Days of the week"
},
{
"collapsible": 1,
"fieldname": "delivery_days_section",
"fieldtype": "Section Break",
"label": "Delivery Days"
}
],
"icon": "fa fa-user",
"idx": 363,
"image_field": "image",
"links": [],
"modified": "2020-06-30 22:24:37.691545",
"modified": "2020-09-08 01:00:08.123104",
"modified_by": "Administrator",
"module": "Selling",
"name": "Customer",
Expand Down

0 comments on commit 1b8f6f2

Please sign in to comment.