fix: Handle Blank from/to range in Numeric Item Attribute
This commit is contained in:
		
							parent
							
								
									db8764a520
								
							
						
					
					
						commit
						c213cd96c5
					
				| @ -1,357 +1,97 @@ | |||||||
| { | { | ||||||
|  "allow_copy": 0,  |  "actions": [], | ||||||
|  "allow_events_in_timeline": 0,  |  "allow_import": 1, | ||||||
|  "allow_guest_to_view": 0,  |  "allow_rename": 1, | ||||||
|  "allow_import": 1,  |  "autoname": "field:attribute_name", | ||||||
|  "allow_rename": 1,  |  "creation": "2014-09-26 03:49:54.899170", | ||||||
|  "autoname": "field:attribute_name",  |  "doctype": "DocType", | ||||||
|  "beta": 0,  |  "document_type": "Setup", | ||||||
|  "creation": "2014-09-26 03:49:54.899170",  |  "engine": "InnoDB", | ||||||
|  "custom": 0,  |  "field_order": [ | ||||||
|  "docstatus": 0,  |   "attribute_name", | ||||||
|  "doctype": "DocType",  |   "numeric_values", | ||||||
|  "document_type": "Setup",  |   "section_break_4", | ||||||
|  "editable_grid": 0,  |   "from_range", | ||||||
|  |   "increment", | ||||||
|  |   "column_break_8", | ||||||
|  |   "to_range", | ||||||
|  |   "section_break_5", | ||||||
|  |   "item_attribute_values" | ||||||
|  |  ], | ||||||
|  "fields": [ |  "fields": [ | ||||||
|   { |   { | ||||||
|    "allow_bulk_edit": 0,  |    "fieldname": "attribute_name", | ||||||
|    "allow_in_quick_entry": 0,  |    "fieldtype": "Data", | ||||||
|    "allow_on_submit": 0,  |    "in_list_view": 1, | ||||||
|    "bold": 0,  |    "label": "Attribute Name", | ||||||
|    "collapsible": 0,  |    "reqd": 1, | ||||||
|    "columns": 0,  |  | ||||||
|    "fieldname": "attribute_name",  |  | ||||||
|    "fieldtype": "Data",  |  | ||||||
|    "hidden": 0,  |  | ||||||
|    "ignore_user_permissions": 0,  |  | ||||||
|    "ignore_xss_filter": 0,  |  | ||||||
|    "in_filter": 0,  |  | ||||||
|    "in_global_search": 0,  |  | ||||||
|    "in_list_view": 1,  |  | ||||||
|    "in_standard_filter": 0,  |  | ||||||
|    "label": "Attribute Name",  |  | ||||||
|    "length": 0,  |  | ||||||
|    "no_copy": 0,  |  | ||||||
|    "permlevel": 0,  |  | ||||||
|    "precision": "",  |  | ||||||
|    "print_hide": 0,  |  | ||||||
|    "print_hide_if_no_value": 0,  |  | ||||||
|    "read_only": 0,  |  | ||||||
|    "remember_last_selected_value": 0,  |  | ||||||
|    "report_hide": 0,  |  | ||||||
|    "reqd": 1,  |  | ||||||
|    "search_index": 0,  |  | ||||||
|    "set_only_once": 0,  |  | ||||||
|    "translatable": 0,  |  | ||||||
|    "unique": 1 |    "unique": 1 | ||||||
|   },  |   }, | ||||||
|   { |   { | ||||||
|    "allow_bulk_edit": 0,  |    "default": "0", | ||||||
|    "allow_in_quick_entry": 0,  |    "fieldname": "numeric_values", | ||||||
|    "allow_on_submit": 0,  |    "fieldtype": "Check", | ||||||
|    "bold": 0,  |    "label": "Numeric Values" | ||||||
|    "collapsible": 0,  |   }, | ||||||
|    "columns": 0,  |  | ||||||
|    "default": "0",  |  | ||||||
|    "fieldname": "numeric_values",  |  | ||||||
|    "fieldtype": "Check",  |  | ||||||
|    "hidden": 0,  |  | ||||||
|    "ignore_user_permissions": 0,  |  | ||||||
|    "ignore_xss_filter": 0,  |  | ||||||
|    "in_filter": 0,  |  | ||||||
|    "in_global_search": 0,  |  | ||||||
|    "in_list_view": 0,  |  | ||||||
|    "in_standard_filter": 0,  |  | ||||||
|    "label": "Numeric Values",  |  | ||||||
|    "length": 0,  |  | ||||||
|    "no_copy": 0,  |  | ||||||
|    "permlevel": 0,  |  | ||||||
|    "precision": "",  |  | ||||||
|    "print_hide": 0,  |  | ||||||
|    "print_hide_if_no_value": 0,  |  | ||||||
|    "read_only": 0,  |  | ||||||
|    "remember_last_selected_value": 0,  |  | ||||||
|    "report_hide": 0,  |  | ||||||
|    "reqd": 0,  |  | ||||||
|    "search_index": 0,  |  | ||||||
|    "set_only_once": 0,  |  | ||||||
|    "translatable": 0,  |  | ||||||
|    "unique": 0 |  | ||||||
|   },  |  | ||||||
|   { |   { | ||||||
|    "allow_bulk_edit": 0,  |    "depends_on": "numeric_values", | ||||||
|    "allow_in_quick_entry": 0,  |    "fieldname": "section_break_4", | ||||||
|    "allow_on_submit": 0,  |    "fieldtype": "Section Break" | ||||||
|    "bold": 0,  |   }, | ||||||
|    "collapsible": 0,  |  | ||||||
|    "columns": 0,  |  | ||||||
|    "depends_on": "numeric_values",  |  | ||||||
|    "fieldname": "section_break_4",  |  | ||||||
|    "fieldtype": "Section Break",  |  | ||||||
|    "hidden": 0,  |  | ||||||
|    "ignore_user_permissions": 0,  |  | ||||||
|    "ignore_xss_filter": 0,  |  | ||||||
|    "in_filter": 0,  |  | ||||||
|    "in_global_search": 0,  |  | ||||||
|    "in_list_view": 0,  |  | ||||||
|    "in_standard_filter": 0,  |  | ||||||
|    "length": 0,  |  | ||||||
|    "no_copy": 0,  |  | ||||||
|    "permlevel": 0,  |  | ||||||
|    "precision": "",  |  | ||||||
|    "print_hide": 0,  |  | ||||||
|    "print_hide_if_no_value": 0,  |  | ||||||
|    "read_only": 0,  |  | ||||||
|    "remember_last_selected_value": 0,  |  | ||||||
|    "report_hide": 0,  |  | ||||||
|    "reqd": 0,  |  | ||||||
|    "search_index": 0,  |  | ||||||
|    "set_only_once": 0,  |  | ||||||
|    "translatable": 0,  |  | ||||||
|    "unique": 0 |  | ||||||
|   },  |  | ||||||
|   { |   { | ||||||
|    "allow_bulk_edit": 0,  |    "default": "0", | ||||||
|    "allow_in_quick_entry": 0,  |    "fieldname": "from_range", | ||||||
|    "allow_on_submit": 0,  |    "fieldtype": "Float", | ||||||
|    "bold": 0,  |    "label": "From Range" | ||||||
|    "collapsible": 0,  |   }, | ||||||
|    "columns": 0,  |  | ||||||
|    "depends_on": "",  |  | ||||||
|    "fieldname": "from_range",  |  | ||||||
|    "fieldtype": "Float",  |  | ||||||
|    "hidden": 0,  |  | ||||||
|    "ignore_user_permissions": 0,  |  | ||||||
|    "ignore_xss_filter": 0,  |  | ||||||
|    "in_filter": 0,  |  | ||||||
|    "in_global_search": 0,  |  | ||||||
|    "in_list_view": 0,  |  | ||||||
|    "in_standard_filter": 0,  |  | ||||||
|    "label": "From Range",  |  | ||||||
|    "length": 0,  |  | ||||||
|    "no_copy": 0,  |  | ||||||
|    "permlevel": 0,  |  | ||||||
|    "precision": "",  |  | ||||||
|    "print_hide": 0,  |  | ||||||
|    "print_hide_if_no_value": 0,  |  | ||||||
|    "read_only": 0,  |  | ||||||
|    "remember_last_selected_value": 0,  |  | ||||||
|    "report_hide": 0,  |  | ||||||
|    "reqd": 0,  |  | ||||||
|    "search_index": 0,  |  | ||||||
|    "set_only_once": 0,  |  | ||||||
|    "translatable": 0,  |  | ||||||
|    "unique": 0 |  | ||||||
|   },  |  | ||||||
|   { |   { | ||||||
|    "allow_bulk_edit": 0,  |    "default": "0", | ||||||
|    "allow_in_quick_entry": 0,  |    "fieldname": "increment", | ||||||
|    "allow_on_submit": 0,  |    "fieldtype": "Float", | ||||||
|    "bold": 0,  |    "label": "Increment" | ||||||
|    "collapsible": 0,  |   }, | ||||||
|    "columns": 0,  |  | ||||||
|    "depends_on": "",  |  | ||||||
|    "fieldname": "increment",  |  | ||||||
|    "fieldtype": "Float",  |  | ||||||
|    "hidden": 0,  |  | ||||||
|    "ignore_user_permissions": 0,  |  | ||||||
|    "ignore_xss_filter": 0,  |  | ||||||
|    "in_filter": 0,  |  | ||||||
|    "in_global_search": 0,  |  | ||||||
|    "in_list_view": 0,  |  | ||||||
|    "in_standard_filter": 0,  |  | ||||||
|    "label": "Increment",  |  | ||||||
|    "length": 0,  |  | ||||||
|    "no_copy": 0,  |  | ||||||
|    "permlevel": 0,  |  | ||||||
|    "precision": "",  |  | ||||||
|    "print_hide": 0,  |  | ||||||
|    "print_hide_if_no_value": 0,  |  | ||||||
|    "read_only": 0,  |  | ||||||
|    "remember_last_selected_value": 0,  |  | ||||||
|    "report_hide": 0,  |  | ||||||
|    "reqd": 0,  |  | ||||||
|    "search_index": 0,  |  | ||||||
|    "set_only_once": 0,  |  | ||||||
|    "translatable": 0,  |  | ||||||
|    "unique": 0 |  | ||||||
|   },  |  | ||||||
|   { |   { | ||||||
|    "allow_bulk_edit": 0,  |    "fieldname": "column_break_8", | ||||||
|    "allow_in_quick_entry": 0,  |    "fieldtype": "Column Break" | ||||||
|    "allow_on_submit": 0,  |   }, | ||||||
|    "bold": 0,  |  | ||||||
|    "collapsible": 0,  |  | ||||||
|    "columns": 0,  |  | ||||||
|    "fieldname": "column_break_8",  |  | ||||||
|    "fieldtype": "Column Break",  |  | ||||||
|    "hidden": 0,  |  | ||||||
|    "ignore_user_permissions": 0,  |  | ||||||
|    "ignore_xss_filter": 0,  |  | ||||||
|    "in_filter": 0,  |  | ||||||
|    "in_global_search": 0,  |  | ||||||
|    "in_list_view": 0,  |  | ||||||
|    "in_standard_filter": 0,  |  | ||||||
|    "length": 0,  |  | ||||||
|    "no_copy": 0,  |  | ||||||
|    "permlevel": 0,  |  | ||||||
|    "precision": "",  |  | ||||||
|    "print_hide": 0,  |  | ||||||
|    "print_hide_if_no_value": 0,  |  | ||||||
|    "read_only": 0,  |  | ||||||
|    "remember_last_selected_value": 0,  |  | ||||||
|    "report_hide": 0,  |  | ||||||
|    "reqd": 0,  |  | ||||||
|    "search_index": 0,  |  | ||||||
|    "set_only_once": 0,  |  | ||||||
|    "translatable": 0,  |  | ||||||
|    "unique": 0 |  | ||||||
|   },  |  | ||||||
|   { |   { | ||||||
|    "allow_bulk_edit": 0,  |    "default": "0", | ||||||
|    "allow_in_quick_entry": 0,  |    "fieldname": "to_range", | ||||||
|    "allow_on_submit": 0,  |    "fieldtype": "Float", | ||||||
|    "bold": 0,  |    "label": "To Range" | ||||||
|    "collapsible": 0,  |   }, | ||||||
|    "columns": 0,  |  | ||||||
|    "depends_on": "",  |  | ||||||
|    "fieldname": "to_range",  |  | ||||||
|    "fieldtype": "Float",  |  | ||||||
|    "hidden": 0,  |  | ||||||
|    "ignore_user_permissions": 0,  |  | ||||||
|    "ignore_xss_filter": 0,  |  | ||||||
|    "in_filter": 0,  |  | ||||||
|    "in_global_search": 0,  |  | ||||||
|    "in_list_view": 0,  |  | ||||||
|    "in_standard_filter": 0,  |  | ||||||
|    "label": "To Range",  |  | ||||||
|    "length": 0,  |  | ||||||
|    "no_copy": 0,  |  | ||||||
|    "permlevel": 0,  |  | ||||||
|    "precision": "",  |  | ||||||
|    "print_hide": 0,  |  | ||||||
|    "print_hide_if_no_value": 0,  |  | ||||||
|    "read_only": 0,  |  | ||||||
|    "remember_last_selected_value": 0,  |  | ||||||
|    "report_hide": 0,  |  | ||||||
|    "reqd": 0,  |  | ||||||
|    "search_index": 0,  |  | ||||||
|    "set_only_once": 0,  |  | ||||||
|    "translatable": 0,  |  | ||||||
|    "unique": 0 |  | ||||||
|   },  |  | ||||||
|   { |   { | ||||||
|    "allow_bulk_edit": 0,  |    "depends_on": "eval: !doc.numeric_values", | ||||||
|    "allow_in_quick_entry": 0,  |    "fieldname": "section_break_5", | ||||||
|    "allow_on_submit": 0,  |    "fieldtype": "Section Break" | ||||||
|    "bold": 0,  |   }, | ||||||
|    "collapsible": 0,  |  | ||||||
|    "columns": 0,  |  | ||||||
|    "depends_on": "eval: !doc.numeric_values",  |  | ||||||
|    "fieldname": "section_break_5",  |  | ||||||
|    "fieldtype": "Section Break",  |  | ||||||
|    "hidden": 0,  |  | ||||||
|    "ignore_user_permissions": 0,  |  | ||||||
|    "ignore_xss_filter": 0,  |  | ||||||
|    "in_filter": 0,  |  | ||||||
|    "in_global_search": 0,  |  | ||||||
|    "in_list_view": 0,  |  | ||||||
|    "in_standard_filter": 0,  |  | ||||||
|    "length": 0,  |  | ||||||
|    "no_copy": 0,  |  | ||||||
|    "permlevel": 0,  |  | ||||||
|    "precision": "",  |  | ||||||
|    "print_hide": 0,  |  | ||||||
|    "print_hide_if_no_value": 0,  |  | ||||||
|    "read_only": 0,  |  | ||||||
|    "remember_last_selected_value": 0,  |  | ||||||
|    "report_hide": 0,  |  | ||||||
|    "reqd": 0,  |  | ||||||
|    "search_index": 0,  |  | ||||||
|    "set_only_once": 0,  |  | ||||||
|    "translatable": 0,  |  | ||||||
|    "unique": 0 |  | ||||||
|   },  |  | ||||||
|   { |   { | ||||||
|    "allow_bulk_edit": 0,  |    "fieldname": "item_attribute_values", | ||||||
|    "allow_in_quick_entry": 0,  |    "fieldtype": "Table", | ||||||
|    "allow_on_submit": 0,  |    "label": "Item Attribute Values", | ||||||
|    "bold": 0,  |    "options": "Item Attribute Value" | ||||||
|    "collapsible": 0,  |  | ||||||
|    "columns": 0,  |  | ||||||
|    "depends_on": "",  |  | ||||||
|    "fieldname": "item_attribute_values",  |  | ||||||
|    "fieldtype": "Table",  |  | ||||||
|    "hidden": 0,  |  | ||||||
|    "ignore_user_permissions": 0,  |  | ||||||
|    "ignore_xss_filter": 0,  |  | ||||||
|    "in_filter": 0,  |  | ||||||
|    "in_global_search": 0,  |  | ||||||
|    "in_list_view": 0,  |  | ||||||
|    "in_standard_filter": 0,  |  | ||||||
|    "label": "Item Attribute Values",  |  | ||||||
|    "length": 0,  |  | ||||||
|    "no_copy": 0,  |  | ||||||
|    "options": "Item Attribute Value",  |  | ||||||
|    "permlevel": 0,  |  | ||||||
|    "precision": "",  |  | ||||||
|    "print_hide": 0,  |  | ||||||
|    "print_hide_if_no_value": 0,  |  | ||||||
|    "read_only": 0,  |  | ||||||
|    "remember_last_selected_value": 0,  |  | ||||||
|    "report_hide": 0,  |  | ||||||
|    "reqd": 0,  |  | ||||||
|    "search_index": 0,  |  | ||||||
|    "set_only_once": 0,  |  | ||||||
|    "translatable": 0,  |  | ||||||
|    "unique": 0 |  | ||||||
|   } |   } | ||||||
|  ],  |  ], | ||||||
|  "has_web_view": 0,  |  "icon": "fa fa-edit", | ||||||
|  "hide_heading": 0,  |  "index_web_pages_for_search": 1, | ||||||
|  "hide_toolbar": 0,  |  "links": [], | ||||||
|  "icon": "fa fa-edit",  |  "modified": "2020-10-02 12:03:02.359202", | ||||||
|  "idx": 0,  |  "modified_by": "Administrator", | ||||||
|  "image_view": 0,  |  "module": "Stock", | ||||||
|  "in_create": 0,  |  "name": "Item Attribute", | ||||||
|  "is_submittable": 0,  |  "owner": "Administrator", | ||||||
|  "issingle": 0,  |  | ||||||
|  "istable": 0,  |  | ||||||
|  "max_attachments": 0,  |  | ||||||
|  "modified": "2019-01-01 13:17:46.524806",  |  | ||||||
|  "modified_by": "Administrator",  |  | ||||||
|  "module": "Stock",  |  | ||||||
|  "name": "Item Attribute",  |  | ||||||
|  "name_case": "",  |  | ||||||
|  "owner": "Administrator",  |  | ||||||
|  "permissions": [ |  "permissions": [ | ||||||
|   { |   { | ||||||
|    "amend": 0,  |    "create": 1, | ||||||
|    "cancel": 0,  |    "delete": 1, | ||||||
|    "create": 1,  |    "read": 1, | ||||||
|    "delete": 1,  |    "report": 1, | ||||||
|    "email": 0,  |    "role": "Item Manager", | ||||||
|    "export": 0,  |    "share": 1, | ||||||
|    "if_owner": 0,  |  | ||||||
|    "import": 0,  |  | ||||||
|    "permlevel": 0,  |  | ||||||
|    "print": 0,  |  | ||||||
|    "read": 1,  |  | ||||||
|    "report": 1,  |  | ||||||
|    "role": "Item Manager",  |  | ||||||
|    "set_user_permissions": 0,  |  | ||||||
|    "share": 1,  |  | ||||||
|    "submit": 0,  |  | ||||||
|    "write": 1 |    "write": 1 | ||||||
|   } |   } | ||||||
|  ],  |  ], | ||||||
|  "quick_entry": 0,  |  "sort_field": "modified", | ||||||
|  "read_only": 0,  |  "sort_order": "DESC", | ||||||
|  "read_only_onload": 0,  |  "track_changes": 1 | ||||||
|  "show_name_in_global_search": 0,  |  | ||||||
|  "sort_field": "modified",  |  | ||||||
|  "sort_order": "DESC",  |  | ||||||
|  "track_changes": 1,  |  | ||||||
|  "track_seen": 0,  |  | ||||||
|  "track_views": 0 |  | ||||||
| } | } | ||||||
| @ -5,6 +5,7 @@ from __future__ import unicode_literals | |||||||
| import frappe | import frappe | ||||||
| from frappe.model.document import Document | from frappe.model.document import Document | ||||||
| from frappe import _ | from frappe import _ | ||||||
|  | from frappe.utils import flt | ||||||
| 
 | 
 | ||||||
| from erpnext.controllers.item_variant import (validate_is_incremental, | from erpnext.controllers.item_variant import (validate_is_incremental, | ||||||
| 	validate_item_attribute_value, InvalidItemAttributeValueError) | 	validate_item_attribute_value, InvalidItemAttributeValueError) | ||||||
| @ -42,7 +43,7 @@ class ItemAttribute(Document): | |||||||
| 			if self.from_range is None or self.to_range is None: | 			if self.from_range is None or self.to_range is None: | ||||||
| 				frappe.throw(_("Please specify from/to range")) | 				frappe.throw(_("Please specify from/to range")) | ||||||
| 
 | 
 | ||||||
| 			elif self.from_range >= self.to_range: | 			elif flt(self.from_range) >= flt(self.to_range): | ||||||
| 				frappe.throw(_("From Range has to be less than To Range")) | 				frappe.throw(_("From Range has to be less than To Range")) | ||||||
| 
 | 
 | ||||||
| 			if not self.increment: | 			if not self.increment: | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user