fix: set company_address for purchases in party.js
(cherry picked from commit d05082987f)
This commit is contained in:
@@ -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