fix: refactor Asset Repair and Stock Entry linkage to resolve amendme… (#41919)

* fix: refactor Asset Repair and Stock Entry linkage to resolve amendment issues

* chore: added missing patch to patches.txt

* chore: fixing previous changes

* chore: fixing minor issues

* fix: code changes to enhance efficiency

* chore: replaced frappe.qb with db.sql because of conflict

* fix: minor changes
This commit is contained in:
Khushi Rawat
2024-06-27 17:34:25 +05:30
committed by GitHub
parent 9738c04ef0
commit ba79e68190
11 changed files with 160 additions and 92 deletions

View File

@@ -0,0 +1,15 @@
import frappe
from frappe.query_builder import DocType
def execute():
if frappe.db.has_column("Asset Repair", "stock_entry"):
AssetRepair = DocType("Asset Repair")
StockEntry = DocType("Stock Entry")
(
frappe.qb.update(StockEntry)
.join(AssetRepair)
.on(StockEntry.name == AssetRepair.stock_entry)
.set(StockEntry.asset_repair, AssetRepair.name)
).run()

View File

@@ -0,0 +1,14 @@
import frappe
# not able to use frappe.qb because of this bug https://github.com/frappe/frappe/issues/20292
def execute():
if frappe.db.has_column("Asset Repair", "warehouse"):
# nosemgrep
frappe.db.sql(
"""UPDATE `tabAsset Repair Consumed Item` ar_item
JOIN `tabAsset Repair` ar
ON ar.name = ar_item.parent
SET ar_item.warehouse = ar.warehouse
WHERE ifnull(ar.warehouse, '') != ''"""
)