diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 0f22d1fa242e645abf326ef04f8e211ec5ff5123..2281a5481f8a74452f6bdbb3b875a04e36c99295 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -680,9 +680,7 @@ def get_due_date_from_template(template_name, posting_date, bill_date): return due_date -def validate_due_date( - posting_date, due_date, party_type, party, company=None, bill_date=None, template_name=None -): +def validate_due_date(posting_date, due_date, bill_date=None, template_name=None): if getdate(due_date) < getdate(posting_date): frappe.throw(_("Due Date cannot be before Posting / Supplier Invoice Date")) else: diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 1097d2be3450a8785286529d6c39ce67aec889e3..852b29d59e5994c7aa98b32e97dffd3076e12998 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -542,18 +542,12 @@ class AccountsController(TransactionBase): validate_due_date( self.posting_date, self.due_date, - "Customer", - self.customer, - self.company, self.payment_terms_template, ) elif self.doctype == "Purchase Invoice": validate_due_date( self.bill_date or self.posting_date, self.due_date, - "Supplier", - self.supplier, - self.company, self.bill_date, self.payment_terms_template, ) diff --git a/erpnext/public/js/utils/contact_address_quick_entry.js b/erpnext/public/js/utils/contact_address_quick_entry.js index 137fbf59879c741e216b322268dbb9bb5146d127..952ebdfcfacafe8eaa0a525205e7b28c48462588 100644 --- a/erpnext/public/js/utils/contact_address_quick_entry.js +++ b/erpnext/public/js/utils/contact_address_quick_entry.js @@ -1,37 +1,59 @@ frappe.provide('frappe.ui.form'); frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm extends frappe.ui.form.QuickEntryForm { + map_field_names = { + "email_address": "email_id", + "mobile_number": "mobile_no", + }; + constructor(doctype, after_insert, init_callback, doc, force) { super(doctype, after_insert, init_callback, doc, force); this.skip_redirect_on_error = true; } - render_dialog() { - const me = this; + async render_dialog() { this.mandatory = this.mandatory.concat(this.get_variant_fields()); - // @dokos - this.mandatory.map(m => { + for (const m of this.mandatory) { + // @dokos if (m.fieldname == "company_search") { - m.get_query = function() { + m.get_query = () => { return { query: "erpnext.buying.doctype.supplier.supplier.company_query" }; } - m.onchange = function() { - const selection = this._data.filter(f => f.value == me.dialog.get_value("company_search")) + m.onchange = () => { + const selection = this._data.filter(f => f.value == this.dialog.get_value("company_search")) if (selection.length){ const selected_company = selection[0] - me.dialog.set_values({ + this.dialog.set_values({ customer_name: selected_company.label, siren_number: selected_company.value }) } } } - }) + + // Grab the original df from the doctype definition + if (m.fieldname) { + let fieldname = m.fieldname; + fieldname = this.map_field_names[fieldname] ?? fieldname; + + const dt = m._for_doctype ?? this.doctype; + await frappe.model.with_doctype(dt); + + const original_df = frappe.meta.get_docfield(dt, fieldname); + if (original_df) { + const default_value = frappe.defaults.get_default(fieldname); + Object.assign(m, original_df, { + "depends_on": "", + "default": default_value, + }); + } + } + } super.render_dialog(); } @@ -41,12 +63,7 @@ frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm * 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]) => { + Object.entries(this.map_field_names).forEach(([fieldname, new_fieldname]) => { this.dialog.doc[new_fieldname] = this.dialog.doc[fieldname]; delete this.dialog.doc[fieldname]; }); @@ -61,6 +78,7 @@ frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm collapsible: 1 }, { + _for_doctype: "Contact", label: __("Email Id"), fieldname: "email_address", fieldtype: "Data", @@ -70,6 +88,7 @@ frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm fieldtype: "Column Break" }, { + _for_doctype: "Contact", label: __("Mobile Number"), fieldname: "mobile_number", fieldtype: "Data" @@ -80,16 +99,19 @@ frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm collapsible: 1 }, { + _for_doctype: "Address", label: __("Address Line 1"), fieldname: "address_line1", fieldtype: "Data" }, { + _for_doctype: "Address", label: __("Address Line 2"), fieldname: "address_line2", fieldtype: "Data" }, { + _for_doctype: "Address", label: __("ZIP Code"), fieldname: "pincode", fieldtype: "Data" @@ -98,16 +120,19 @@ frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm fieldtype: "Column Break" }, { + _for_doctype: "Address", label: __("City"), fieldname: "city", fieldtype: "Data" }, { + _for_doctype: "Address", label: __("State"), fieldname: "state", fieldtype: "Data" }, { + _for_doctype: "Address", label: __("Country"), fieldname: "country", fieldtype: "Link",