mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
Merge branch 'version-14-hotfix' of https://github.com/frappe/erpnext into 14_warning_depreciation_regional_france
This commit is contained in:
@@ -46,6 +46,17 @@ def execute():
|
||||
for doctype in doctypes:
|
||||
frappe.delete_doc("DocType", doctype, ignore_missing=True)
|
||||
|
||||
titles = [
|
||||
"Fees",
|
||||
"Student Admission",
|
||||
"Grant Application",
|
||||
"Chapter",
|
||||
"Certification Application",
|
||||
]
|
||||
items = frappe.get_all("Portal Menu Item", filters=[["title", "in", titles]], pluck="name")
|
||||
for item in items:
|
||||
frappe.delete_doc("Portal Menu Item", item, ignore_missing=True, force=True)
|
||||
|
||||
frappe.delete_doc("Module Def", "Education", ignore_missing=True, force=True)
|
||||
|
||||
click.secho(
|
||||
|
||||
@@ -41,7 +41,7 @@ def execute():
|
||||
for card in cards:
|
||||
frappe.delete_doc("Number Card", card, ignore_missing=True, force=True)
|
||||
|
||||
titles = ["Lab Test", "Prescription", "Patient Appointment"]
|
||||
titles = ["Lab Test", "Prescription", "Patient Appointment", "Patient"]
|
||||
items = frappe.get_all("Portal Menu Item", filters=[["title", "in", titles]], pluck="name")
|
||||
for item in items:
|
||||
frappe.delete_doc("Portal Menu Item", item, ignore_missing=True, force=True)
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
try:
|
||||
item_dict = get_deferred_accounts()
|
||||
add_to_item_defaults(item_dict)
|
||||
except Exception:
|
||||
frappe.db.rollback()
|
||||
frappe.log_error("Failed to migrate deferred accounts in Item Defaults.")
|
||||
|
||||
|
||||
def get_deferred_accounts():
|
||||
item = frappe.qb.DocType("Item")
|
||||
return (
|
||||
frappe.qb.from_(item)
|
||||
.select(item.name, item.deferred_expense_account, item.deferred_revenue_account)
|
||||
.where((item.enable_deferred_expense == 1) | (item.enable_deferred_revenue == 1))
|
||||
.run(as_dict=True)
|
||||
)
|
||||
|
||||
|
||||
def add_to_item_defaults(item_dict):
|
||||
for item in item_dict:
|
||||
add_company_wise_item_default(item, "deferred_expense_account")
|
||||
add_company_wise_item_default(item, "deferred_revenue_account")
|
||||
|
||||
|
||||
def add_company_wise_item_default(item, account_type):
|
||||
company = frappe.get_cached_value("Account", item[account_type], "company")
|
||||
if company and item[account_type]:
|
||||
item_defaults = frappe.get_cached_value("Item", item["name"], "item_defaults")
|
||||
for item_row in item_defaults:
|
||||
if item_row.company == company:
|
||||
frappe.set_value("Item Default", item_row.name, account_type, item[account_type])
|
||||
break
|
||||
else:
|
||||
item_defaults.append({"company": company, account_type: item[account_type]})
|
||||
frappe.set_value("Item", item["name"], "item_defaults", item_defaults)
|
||||
Reference in New Issue
Block a user