feat(Asset Maintenance): Increase Asset value if Stock Items were consumed
This commit is contained in:
parent
d1f521701c
commit
70bad470f7
@ -26,6 +26,7 @@ class AssetMaintenance(Document):
|
|||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
self.check_for_stock_items_and_warehouse()
|
self.check_for_stock_items_and_warehouse()
|
||||||
|
self.increase_asset_value()
|
||||||
|
|
||||||
def check_for_stock_items_and_warehouse(self):
|
def check_for_stock_items_and_warehouse(self):
|
||||||
if self.stock_consumption:
|
if self.stock_consumption:
|
||||||
@ -34,6 +35,13 @@ class AssetMaintenance(Document):
|
|||||||
if not self.warehouse:
|
if not self.warehouse:
|
||||||
frappe.throw(_("Please enter Warehouse from which Stock Items consumed during Asset Maintenance were taken."))
|
frappe.throw(_("Please enter Warehouse from which Stock Items consumed during Asset Maintenance were taken."))
|
||||||
|
|
||||||
|
def increase_asset_value(self):
|
||||||
|
asset_value = frappe.db.get_value('Asset', self.asset, 'asset_value')
|
||||||
|
for item in self.stock_items:
|
||||||
|
asset_value += item.total_value
|
||||||
|
|
||||||
|
frappe.db.set_value('Asset', self.asset, 'asset_value', asset_value)
|
||||||
|
|
||||||
def sync_maintenance_tasks(self):
|
def sync_maintenance_tasks(self):
|
||||||
tasks_names = []
|
tasks_names = []
|
||||||
for task in self.get('asset_maintenance_tasks'):
|
for task in self.get('asset_maintenance_tasks'):
|
||||||
|
Loading…
Reference in New Issue
Block a user