Merge pull request #31792 from frappe/mergify/bp/version-13-hotfix/pr-31733
fix: set `billing_address` for purchases in `get_party_details` (backport #31733)
This commit is contained in:
@@ -208,7 +208,7 @@ def set_address_details(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if company_address:
|
if company_address:
|
||||||
party_details.update({"company_address": company_address})
|
party_details.company_address = company_address
|
||||||
else:
|
else:
|
||||||
party_details.update(get_company_address(company))
|
party_details.update(get_company_address(company))
|
||||||
|
|
||||||
@@ -220,12 +220,37 @@ def set_address_details(
|
|||||||
get_regional_address_details(party_details, doctype, company)
|
get_regional_address_details(party_details, doctype, company)
|
||||||
|
|
||||||
elif doctype and doctype in ["Purchase Invoice", "Purchase Order", "Purchase Receipt"]:
|
elif doctype and doctype in ["Purchase Invoice", "Purchase Order", "Purchase Receipt"]:
|
||||||
if party_details.company_address:
|
if shipping_address:
|
||||||
party_details["shipping_address"] = shipping_address or party_details["company_address"]
|
|
||||||
party_details.shipping_address_display = get_address_display(party_details["shipping_address"])
|
|
||||||
party_details.update(
|
party_details.update(
|
||||||
get_fetch_values(doctype, "shipping_address", party_details.shipping_address)
|
{
|
||||||
|
"shipping_address": shipping_address,
|
||||||
|
"shipping_address_display": get_address_display(shipping_address),
|
||||||
|
**get_fetch_values(doctype, "shipping_address", shipping_address),
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if party_details.company_address:
|
||||||
|
# billing address
|
||||||
|
party_details.update(
|
||||||
|
{
|
||||||
|
"billing_address": party_details.company_address,
|
||||||
|
"billing_address_display": (
|
||||||
|
party_details.company_address_display or get_address_display(party_details.company_address)
|
||||||
|
),
|
||||||
|
**get_fetch_values(doctype, "billing_address", party_details.company_address),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
# shipping address - if not already set
|
||||||
|
if not party_details.shipping_address:
|
||||||
|
party_details.update(
|
||||||
|
{
|
||||||
|
"shipping_address": party_details.billing_address,
|
||||||
|
"shipping_address_display": party_details.billing_address_display,
|
||||||
|
**get_fetch_values(doctype, "shipping_address", party_details.billing_address),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
get_regional_address_details(party_details, doctype, company)
|
get_regional_address_details(party_details, doctype, company)
|
||||||
|
|
||||||
return party_details.get(billing_address_field), party_details.shipping_address_name
|
return party_details.get(billing_address_field), party_details.shipping_address_name
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ class BuyingController(StockController, Subcontracting):
|
|||||||
company=self.company,
|
company=self.company,
|
||||||
party_address=self.get("supplier_address"),
|
party_address=self.get("supplier_address"),
|
||||||
shipping_address=self.get("shipping_address"),
|
shipping_address=self.get("shipping_address"),
|
||||||
|
company_address=self.get("billing_address"),
|
||||||
fetch_payment_terms_template=not self.get("ignore_default_payment_terms_template"),
|
fetch_payment_terms_template=not self.get("ignore_default_payment_terms_template"),
|
||||||
ignore_permissions=self.flags.ignore_permissions,
|
ignore_permissions=self.flags.ignore_permissions,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
frappe.provide('erpnext.accounts.dimensions');
|
|
||||||
|
|
||||||
erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||||
setup: function() {
|
setup: function() {
|
||||||
@@ -910,24 +909,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
set_party_account(set_pricing);
|
set_party_account(set_pricing);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get default company billing address in Purchase Invoice, Order and Receipt
|
|
||||||
if (this.frm.doc.company && frappe.meta.get_docfield(this.frm.doctype, "billing_address")) {
|
|
||||||
frappe.call({
|
|
||||||
method: "erpnext.setup.doctype.company.company.get_default_company_address",
|
|
||||||
args: {name: this.frm.doc.company, existing_address: this.frm.doc.billing_address || ""},
|
|
||||||
debounce: 2000,
|
|
||||||
callback: function(r) {
|
|
||||||
if (r.message) {
|
|
||||||
me.frm.set_value("billing_address", r.message);
|
|
||||||
} else {
|
|
||||||
if (frappe.meta.get_docfield(me.frm.doctype, 'company_address')) {
|
|
||||||
me.frm.set_value("company_address", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
set_party_account(set_pricing);
|
set_party_account(set_pricing);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,25 +3,14 @@
|
|||||||
|
|
||||||
frappe.provide("erpnext.utils");
|
frappe.provide("erpnext.utils");
|
||||||
|
|
||||||
|
const SALES_DOCTYPES = ['Quotation', 'Sales Order', 'Delivery Note', 'Sales Invoice'];
|
||||||
|
const PURCHASE_DOCTYPES = ['Purchase Order', 'Purchase Receipt', 'Purchase Invoice'];
|
||||||
|
|
||||||
erpnext.utils.get_party_details = function(frm, method, args, callback) {
|
erpnext.utils.get_party_details = function(frm, method, args, callback) {
|
||||||
if (!method) {
|
if (!method) {
|
||||||
method = "erpnext.accounts.party.get_party_details";
|
method = "erpnext.accounts.party.get_party_details";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args) {
|
|
||||||
if (in_list(['Sales Invoice', 'Sales Order', 'Delivery Note'], frm.doc.doctype)) {
|
|
||||||
if (frm.doc.company_address && (!args.company_address)) {
|
|
||||||
args.company_address = frm.doc.company_address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_list(['Purchase Invoice', 'Purchase Order', 'Purchase Receipt'], frm.doc.doctype)) {
|
|
||||||
if (frm.doc.shipping_address && (!args.shipping_address)) {
|
|
||||||
args.shipping_address = frm.doc.shipping_address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!args) {
|
if (!args) {
|
||||||
if ((frm.doctype != "Purchase Order" && frm.doc.customer)
|
if ((frm.doctype != "Purchase Order" && frm.doc.customer)
|
||||||
|| (frm.doc.party_name && in_list(['Quotation', 'Opportunity'], frm.doc.doctype))) {
|
|| (frm.doc.party_name && in_list(['Quotation', 'Opportunity'], frm.doc.doctype))) {
|
||||||
@@ -45,41 +34,44 @@ erpnext.utils.get_party_details = function(frm, method, args, callback) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_list(['Sales Invoice', 'Sales Order', 'Delivery Note'], frm.doc.doctype)) {
|
if (!args) {
|
||||||
if (!args) {
|
if (in_list(SALES_DOCTYPES, frm.doc.doctype)) {
|
||||||
args = {
|
args = {
|
||||||
party: frm.doc.customer || frm.doc.party_name,
|
party: frm.doc.customer || frm.doc.party_name,
|
||||||
party_type: 'Customer'
|
party_type: 'Customer'
|
||||||
}
|
};
|
||||||
}
|
|
||||||
if (frm.doc.company_address && (!args.company_address)) {
|
|
||||||
args.company_address = frm.doc.company_address;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frm.doc.shipping_address_name &&(!args.shipping_address_name)) {
|
if (in_list(PURCHASE_DOCTYPES, frm.doc.doctype)) {
|
||||||
args.shipping_address_name = frm.doc.shipping_address_name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_list(['Purchase Invoice', 'Purchase Order', 'Purchase Receipt'], frm.doc.doctype)) {
|
|
||||||
if (!args) {
|
|
||||||
args = {
|
args = {
|
||||||
party: frm.doc.supplier,
|
party: frm.doc.supplier,
|
||||||
party_type: 'Supplier'
|
party_type: 'Supplier'
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
if (frm.doc.shipping_address && (!args.shipping_address)) {
|
|
||||||
args.shipping_address = frm.doc.shipping_address;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args) {
|
if (!args || !args.party) return;
|
||||||
args.posting_date = frm.doc.posting_date || frm.doc.transaction_date;
|
|
||||||
args.fetch_payment_terms_template = cint(!frm.doc.ignore_default_payment_terms_template);
|
args.posting_date = frm.doc.posting_date || frm.doc.transaction_date;
|
||||||
|
args.fetch_payment_terms_template = cint(!frm.doc.ignore_default_payment_terms_template);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_list(SALES_DOCTYPES, frm.doc.doctype)) {
|
||||||
|
if (!args.company_address && frm.doc.company_address) {
|
||||||
|
args.company_address = frm.doc.company_address;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!args || !args.party) return;
|
|
||||||
|
if (in_list(PURCHASE_DOCTYPES, frm.doc.doctype)) {
|
||||||
|
if (!args.company_address && frm.doc.billing_address) {
|
||||||
|
args.company_address = frm.doc.billing_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!args.shipping_address && frm.doc.shipping_address) {
|
||||||
|
args.shipping_address = frm.doc.shipping_address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (frappe.meta.get_docfield(frm.doc.doctype, "taxes")) {
|
if (frappe.meta.get_docfield(frm.doc.doctype, "taxes")) {
|
||||||
if (!erpnext.utils.validate_mandatory(frm, "Posting / Transaction Date",
|
if (!erpnext.utils.validate_mandatory(frm, "Posting / Transaction Date",
|
||||||
|
|||||||
Reference in New Issue
Block a user