From f62efeae0afe1358c26391c3bccd5415eb7965d4 Mon Sep 17 00:00:00 2001 From: Jatin3128 <140256508+Jatin3128@users.noreply.github.com> Date: Thu, 23 Jul 2026 12:30:23 +0530 Subject: [PATCH] feat: make Shipping Rule Cost Center optional with company default fallback (#57355) feat(shipping-rule): make cost center optional with company default fallback Cost Center on Shipping Rule is no longer mandatory. When left blank, the applied shipping tax row falls back to the company default cost center, avoiding the 'Cost Center is required for Profit and Loss account' error on submit. The rule's project is also applied to the tax row. (cherry picked from commit a47f25896b095aea90308801a8fa91f77fc0c759) # Conflicts: # erpnext/accounts/doctype/shipping_rule/shipping_rule.json --- .../doctype/shipping_rule/shipping_rule.json | 27 ++++++++++++++----- .../doctype/shipping_rule/shipping_rule.py | 7 +++-- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/doctype/shipping_rule/shipping_rule.json b/erpnext/accounts/doctype/shipping_rule/shipping_rule.json index 8277c92d829..d42954c9d71 100644 --- a/erpnext/accounts/doctype/shipping_rule/shipping_rule.json +++ b/erpnext/accounts/doctype/shipping_rule/shipping_rule.json @@ -80,8 +80,7 @@ "fieldname": "cost_center", "fieldtype": "Link", "label": "Cost Center", - "options": "Cost Center", - "reqd": 1 + "options": "Cost Center" }, { "fieldname": "shipping_amount_section", @@ -139,18 +138,24 @@ "fieldtype": "Column Break" }, { - "fieldname": "project", - "fieldtype": "Link", - "label": "Project", - "options": "Project" + "fieldname": "project", + "fieldtype": "Link", + "label": "Project", + "options": "Project" } ], "icon": "fa fa-truck", "idx": 1, +<<<<<<< HEAD "modified": "2019-05-25 23:12:26.156405", +======= + "links": [], + "modified": "2026-07-22 14:53:27.315435", +>>>>>>> a47f25896b (feat: make Shipping Rule Cost Center optional with company default fallback (#57355)) "modified_by": "Administrator", "module": "Accounts", "name": "Shipping Rule", + "naming_rule": "By fieldname", "owner": "Administrator", "permissions": [ { @@ -196,5 +201,13 @@ "write": 1 } ], +<<<<<<< HEAD "sort_order": "ASC" -} \ No newline at end of file +} +======= + "row_format": "Dynamic", + "sort_field": "creation", + "sort_order": "ASC", + "states": [] +} +>>>>>>> a47f25896b (feat: make Shipping Rule Cost Center optional with company default fallback (#57355)) diff --git a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py index a2db95d03c9..e636367bc68 100644 --- a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py +++ b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py @@ -36,18 +36,17 @@ class ShippingRule(Document): from erpnext.accounts.doctype.shipping_rule_condition.shipping_rule_condition import ( ShippingRuleCondition, ) - from erpnext.accounts.doctype.shipping_rule_country.shipping_rule_country import ( - ShippingRuleCountry, - ) + from erpnext.accounts.doctype.shipping_rule_country.shipping_rule_country import ShippingRuleCountry account: DF.Link calculate_based_on: DF.Literal["Fixed", "Net Total", "Net Weight"] company: DF.Link conditions: DF.Table[ShippingRuleCondition] - cost_center: DF.Link + cost_center: DF.Link | None countries: DF.Table[ShippingRuleCountry] disabled: DF.Check label: DF.Data + project: DF.Link | None shipping_amount: DF.Currency shipping_rule_type: DF.Literal["Selling", "Buying"] # end: auto-generated types