mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-27 00:26:03 +00:00
feat(Company): allow setting default sales contact, fetch into sales transaction (backport #50159) (#50599)
Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Co-authored-by: Diptanil Saha <diptanil@frappe.io>
This commit is contained in:
@@ -95,6 +95,7 @@ class SellingController(StockController):
|
|||||||
# set contact and address details for customer, if they are not mentioned
|
# set contact and address details for customer, if they are not mentioned
|
||||||
self.set_missing_lead_customer_details(for_validate=for_validate)
|
self.set_missing_lead_customer_details(for_validate=for_validate)
|
||||||
self.set_price_list_and_item_details(for_validate=for_validate)
|
self.set_price_list_and_item_details(for_validate=for_validate)
|
||||||
|
self.set_company_contact_person()
|
||||||
|
|
||||||
def set_missing_lead_customer_details(self, for_validate=False):
|
def set_missing_lead_customer_details(self, for_validate=False):
|
||||||
customer, lead = None, None
|
customer, lead = None, None
|
||||||
@@ -150,6 +151,13 @@ class SellingController(StockController):
|
|||||||
self.set_price_list_currency("Selling")
|
self.set_price_list_currency("Selling")
|
||||||
self.set_missing_item_details(for_validate=for_validate)
|
self.set_missing_item_details(for_validate=for_validate)
|
||||||
|
|
||||||
|
def set_company_contact_person(self):
|
||||||
|
"""Set the Company's Default Sales Contact as Company Contact Person."""
|
||||||
|
if self.company and self.meta.has_field("company_contact_person") and not self.company_contact_person:
|
||||||
|
self.company_contact_person = frappe.get_cached_value(
|
||||||
|
"Company", self.company, "default_sales_contact"
|
||||||
|
)
|
||||||
|
|
||||||
def remove_shipping_charge(self):
|
def remove_shipping_charge(self):
|
||||||
if self.shipping_rule:
|
if self.shipping_rule:
|
||||||
shipping_rule = frappe.get_doc("Shipping Rule", self.shipping_rule)
|
shipping_rule = frappe.get_doc("Shipping Rule", self.shipping_rule)
|
||||||
|
|||||||
@@ -115,6 +115,10 @@ erpnext.sales_common = {
|
|||||||
company() {
|
company() {
|
||||||
super.company();
|
super.company();
|
||||||
this.set_default_company_address();
|
this.set_default_company_address();
|
||||||
|
if (!this.is_onload) {
|
||||||
|
// we don't want to override the mapped contact from prevdoc
|
||||||
|
this.set_default_company_contact_person();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set_default_company_address() {
|
set_default_company_address() {
|
||||||
@@ -139,6 +143,24 @@ erpnext.sales_common = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_default_company_contact_person() {
|
||||||
|
if (!frappe.meta.has_field(this.frm.doc.doctype, "company_contact_person")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.frm.doc.company) {
|
||||||
|
frappe.db
|
||||||
|
.get_value("Company", this.frm.doc.company, "default_sales_contact")
|
||||||
|
.then((r) => {
|
||||||
|
if (r.message?.default_sales_contact) {
|
||||||
|
this.frm.set_value("company_contact_person", r.message.default_sales_contact);
|
||||||
|
} else {
|
||||||
|
this.frm.set_value("company_contact_person", "");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
customer() {
|
customer() {
|
||||||
var me = this;
|
var me = this;
|
||||||
erpnext.utils.get_party_details(this.frm, null, null, function () {
|
erpnext.utils.get_party_details(this.frm, null, null, function () {
|
||||||
|
|||||||
@@ -37,6 +37,13 @@ frappe.ui.form.on("Company", {
|
|||||||
return { filters: { selling: 1 } };
|
return { filters: { selling: 1 } };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frm.set_query("default_sales_contact", function (doc) {
|
||||||
|
return {
|
||||||
|
query: "frappe.contacts.doctype.contact.contact.contact_query",
|
||||||
|
filters: { link_doctype: "Company", link_name: doc.name },
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
frm.set_query("default_buying_terms", function () {
|
frm.set_query("default_buying_terms", function () {
|
||||||
return { filters: { buying: 1 } };
|
return { filters: { buying: 1 } };
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -103,6 +103,7 @@
|
|||||||
"total_monthly_sales",
|
"total_monthly_sales",
|
||||||
"column_break_goals",
|
"column_break_goals",
|
||||||
"default_selling_terms",
|
"default_selling_terms",
|
||||||
|
"default_sales_contact",
|
||||||
"default_warehouse_for_sales_return",
|
"default_warehouse_for_sales_return",
|
||||||
"credit_limit",
|
"credit_limit",
|
||||||
"transactions_annual_history",
|
"transactions_annual_history",
|
||||||
@@ -851,6 +852,12 @@
|
|||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Reconciliation Takes Effect On",
|
"label": "Reconciliation Takes Effect On",
|
||||||
"options": "Advance Payment Date\nOldest Of Invoice Or Advance\nReconciliation Date"
|
"options": "Advance Payment Date\nOldest Of Invoice Or Advance\nReconciliation Date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "default_sales_contact",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Default Sales Contact",
|
||||||
|
"options": "Contact"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-building",
|
"icon": "fa fa-building",
|
||||||
@@ -858,7 +865,7 @@
|
|||||||
"image_field": "company_logo",
|
"image_field": "company_logo",
|
||||||
"is_tree": 1,
|
"is_tree": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2025-08-25 18:34:03.602046",
|
"modified": "2025-11-16 16:51:27.624096",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Setup",
|
"module": "Setup",
|
||||||
"name": "Company",
|
"name": "Company",
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class Company(NestedSet):
|
|||||||
default_payable_account: DF.Link | None
|
default_payable_account: DF.Link | None
|
||||||
default_provisional_account: DF.Link | None
|
default_provisional_account: DF.Link | None
|
||||||
default_receivable_account: DF.Link | None
|
default_receivable_account: DF.Link | None
|
||||||
|
default_sales_contact: DF.Link | None
|
||||||
default_selling_terms: DF.Link | None
|
default_selling_terms: DF.Link | None
|
||||||
default_warehouse_for_sales_return: DF.Link | None
|
default_warehouse_for_sales_return: DF.Link | None
|
||||||
depreciation_cost_center: DF.Link | None
|
depreciation_cost_center: DF.Link | None
|
||||||
|
|||||||
Reference in New Issue
Block a user