fix: apply default accounting dimensions reliably on new documents

Default accounting dimensions were applied from the `company` client
trigger, which reads dimension data fetched asynchronously in
`setup_dimension_filters`. When the trigger fired before that fetch
returned, new documents were left without their default dimensions, and
Sales Order never called `update_dimension` at all.

- Apply defaults from the fetch callback in dimension_tree_filter.js so
  they no longer depend on `company`-trigger timing. This fixes the race
  for Sales Invoice, Purchase Invoice and Payment Entry, and populates
  defaults on new Sales Orders.
- Add a `company()` override on SalesOrderController so the default is
  re-applied when the company changes, matching the sibling doctypes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
khushi8112
2026-07-21 11:34:40 +05:30
parent 2cd531d099
commit 88abe119c3
2 changed files with 6 additions and 0 deletions

View File

@@ -22,6 +22,7 @@ erpnext.accounts.dimensions = {
});
me.default_dimensions = r.message[1];
me.setup_filters(frm, doctype);
me.update_dimension(frm, doctype);
},
});
},

View File

@@ -589,6 +589,11 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
super.onload(doc, dt, dn);
}
company() {
super.company();
erpnext.accounts.dimensions.update_dimension(this.frm, this.frm.doctype);
}
refresh(doc, dt, dn) {
var me = this;
super.refresh();