Multiple fixes in asset

This commit is contained in:
Rohit Waghchaure 2018-05-16 22:12:39 +05:30
parent 4ea97c84ac
commit e6acd4c57a
3 changed files with 13 additions and 5 deletions

View File

@ -157,6 +157,13 @@ frappe.ui.form.on('Asset', {
}
},
available_for_use_date: function(frm) {
$.each(frm.doc.finance_books || [], function(i, d) {
if(!d.depreciation_start_date) d.depreciation_start_date = frm.doc.available_for_use_date;
});
refresh_field("finance_books");
},
is_existing_asset: function(frm) {
// frm.toggle_reqd("next_depreciation_date", (!frm.doc.is_existing_asset && frm.doc.calculate_depreciation));
},

View File

@ -51,7 +51,7 @@ class Asset(AccountsController):
def validate_in_use_date(self):
if not self.available_for_use_date:
frappe.throw(_("Available for use data is required"))
frappe.throw(_("Available for use date is required"))
def set_missing_values(self):
if not self.asset_category:
@ -162,6 +162,9 @@ class Asset(AccountsController):
frappe.throw(_("Row {0}: Expected Value After Useful Life must be less than Gross Purchase Amount")
.format(row.idx))
if not row.depreciation_start_date:
frappe.throw(_("Row {0}: Depreciation Start Date is required").format(row.idx))
if not self.is_existing_asset:
self.opening_accumulated_depreciation = 0
self.number_of_depreciations_booked = 0

View File

@ -55,7 +55,5 @@ class AssetMovement(Document):
frappe.db.set_value("Asset", self.asset, "location", location)
if self.serial_no:
serial_nos = get_serial_nos(self.serial_no)
frappe.db.sql(""" update `tabSerial No` set location = %s where name in (%s)"""
%('%s', ','.join(['%s'] * len(serial_nos))), (location, tuple(serial_nos)))
for d in get_serial_nos(self.serial_no):
frappe.db.set_value('Serial No', d, 'location', location)