chore: Add accounting dimensions to Sales Order Item table

(cherry picked from commit e31db18912)

# Conflicts:
#	erpnext/patches.txt
This commit is contained in:
Deepesh Garg
2023-10-17 18:19:47 +05:30
committed by Mergify
parent e23710bf00
commit bfa93cd3f6
5 changed files with 51 additions and 2 deletions

View File

@@ -301,3 +301,30 @@ def get_dimensions(with_cost_center_and_project=False):
default_dimensions_map[dimension.company][dimension.fieldname] = dimension.default_dimension
return dimension_filters, default_dimensions_map
def create_accounting_dimensions_for_doctype(doctype):
accounting_dimensions = frappe.db.get_all(
"Accounting Dimension", fields=["fieldname", "label", "document_type", "disabled"]
)
if not accounting_dimensions:
return
for d in accounting_dimensions:
field = frappe.db.get_value("Custom Field", {"dt": doctype, "fieldname": d.fieldname})
if field:
continue
df = {
"fieldname": d.fieldname,
"label": d.label,
"fieldtype": "Link",
"options": d.document_type,
"insert_after": "accounting_dimensions_section",
}
create_custom_field(doctype, df, ignore_validate=True)
frappe.clear_cache(doctype=doctype)

View File

@@ -517,6 +517,7 @@ accounting_dimension_doctypes = [
"Sales Invoice Item",
"Purchase Invoice Item",
"Purchase Order Item",
"Sales Order Item",
"Journal Entry Account",
"Material Request Item",
"Delivery Note Item",

View File

@@ -341,5 +341,12 @@ execute:frappe.defaults.clear_default("fiscal_year")
execute:frappe.db.set_single_value('Selling Settings', 'allow_negative_rates_for_items', 0)
erpnext.patches.v14_0.correct_asset_value_if_je_with_workflow
erpnext.patches.v14_0.migrate_deferred_accounts_to_item_defaults
<<<<<<< HEAD
=======
erpnext.patches.v14_0.update_invoicing_period_in_subscription
execute:frappe.delete_doc("Page", "welcome-to-erpnext")
erpnext.patches.v15_0.delete_payment_gateway_doctypes
erpnext.patches.v14_0.create_accounting_dimensions_in_sales_order_item
>>>>>>> e31db18912 (chore: Add accounting dimensions to Sales Order Item table)
# below migration patch should always run last
erpnext.patches.v14_0.migrate_gl_to_payment_ledger

View File

@@ -0,0 +1,7 @@
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
create_accounting_dimensions_for_doctype,
)
def execute():
create_accounting_dimensions_for_doctype(doctype="Sales Order Item")

View File

@@ -66,6 +66,7 @@
"total_weight",
"column_break_21",
"weight_uom",
"accounting_dimensions_section",
"warehouse_and_reference",
"warehouse",
"target_warehouse",
@@ -868,12 +869,18 @@
"label": "Production Plan Qty",
"no_copy": 1,
"read_only": 1
},
{
"collapsible": 1,
"fieldname": "accounting_dimensions_section",
"fieldtype": "Section Break",
"label": "Accounting Dimensions"
}
],
"idx": 1,
"istable": 1,
"links": [],
"modified": "2023-07-28 14:56:42.031636",
"modified": "2023-10-17 18:18:26.475259",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order Item",
@@ -884,4 +891,4 @@
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
}