Merge pull request #33077 from rohitwaghchaure/ux-for-inventory-dimension
fix: UX for inventory dimension
This commit is contained in:
commit
68424887e4
@ -71,6 +71,8 @@ frappe.ui.form.on('Inventory Dimension', {
|
||||
if (r.message && r.message.length) {
|
||||
frm.set_df_property("fetch_from_parent", "options",
|
||||
[""].concat(r.message));
|
||||
} else {
|
||||
frm.set_df_property("fetch_from_parent", "hidden", 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -11,20 +11,20 @@
|
||||
"reference_document",
|
||||
"column_break_4",
|
||||
"disabled",
|
||||
"section_break_7",
|
||||
"field_mapping_section",
|
||||
"source_fieldname",
|
||||
"column_break_9",
|
||||
"target_fieldname",
|
||||
"applicable_for_documents_tab",
|
||||
"apply_to_all_doctypes",
|
||||
"column_break_13",
|
||||
"document_type",
|
||||
"istable",
|
||||
"type_of_transaction",
|
||||
"fetch_from_parent",
|
||||
"column_break_16",
|
||||
"condition",
|
||||
"istable",
|
||||
"applicable_condition_example_section",
|
||||
"condition",
|
||||
"conditional_rule_examples_section",
|
||||
"html_19"
|
||||
],
|
||||
"fields": [
|
||||
@ -52,13 +52,13 @@
|
||||
{
|
||||
"fieldname": "applicable_for_documents_tab",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Applicable For Documents"
|
||||
"label": "Applicable For"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!doc.apply_to_all_doctypes",
|
||||
"fieldname": "document_type",
|
||||
"fieldtype": "Link",
|
||||
"label": "Applicable to Document",
|
||||
"label": "Apply to Document",
|
||||
"mandatory_depends_on": "eval:!doc.apply_to_all_doctypes",
|
||||
"options": "DocType"
|
||||
},
|
||||
@ -72,6 +72,7 @@
|
||||
"fetch_from": "document_type.istable",
|
||||
"fieldname": "istable",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"label": " Is Child Table",
|
||||
"read_only": 1
|
||||
},
|
||||
@ -79,13 +80,13 @@
|
||||
"depends_on": "eval:!doc.apply_to_all_doctypes",
|
||||
"fieldname": "condition",
|
||||
"fieldtype": "Code",
|
||||
"label": "Applicable Condition"
|
||||
"label": "Conditional Rule"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"default": "1",
|
||||
"fieldname": "apply_to_all_doctypes",
|
||||
"fieldtype": "Check",
|
||||
"label": "Apply to All Inventory Document Types"
|
||||
"label": "Apply to All Inventory Documents"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
@ -93,10 +94,6 @@
|
||||
"fieldtype": "Check",
|
||||
"label": "Disabled"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_7",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "target_fieldname",
|
||||
"fieldtype": "Data",
|
||||
@ -115,13 +112,11 @@
|
||||
"collapsible": 1,
|
||||
"fieldname": "field_mapping_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 1,
|
||||
"label": "Field Mapping"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_16",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!doc.apply_to_all_doctypes",
|
||||
"fieldname": "type_of_transaction",
|
||||
"fieldtype": "Select",
|
||||
"label": "Type of Transaction",
|
||||
@ -136,23 +131,33 @@
|
||||
"collapsible": 1,
|
||||
"depends_on": "eval:!doc.apply_to_all_doctypes",
|
||||
"fieldname": "applicable_condition_example_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Applicable Condition Examples"
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_4",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"description": "Set fieldname or DocType name like Supplier, Customer etc.",
|
||||
"depends_on": "eval:!doc.apply_to_all_doctypes",
|
||||
"description": "Set fieldname from which you want to fetch the data from the parent form.",
|
||||
"fieldname": "fetch_from_parent",
|
||||
"fieldtype": "Select",
|
||||
"label": "Fetch Value From Parent Form"
|
||||
"label": "Fetch Value From"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_13",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!doc.apply_to_all_doctypes",
|
||||
"fieldname": "conditional_rule_examples_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Conditional Rule Examples"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2022-09-02 13:29:04.098469",
|
||||
"modified": "2022-11-15 15:50:16.767105",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Inventory Dimension",
|
||||
|
@ -33,10 +33,22 @@ class InventoryDimension(Document):
|
||||
)
|
||||
|
||||
def validate(self):
|
||||
self.validate_reference_document()
|
||||
|
||||
def before_save(self):
|
||||
self.do_not_update_document()
|
||||
self.reset_value()
|
||||
self.validate_reference_document()
|
||||
self.set_source_and_target_fieldname()
|
||||
self.set_type_of_transaction()
|
||||
self.set_fetch_value_from()
|
||||
|
||||
def set_type_of_transaction(self):
|
||||
if self.apply_to_all_doctypes:
|
||||
self.type_of_transaction = "Both"
|
||||
|
||||
def set_fetch_value_from(self):
|
||||
if self.apply_to_all_doctypes:
|
||||
self.fetch_from_parent = self.reference_document
|
||||
|
||||
def do_not_update_document(self):
|
||||
if self.is_new() or not self.has_stock_ledger():
|
||||
|
@ -140,14 +140,13 @@ class TestInventoryDimension(FrappeTestCase):
|
||||
self.assertRaises(DoNotChangeError, inv_dim1.save)
|
||||
|
||||
def test_inventory_dimension_for_purchase_receipt_and_delivery_note(self):
|
||||
create_inventory_dimension(
|
||||
reference_document="Rack",
|
||||
type_of_transaction="Both",
|
||||
dimension_name="Rack",
|
||||
apply_to_all_doctypes=1,
|
||||
fetch_from_parent="Rack",
|
||||
inv_dimension = create_inventory_dimension(
|
||||
reference_document="Rack", dimension_name="Rack", apply_to_all_doctypes=1
|
||||
)
|
||||
|
||||
self.assertEqual(inv_dimension.type_of_transaction, "Both")
|
||||
self.assertEqual(inv_dimension.fetch_from_parent, "Rack")
|
||||
|
||||
create_custom_field(
|
||||
"Purchase Receipt", dict(fieldname="rack", label="Rack", fieldtype="Link", options="Rack")
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user