Skip to content

Commit

Permalink
fix: inv dimensions fields not creating for standard doctype (backport
Browse files Browse the repository at this point in the history
…#44504) (#44515)

fix: inv dimensions fields not creating for standard doctype (#44504)

(cherry picked from commit 353610c)

Co-authored-by: rohitwaghchaure <[email protected]>
  • Loading branch information
mergify[bot] and rohitwaghchaure authored Dec 5, 2024
1 parent 07df87a commit 8733eda
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions erpnext/stock/doctype/inventory_dimension/inventory_dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,10 @@ def add_custom_fields(self):
dimension_fields = []
if self.apply_to_all_doctypes:
for doctype in get_inventory_documents():
if field_exists(doctype[0], self.source_fieldname):
continue

dimension_fields = self.get_dimension_fields(doctype[0])
self.add_transfer_field(doctype[0], dimension_fields)
custom_fields.setdefault(doctype[0], dimension_fields)
elif not field_exists(self.document_type, self.source_fieldname):
else:
dimension_fields = self.get_dimension_fields()

self.add_transfer_field(self.document_type, dimension_fields)
Expand All @@ -239,8 +236,17 @@ def add_custom_fields(self):
dimension_field["fieldname"] = self.target_fieldname
custom_fields["Stock Ledger Entry"] = dimension_field

filter_custom_fields = {}
if custom_fields:
create_custom_fields(custom_fields)
for doctype, fields in custom_fields.items():
if isinstance(fields, dict):
fields = [fields]

for field in fields:
if not field_exists(doctype, field["fieldname"]):
filter_custom_fields.setdefault(doctype, []).append(field)

create_custom_fields(filter_custom_fields)

def add_transfer_field(self, doctype, dimension_fields):
if doctype not in [
Expand Down

0 comments on commit 8733eda

Please sign in to comment.