mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-20 03:47:11 +00:00
fix: validate shipping rule account company
(cherry picked from commit 340feb94a1)
This commit is contained in:
@@ -9,10 +9,15 @@ frappe.ui.form.on("Shipping Rule", {
|
||||
},
|
||||
|
||||
company: function (frm) {
|
||||
if (frm.previous_company !== frm.doc.company) {
|
||||
frm.previous_company = frm.doc.company;
|
||||
frm.set_value("account", "");
|
||||
}
|
||||
erpnext.accounts.dimensions.update_dimension(frm, frm.doctype);
|
||||
},
|
||||
|
||||
refresh: function (frm) {
|
||||
frm.previous_company = frm.doc.company;
|
||||
frm.set_query("account", function () {
|
||||
return {
|
||||
filters: {
|
||||
|
||||
@@ -52,10 +52,23 @@ class ShippingRule(Document):
|
||||
# end: auto-generated types
|
||||
|
||||
def validate(self):
|
||||
self.validate_account_company()
|
||||
self.validate_from_to_values()
|
||||
self.sort_shipping_rule_conditions()
|
||||
self.validate_overlapping_shipping_rule_conditions()
|
||||
|
||||
def validate_account_company(self):
|
||||
if not self.company or not self.account:
|
||||
return
|
||||
|
||||
if frappe.get_cached_value("Account", self.account, "company") != self.company:
|
||||
throw(
|
||||
_("Shipping Account {0} does not belong to Company {1}").format(
|
||||
frappe.bold(self.account), frappe.bold(self.company)
|
||||
),
|
||||
title=_("Invalid Shipping Account"),
|
||||
)
|
||||
|
||||
def validate_from_to_values(self):
|
||||
if self.calculate_based_on == "Fixed":
|
||||
if self.conditions:
|
||||
|
||||
Reference in New Issue
Block a user