Merge pull request #37550 from deepeshgarg007/sales_order_item_dimensions

chore: Add accounting dimensions to Sales Order Item table
This commit is contained in:
Deepesh Garg 2023-10-17 22:54:04 +05:30 committed by GitHub
commit 14760d9aea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 2 deletions

View File

@ -302,3 +302,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

@ -508,6 +508,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

@ -339,5 +339,6 @@ erpnext.patches.v14_0.migrate_deferred_accounts_to_item_defaults
erpnext.patches.v14_0.update_invoicing_period_in_subscription erpnext.patches.v14_0.update_invoicing_period_in_subscription
execute:frappe.delete_doc("Page", "welcome-to-erpnext") execute:frappe.delete_doc("Page", "welcome-to-erpnext")
erpnext.patches.v15_0.delete_payment_gateway_doctypes erpnext.patches.v15_0.delete_payment_gateway_doctypes
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

@ -68,6 +68,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",
@ -889,12 +890,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",
@ -905,4 +912,4 @@
"sort_order": "DESC", "sort_order": "DESC",
"states": [], "states": [],
"track_changes": 1 "track_changes": 1
} }