mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 05:29:18 +00:00
Fetch deatils from Item and Asset Category
This commit is contained in:
@@ -8,7 +8,9 @@ frappe.ui.form.on('Asset', {
|
|||||||
frm.set_query("item_code", function() {
|
frm.set_query("item_code", function() {
|
||||||
return {
|
return {
|
||||||
"filters": {
|
"filters": {
|
||||||
"disabled": 0
|
"disabled": 0,
|
||||||
|
"is_fixed_asset": 1,
|
||||||
|
"is_stock_item": 0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -113,6 +115,24 @@ frappe.ui.form.on('Asset', {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
item_code: function(frm) {
|
||||||
|
if(frm.doc.item_code) {
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.accounts.doctype.asset.asset.get_item_details",
|
||||||
|
args: {
|
||||||
|
item_code: frm.doc.item_code
|
||||||
|
},
|
||||||
|
callback: function(r, rt) {
|
||||||
|
if(r.message) {
|
||||||
|
$.each(r.message, function(field, value) {
|
||||||
|
frm.set_value(field, value);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
is_existing_asset: function(frm) {
|
is_existing_asset: function(frm) {
|
||||||
frm.toggle_enable("supplier", frm.doc.is_existing_asset);
|
frm.toggle_enable("supplier", frm.doc.is_existing_asset);
|
||||||
frm.toggle_reqd("next_depreciation_date", !frm.doc.is_existing_asset);
|
frm.toggle_reqd("next_depreciation_date", !frm.doc.is_existing_asset);
|
||||||
|
|||||||
@@ -35,32 +35,6 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"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": 1,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@@ -87,6 +61,32 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"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": 1,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@@ -733,13 +733,14 @@
|
|||||||
"hide_toolbar": 0,
|
"hide_toolbar": 0,
|
||||||
"idx": 72,
|
"idx": 72,
|
||||||
"image_field": "image",
|
"image_field": "image",
|
||||||
|
"image_view": 0,
|
||||||
"in_create": 0,
|
"in_create": 0,
|
||||||
"in_dialog": 0,
|
"in_dialog": 0,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2016-05-30 18:09:56.158782",
|
"modified": "2016-07-05 12:54:38.585259",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Asset",
|
"name": "Asset",
|
||||||
|
|||||||
@@ -30,9 +30,16 @@ class Asset(Document):
|
|||||||
self.set_status()
|
self.set_status()
|
||||||
|
|
||||||
def validate_item(self):
|
def validate_item(self):
|
||||||
item = frappe.get_doc("Item", self.item_code)
|
item = frappe.db.get_value("Item", self.item_code,
|
||||||
if item.disabled:
|
["is_fixed_asset", "is_stock_item", "disabled"], as_dict=1)
|
||||||
|
if not item:
|
||||||
|
frappe.throw(_("Item {0} does not exist").format(self.item_code))
|
||||||
|
elif item.disabled:
|
||||||
frappe.throw(_("Item {0} has been disabled").format(self.item_code))
|
frappe.throw(_("Item {0} has been disabled").format(self.item_code))
|
||||||
|
elif not item.is_fixed_asset:
|
||||||
|
frappe.throw(_("Item {0} must be a Fixed Asset Item").format(self.item_code))
|
||||||
|
elif item.is_stock_item:
|
||||||
|
frappe.throw(_("Item {0} must be a non-stock item").format(self.item_code))
|
||||||
|
|
||||||
def validate_asset_values(self):
|
def validate_asset_values(self):
|
||||||
self.value_after_depreciation = flt(self.gross_purchase_amount) - flt(self.opening_accumulated_depreciation)
|
self.value_after_depreciation = flt(self.gross_purchase_amount) - flt(self.opening_accumulated_depreciation)
|
||||||
@@ -203,4 +210,17 @@ def transfer_asset(args):
|
|||||||
|
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
frappe.msgprint(_("Asset Movement record {0} created").format("<a href='#Form/Asset Movement/{0}'>{0}</a>".format(movement_entry.name)))
|
frappe.msgprint(_("Asset Movement record {0} created").format("<a href='#Form/Asset Movement/{0}'>{0}</a>".format(movement_entry.name)))
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_item_details(item_code):
|
||||||
|
asset_category = frappe.db.get_value("Item", item_code, "asset_category")
|
||||||
|
|
||||||
|
ret = frappe.db.get_value("Asset Category", asset_category,
|
||||||
|
["depreciation_method", "total_number_of_depreciations", "frequency_of_depreciation"], as_dict=1)
|
||||||
|
|
||||||
|
ret.update({
|
||||||
|
"asset_category": asset_category
|
||||||
|
})
|
||||||
|
|
||||||
|
return ret
|
||||||
Reference in New Issue
Block a user