-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Set available-for-use date if missing (#30838)
- Loading branch information
1 parent
e9e2dcc
commit bf2eaec
Showing
3 changed files
with
57 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
erpnext/patches/v13_0/set_available_for_use_date_if_missing.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import frappe | ||
|
||
|
||
def execute(): | ||
""" | ||
Sets available-for-use date for Assets created in older versions of ERPNext, | ||
before the field was introduced. | ||
""" | ||
|
||
assets = get_assets_without_available_for_use_date() | ||
|
||
for asset in assets: | ||
frappe.db.set_value("Asset", asset.name, "available_for_use_date", asset.purchase_date) | ||
|
||
def get_assets_without_available_for_use_date(): | ||
return frappe.get_all( | ||
"Asset", | ||
filters = { | ||
"available_for_use_date": ["in", ["", None]] | ||
}, | ||
fields = ["name", "purchase_date"] | ||
) |