Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create/update assets accounting dimension on migrate #108

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion assets/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
def after_install():
create_custom_fields()
create_property_setter()
make_accounting_dimension()

def after_migrate():
create_custom_fields()
create_property_setter()
make_accounting_dimension()

def before_uninstall():
delete_property_setters()
Expand Down Expand Up @@ -99,4 +101,16 @@ def delete_auto_created_custom_fields():
doctype_list = frappe.get_all("DocType", {"module": "Assets"}, pluck = "name")
custom_field_list = frappe.get_all("Custom Field", {"fieldtype": "Link", "options": ["In", doctype_list]}, pluck = "name")
for custom_field in custom_field_list:
frappe.db.delete("Custom Field", {"name": custom_field})
frappe.db.delete("Custom Field", {"name": custom_field})

def make_accounting_dimension():
accounting_dimensions = frappe.get_all("Accounting Dimension", pluck= "name")
from assets.hooks import accounting_dimension_doctypes
for dimension in accounting_dimensions:
frappe.enqueue(
"erpnext.accounts.doctype.accounting_dimension.accounting_dimension.make_dimension_in_accounting_doctypes",
doc=frappe.get_doc("Accounting Dimension", dimension),
doclist = accounting_dimension_doctypes,
queue="long",
enqueue_after_commit=True
)