Is Fixed Asset and Asset Category field added in Item

This commit is contained in:
Nabin Hait 2016-07-04 13:13:22 +05:30
parent 21f443e37c
commit 2dec0db3bd
2 changed files with 62 additions and 1 deletions

View File

@ -430,6 +430,58 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "is_fixed_asset",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Is Fixed Asset",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"depends_on": "is_fixed_asset",
"fieldname": "asset_category",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Asset Category",
"length": 0,
"no_copy": 0,
"options": "Asset Category",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -2307,7 +2359,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 1,
"modified": "2016-07-06 16:00:45.561339",
"modified": "2016-07-06 16:00:45.561349",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",

View File

@ -86,6 +86,7 @@ class Item(WebsiteGenerator):
self.validate_variant_attributes()
self.validate_website_image()
self.make_thumbnail()
self.validate_fixed_asset()
if not self.get("__islocal"):
self.old_item_group = frappe.db.get_value(self.doctype, self.name, "item_group")
@ -220,6 +221,14 @@ class Item(WebsiteGenerator):
file_doc.make_thumbnail()
self.thumbnail = file_doc.thumbnail_url
def validate_fixed_asset(self):
if self.is_fixed_asset:
if self.is_stock_item:
frappe.throw(_("Fixed Asset Item must be a non-stock item."))
if not self.asset_category:
frappe.throw(_("Asset Category is mandatory for Fixed Asset item"))
def get_context(self, context):
context.show_search=True