Merge pull request #37555 from frappe/mergify/bp/version-14-hotfix/pr-37550

chore: Add accounting dimensions to Sales Order Item table (backport #37550)
This commit is contained in:
Deepesh Garg
2023-10-18 17:09:14 +05:30
committed by GitHub
5 changed files with 45 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 default_dimensions_map[dimension.company][dimension.fieldname] = dimension.default_dimension
return dimension_filters, default_dimensions_map 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", "Sales Invoice Item",
"Purchase Invoice Item", "Purchase Invoice Item",
"Purchase Order Item", "Purchase Order Item",
"Sales Order Item",
"Journal Entry Account", "Journal Entry Account",
"Material Request Item", "Material Request Item",
"Delivery Note Item", "Delivery Note Item",

View File

@@ -341,5 +341,6 @@ execute:frappe.defaults.clear_default("fiscal_year")
execute:frappe.db.set_single_value('Selling Settings', 'allow_negative_rates_for_items', 0) 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.correct_asset_value_if_je_with_workflow
erpnext.patches.v14_0.migrate_deferred_accounts_to_item_defaults erpnext.patches.v14_0.migrate_deferred_accounts_to_item_defaults
erpnext.patches.v14_0.create_accounting_dimensions_in_sales_order_item
# below migration patch should always run last # below migration patch should always run last
erpnext.patches.v14_0.migrate_gl_to_payment_ledger 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", "total_weight",
"column_break_21", "column_break_21",
"weight_uom", "weight_uom",
"accounting_dimensions_section",
"warehouse_and_reference", "warehouse_and_reference",
"warehouse", "warehouse",
"target_warehouse", "target_warehouse",
@@ -868,12 +869,18 @@
"label": "Production Plan Qty", "label": "Production Plan Qty",
"no_copy": 1, "no_copy": 1,
"read_only": 1 "read_only": 1
},
{
"collapsible": 1,
"fieldname": "accounting_dimensions_section",
"fieldtype": "Section Break",
"label": "Accounting Dimensions"
} }
], ],
"idx": 1, "idx": 1,
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2023-07-28 14:56:42.031636", "modified": "2023-10-17 18:18:26.475259",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Sales Order Item", "name": "Sales Order Item",
@@ -884,4 +891,4 @@
"sort_order": "DESC", "sort_order": "DESC",
"states": [], "states": [],
"track_changes": 1 "track_changes": 1
} }