Compare commits

...

3 Commits

Author SHA1 Message Date
Afsal Syed
db6e089109 fix(stock): validate warehouse account belongs to selected company (#59191) 2026-09-19 13:06:06 +05:30
Khushi Rawat
a2481e9390 Merge pull request #59181 from aerele/fix/accounts-reports-revaluation-filter-labels
fix(accounts): clarify revaluation journal filters
2026-09-18 17:53:02 +05:30
pandiyan
dc4b390a9b fix(accounts): clarify revaluation journal filters 2026-09-18 17:26:10 +05:30
7 changed files with 48 additions and 4 deletions

View File

@@ -156,7 +156,7 @@ frappe.query_reports["Accounts Payable"] = {
},
{
fieldname: "for_revaluation_journals",
label: __("Revaluation Journals"),
label: __("Include Revaluation Journals"),
fieldtype: "Check",
},
{

View File

@@ -113,7 +113,7 @@ frappe.query_reports["Accounts Payable Summary"] = {
},
{
fieldname: "for_revaluation_journals",
label: __("Revaluation Journals"),
label: __("Include Revaluation Journals"),
fieldtype: "Check",
},
{

View File

@@ -183,7 +183,7 @@ frappe.query_reports["Accounts Receivable"] = {
},
{
fieldname: "for_revaluation_journals",
label: __("Revaluation Journals"),
label: __("Include Revaluation Journals"),
fieldtype: "Check",
},
{

View File

@@ -141,7 +141,7 @@ frappe.query_reports["Accounts Receivable Summary"] = {
},
{
fieldname: "for_revaluation_journals",
label: __("Revaluation Journals"),
label: __("Include Revaluation Journals"),
fieldtype: "Check",
},
],

View File

@@ -248,6 +248,33 @@ class TestWarehouse(ERPNextTestSuite):
fetch_stock_accounts.assert_called_once_with(company)
def test_warehouse_account_company_validation(self):
company_1 = "_Test Company"
company_2 = "_Test Company 1"
account_company_2 = frappe.db.get_value(
"Account", {"company": company_2, "account_type": "Stock", "is_group": 0}, "name"
)
warehouse = frappe.get_doc(
{
"doctype": "Warehouse",
"warehouse_name": "Test Company Account Mismatch",
"company": company_1,
"account": account_company_2,
}
)
self.assertRaisesRegex(frappe.ValidationError, "does not belong to Company", warehouse.insert)
warehouse.account = None
warehouse.insert()
warehouse.account = account_company_2
self.assertRaisesRegex(frappe.ValidationError, "does not belong to Company", warehouse.save)
warehouse.delete()
def create_inventory_fallback_company():
company = "_Test Company Inventory Fallback"

View File

@@ -33,6 +33,12 @@ frappe.ui.form.on("Warehouse", {
});
},
company: function (frm) {
if (frm.doc.account) {
frm.set_value("account", "");
}
},
refresh: function (frm) {
frm.toggle_display("warehouse_name", frm.doc.__islocal);
frm.toggle_display(["address_html", "contact_html"], !frm.doc.__islocal);

View File

@@ -71,9 +71,20 @@ class Warehouse(NestedSet):
self.set_onload("stock_exists", self.check_if_sle_exists(non_cancelled_only=True))
def validate(self):
self.validate_warehouse_account()
self.validate_inventory_account()
self.warn_about_multiple_warehouse_account()
def validate_warehouse_account(self):
if self.account and self.company:
account_company = frappe.get_cached_value("Account", self.account, "company")
if account_company and account_company != self.company:
frappe.throw(
_("Account {0} does not belong to Company {1}").format(
frappe.bold(self.account), frappe.bold(self.company)
)
)
def validate_inventory_account(self):
if (
not self.is_new()