Skip to content

Commit

Permalink
fix: customer/supplier quick entry dialog (#33496)
Browse files Browse the repository at this point in the history
fix: customer/supplier quick entry dialog (#33496)

* fix: readonly primary contact fields.

* refactor: supplier and customer quick entry form into common class.

(cherry picked from commit 6bc8bb2)

Co-authored-by: Devin Slauenwhite <devin.slauenwhite@gmail.com>
  • Loading branch information
mergify[bot] and dj12djdjs authored Jan 10, 2023
1 parent d2e3701 commit 914e2fd
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 154 deletions.
1 change: 1 addition & 0 deletions erpnext/public/js/erpnext.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import "./help_links";
import "./agriculture/ternary_plot";
import "./templates/item_quick_entry.html";
import "./utils/item_quick_entry";
import "./utils/contact_address_quick_entry";
import "./utils/customer_quick_entry";
import "./utils/supplier_quick_entry";
import "./call_popup/call_popup";
Expand Down
100 changes: 100 additions & 0 deletions erpnext/public/js/utils/contact_address_quick_entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
frappe.provide('frappe.ui.form');

frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm extends frappe.ui.form.QuickEntryForm {
constructor(doctype, after_insert, init_callback, doc, force) {
super(doctype, after_insert, init_callback, doc, force);
this.skip_redirect_on_error = true;
}

render_dialog() {
this.mandatory = this.mandatory.concat(this.get_variant_fields());
super.render_dialog();
}

insert() {
/**
* Using alias fieldnames because the doctype definition define "email_id" and "mobile_no" as readonly fields.
* Therefor, resulting in the fields being "hidden".
*/
const map_field_names = {
"email_address": "email_id",
"mobile_number": "mobile_no",
};

Object.entries(map_field_names).forEach(([fieldname, new_fieldname]) => {
this.dialog.doc[new_fieldname] = this.dialog.doc[fieldname];
delete this.dialog.doc[fieldname];
});

return super.insert();
}

get_variant_fields() {
var variant_fields = [{
fieldtype: "Section Break",
label: __("Primary Contact Details"),
collapsible: 1
},
{
label: __("Email Id"),
fieldname: "email_address",
fieldtype: "Data",
options: "Email",
},
{
fieldtype: "Column Break"
},
{
label: __("Mobile Number"),
fieldname: "mobile_number",
fieldtype: "Data"
},
{
fieldtype: "Section Break",
label: __("Primary Address Details"),
collapsible: 1
},
{
label: __("Address Line 1"),
fieldname: "address_line1",
fieldtype: "Data"
},
{
label: __("Address Line 2"),
fieldname: "address_line2",
fieldtype: "Data"
},
{
label: __("ZIP Code"),
fieldname: "pincode",
fieldtype: "Data"
},
{
fieldtype: "Column Break"
},
{
label: __("City"),
fieldname: "city",
fieldtype: "Data"
},
{
label: __("State"),
fieldname: "state",
fieldtype: "Data"
},
{
label: __("Country"),
fieldname: "country",
fieldtype: "Link",
options: "Country"
},
{
label: __("Customer POS Id"),
fieldname: "customer_pos_id",
fieldtype: "Data",
hidden: 1
}];

return variant_fields;
}
}
80 changes: 1 addition & 79 deletions erpnext/public/js/utils/customer_quick_entry.js
Original file line number Diff line number Diff line change
@@ -1,81 +1,3 @@
frappe.provide('frappe.ui.form');

frappe.ui.form.CustomerQuickEntryForm = class CustomerQuickEntryForm extends frappe.ui.form.QuickEntryForm {
constructor(doctype, after_insert, init_callback, doc, force) {
super(doctype, after_insert, init_callback, doc, force);
this.skip_redirect_on_error = true;
}

render_dialog() {
this.mandatory = this.mandatory.concat(this.get_variant_fields());
super.render_dialog();
}

get_variant_fields() {
var variant_fields = [{
fieldtype: "Section Break",
label: __("Primary Contact Details"),
collapsible: 1
},
{
label: __("Email Id"),
fieldname: "email_id",
fieldtype: "Data"
},
{
fieldtype: "Column Break"
},
{
label: __("Mobile Number"),
fieldname: "mobile_no",
fieldtype: "Data"
},
{
fieldtype: "Section Break",
label: __("Primary Address Details"),
collapsible: 1
},
{
label: __("Address Line 1"),
fieldname: "address_line1",
fieldtype: "Data"
},
{
label: __("Address Line 2"),
fieldname: "address_line2",
fieldtype: "Data"
},
{
label: __("ZIP Code"),
fieldname: "pincode",
fieldtype: "Data"
},
{
fieldtype: "Column Break"
},
{
label: __("City"),
fieldname: "city",
fieldtype: "Data"
},
{
label: __("State"),
fieldname: "state",
fieldtype: "Data"
},
{
label: __("Country"),
fieldname: "country",
fieldtype: "Link",
options: "Country"
},
{
label: __("Customer POS Id"),
fieldname: "customer_pos_id",
fieldtype: "Data",
hidden: 1
}];

return variant_fields;
}
}
frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.ContactAddressQuickEntryForm;
76 changes: 1 addition & 75 deletions erpnext/public/js/utils/supplier_quick_entry.js
Original file line number Diff line number Diff line change
@@ -1,77 +1,3 @@
frappe.provide('frappe.ui.form');

frappe.ui.form.SupplierQuickEntryForm = class SupplierQuickEntryForm extends frappe.ui.form.QuickEntryForm {
constructor(doctype, after_insert, init_callback, doc, force) {
super(doctype, after_insert, init_callback, doc, force);
this.skip_redirect_on_error = true;
}

render_dialog() {
this.mandatory = this.mandatory.concat(this.get_variant_fields());
super.render_dialog();
}

get_variant_fields() {
var variant_fields = [
{
fieldtype: "Section Break",
label: __("Primary Contact Details"),
collapsible: 1
},
{
label: __("Email Id"),
fieldname: "email_id",
fieldtype: "Data"
},
{
fieldtype: "Column Break"
},
{
label: __("Mobile Number"),
fieldname: "mobile_no",
fieldtype: "Data"
},
{
fieldtype: "Section Break",
label: __("Primary Address Details"),
collapsible: 1
},
{
label: __("Address Line 1"),
fieldname: "address_line1",
fieldtype: "Data"
},
{
label: __("Address Line 2"),
fieldname: "address_line2",
fieldtype: "Data"
},
{
label: __("ZIP Code"),
fieldname: "pincode",
fieldtype: "Data"
},
{
fieldtype: "Column Break"
},
{
label: __("City"),
fieldname: "city",
fieldtype: "Data"
},
{
label: __("State"),
fieldname: "state",
fieldtype: "Data"
},
{
label: __("Country"),
fieldname: "country",
fieldtype: "Link",
options: "Country"
}
];

return variant_fields;
}
};
frappe.ui.form.SupplierQuickEntryForm = frappe.ui.form.ContactAddressQuickEntryForm;

0 comments on commit 914e2fd

Please sign in to comment.