mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-02 18:14:50 +00:00
fix: respect mapped accounting dimensions
(cherry picked from commit 7dbe27da19)
This commit is contained in:
@@ -77,35 +77,34 @@ erpnext.accounts.dimensions = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
update_dimension(frm, doctype) {
|
update_dimension(frm, doctype) {
|
||||||
if (this.accounting_dimensions) {
|
if (
|
||||||
this.accounting_dimensions.forEach((dimension) => {
|
!this.accounting_dimensions ||
|
||||||
if (frm.is_new()) {
|
!frm.is_new() ||
|
||||||
if (
|
!frm.doc.company ||
|
||||||
frm.doc.company &&
|
!this.default_dimensions?.[frm.doc.company]
|
||||||
Object.keys(this.default_dimensions || {}).length > 0 &&
|
)
|
||||||
this.default_dimensions[frm.doc.company]
|
return;
|
||||||
) {
|
|
||||||
let default_dimension =
|
|
||||||
this.default_dimensions[frm.doc.company][dimension["fieldname"]];
|
|
||||||
|
|
||||||
if (default_dimension) {
|
// don't set default dimensions if any of the dimension is already set due to mapping
|
||||||
if (frappe.meta.has_field(doctype, dimension["fieldname"])) {
|
if (frm.doc.__onload?.load_after_mapping) {
|
||||||
frm.set_value(dimension["fieldname"], default_dimension);
|
for (const dimension of this.accounting_dimensions) {
|
||||||
}
|
if (frm.doc[dimension["fieldname"]]) return;
|
||||||
|
}
|
||||||
$.each(frm.doc.items || frm.doc.accounts || [], function (i, row) {
|
|
||||||
frappe.model.set_value(
|
|
||||||
row.doctype,
|
|
||||||
row.name,
|
|
||||||
dimension["fieldname"],
|
|
||||||
default_dimension
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.accounting_dimensions.forEach((dimension) => {
|
||||||
|
const default_dimension = this.default_dimensions[frm.doc.company][dimension["fieldname"]];
|
||||||
|
|
||||||
|
if (!default_dimension) return;
|
||||||
|
|
||||||
|
if (frappe.meta.has_field(doctype, dimension["fieldname"])) {
|
||||||
|
frm.set_value(dimension["fieldname"], default_dimension);
|
||||||
|
}
|
||||||
|
|
||||||
|
(frm.doc.items || frm.doc.accounts || []).forEach((row) => {
|
||||||
|
frappe.model.set_value(row.doctype, row.name, dimension["fieldname"], default_dimension);
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
copy_dimension_from_first_row(frm, cdt, cdn, fieldname) {
|
copy_dimension_from_first_row(frm, cdt, cdn, fieldname) {
|
||||||
|
|||||||
Reference in New Issue
Block a user