Merge pull request #20663 from marination/stock-settings-query
fix: Set Query on warehouse fields in Stock Settings
This commit is contained in:
commit
40546d8af9
@ -3,6 +3,15 @@
|
|||||||
|
|
||||||
frappe.ui.form.on('Stock Settings', {
|
frappe.ui.form.on('Stock Settings', {
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
|
let filters = function() {
|
||||||
|
return {
|
||||||
|
filters : {
|
||||||
|
is_group : 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
frm.set_query("default_warehouse", filters);
|
||||||
|
frm.set_query("sample_retention_warehouse", filters);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -30,9 +30,17 @@ class StockSettings(Document):
|
|||||||
frappe.make_property_setter({'fieldname': name, 'property': 'hidden',
|
frappe.make_property_setter({'fieldname': name, 'property': 'hidden',
|
||||||
'value': 0 if self.show_barcode_field else 1})
|
'value': 0 if self.show_barcode_field else 1})
|
||||||
|
|
||||||
|
self.validate_warehouses()
|
||||||
self.cant_change_valuation_method()
|
self.cant_change_valuation_method()
|
||||||
self.validate_clean_description_html()
|
self.validate_clean_description_html()
|
||||||
|
|
||||||
|
def validate_warehouses(self):
|
||||||
|
warehouse_fields = ["default_warehouse", "sample_retention_warehouse"]
|
||||||
|
for field in warehouse_fields:
|
||||||
|
if frappe.db.get_value("Warehouse", self.get(field), "is_group"):
|
||||||
|
frappe.throw(_("Group Warehouses cannot be used in transactions. Please change the value of {0}") \
|
||||||
|
.format(frappe.bold(self.meta.get_field(field).label)), title =_("Incorrect Warehouse"))
|
||||||
|
|
||||||
def cant_change_valuation_method(self):
|
def cant_change_valuation_method(self):
|
||||||
db_valuation_method = frappe.db.get_single_value("Stock Settings", "valuation_method")
|
db_valuation_method = frappe.db.get_single_value("Stock Settings", "valuation_method")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user