mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
Merge branch 'version-14-hotfix' into mergify/bp/version-14-hotfix/pr-33715
This commit is contained in:
@@ -37,7 +37,7 @@ frappe.ui.form.on('Inventory Dimension', {
|
|||||||
if (frm.doc.__onload && frm.doc.__onload.has_stock_ledger
|
if (frm.doc.__onload && frm.doc.__onload.has_stock_ledger
|
||||||
&& frm.doc.__onload.has_stock_ledger.length) {
|
&& frm.doc.__onload.has_stock_ledger.length) {
|
||||||
let allow_to_edit_fields = ['disabled', 'fetch_from_parent',
|
let allow_to_edit_fields = ['disabled', 'fetch_from_parent',
|
||||||
'type_of_transaction', 'condition'];
|
'type_of_transaction', 'condition', 'mandatory_depends_on'];
|
||||||
|
|
||||||
frm.fields.forEach((field) => {
|
frm.fields.forEach((field) => {
|
||||||
if (!in_list(allow_to_edit_fields, field.df.fieldname)) {
|
if (!in_list(allow_to_edit_fields, field.df.fieldname)) {
|
||||||
|
|||||||
@@ -24,6 +24,9 @@
|
|||||||
"istable",
|
"istable",
|
||||||
"applicable_condition_example_section",
|
"applicable_condition_example_section",
|
||||||
"condition",
|
"condition",
|
||||||
|
"conditional_mandatory_section",
|
||||||
|
"reqd",
|
||||||
|
"mandatory_depends_on",
|
||||||
"conditional_rule_examples_section",
|
"conditional_rule_examples_section",
|
||||||
"html_19"
|
"html_19"
|
||||||
],
|
],
|
||||||
@@ -153,11 +156,28 @@
|
|||||||
"fieldname": "conditional_rule_examples_section",
|
"fieldname": "conditional_rule_examples_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Conditional Rule Examples"
|
"label": "Conditional Rule Examples"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "To apply condition on parent field use parent.field_name and to apply condition on child table use doc.field_name. Here field_name could be based on the actual column name of the respective field.",
|
||||||
|
"fieldname": "mandatory_depends_on",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"label": "Mandatory Depends On"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "conditional_mandatory_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Mandatory Section"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "reqd",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Mandatory"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-11-15 15:50:16.767105",
|
"modified": "2023-01-31 13:44:38.507698",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Inventory Dimension",
|
"name": "Inventory Dimension",
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ class InventoryDimension(Document):
|
|||||||
insert_after="inventory_dimension",
|
insert_after="inventory_dimension",
|
||||||
options=self.reference_document,
|
options=self.reference_document,
|
||||||
label=self.dimension_name,
|
label=self.dimension_name,
|
||||||
|
reqd=self.reqd,
|
||||||
|
mandatory_depends_on=self.mandatory_depends_on,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -142,6 +144,8 @@ class InventoryDimension(Document):
|
|||||||
"Custom Field", {"dt": "Stock Ledger Entry", "fieldname": self.target_fieldname}
|
"Custom Field", {"dt": "Stock Ledger Entry", "fieldname": self.target_fieldname}
|
||||||
) and not field_exists("Stock Ledger Entry", self.target_fieldname):
|
) and not field_exists("Stock Ledger Entry", self.target_fieldname):
|
||||||
dimension_field = dimension_fields[1]
|
dimension_field = dimension_fields[1]
|
||||||
|
dimension_field["mandatory_depends_on"] = ""
|
||||||
|
dimension_field["reqd"] = 0
|
||||||
dimension_field["fieldname"] = self.target_fieldname
|
dimension_field["fieldname"] = self.target_fieldname
|
||||||
custom_fields["Stock Ledger Entry"] = dimension_field
|
custom_fields["Stock Ledger Entry"] = dimension_field
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,9 @@ class TestInventoryDimension(FrappeTestCase):
|
|||||||
condition="parent.purpose == 'Material Issue'",
|
condition="parent.purpose == 'Material Issue'",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
inv_dim1.reqd = 0
|
||||||
|
inv_dim1.save()
|
||||||
|
|
||||||
create_inventory_dimension(
|
create_inventory_dimension(
|
||||||
reference_document="Shelf",
|
reference_document="Shelf",
|
||||||
type_of_transaction="Inward",
|
type_of_transaction="Inward",
|
||||||
@@ -205,6 +208,48 @@ class TestInventoryDimension(FrappeTestCase):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_check_mandatory_dimensions(self):
|
||||||
|
doc = create_inventory_dimension(
|
||||||
|
reference_document="Pallet",
|
||||||
|
type_of_transaction="Outward",
|
||||||
|
dimension_name="Pallet",
|
||||||
|
apply_to_all_doctypes=0,
|
||||||
|
document_type="Stock Entry Detail",
|
||||||
|
)
|
||||||
|
|
||||||
|
doc.reqd = 1
|
||||||
|
doc.save()
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
frappe.db.get_value(
|
||||||
|
"Custom Field", {"fieldname": "pallet", "dt": "Stock Entry Detail", "reqd": 1}, "name"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
doc.load_from_db
|
||||||
|
doc.reqd = 0
|
||||||
|
doc.save()
|
||||||
|
|
||||||
|
def test_check_mandatory_depends_on_dimensions(self):
|
||||||
|
doc = create_inventory_dimension(
|
||||||
|
reference_document="Pallet",
|
||||||
|
type_of_transaction="Outward",
|
||||||
|
dimension_name="Pallet",
|
||||||
|
apply_to_all_doctypes=0,
|
||||||
|
document_type="Stock Entry Detail",
|
||||||
|
)
|
||||||
|
|
||||||
|
doc.mandatory_depends_on = "t_warehouse"
|
||||||
|
doc.save()
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
frappe.db.get_value(
|
||||||
|
"Custom Field",
|
||||||
|
{"fieldname": "pallet", "dt": "Stock Entry Detail", "mandatory_depends_on": "t_warehouse"},
|
||||||
|
"name",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def prepare_test_data():
|
def prepare_test_data():
|
||||||
if not frappe.db.exists("DocType", "Shelf"):
|
if not frappe.db.exists("DocType", "Shelf"):
|
||||||
@@ -251,6 +296,22 @@ def prepare_test_data():
|
|||||||
|
|
||||||
create_warehouse("Rack Warehouse")
|
create_warehouse("Rack Warehouse")
|
||||||
|
|
||||||
|
if not frappe.db.exists("DocType", "Pallet"):
|
||||||
|
frappe.get_doc(
|
||||||
|
{
|
||||||
|
"doctype": "DocType",
|
||||||
|
"name": "Pallet",
|
||||||
|
"module": "Stock",
|
||||||
|
"custom": 1,
|
||||||
|
"naming_rule": "By fieldname",
|
||||||
|
"autoname": "field:pallet_name",
|
||||||
|
"fields": [{"label": "Pallet Name", "fieldname": "pallet_name", "fieldtype": "Data"}],
|
||||||
|
"permissions": [
|
||||||
|
{"role": "System Manager", "permlevel": 0, "read": 1, "write": 1, "create": 1, "delete": 1}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
).insert(ignore_permissions=True)
|
||||||
|
|
||||||
|
|
||||||
def create_inventory_dimension(**args):
|
def create_inventory_dimension(**args):
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
|
|||||||
@@ -366,10 +366,11 @@ frappe.ui.form.on('Material Request', {
|
|||||||
|
|
||||||
frappe.ui.form.on("Material Request Item", {
|
frappe.ui.form.on("Material Request Item", {
|
||||||
qty: function (frm, doctype, name) {
|
qty: function (frm, doctype, name) {
|
||||||
var d = locals[doctype][name];
|
const item = locals[doctype][name];
|
||||||
if (flt(d.qty) < flt(d.min_order_qty)) {
|
if (flt(item.qty) < flt(item.min_order_qty)) {
|
||||||
frappe.msgprint(__("Warning: Material Requested Qty is less than Minimum Order Qty"));
|
frappe.msgprint(__("Warning: Material Requested Qty is less than Minimum Order Qty"));
|
||||||
}
|
}
|
||||||
|
frm.events.get_item_data(frm, item, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
from_warehouse: function(frm, doctype, name) {
|
from_warehouse: function(frm, doctype, name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user