Skip to content

feat inv dim propagation#340

Open
robproject wants to merge 6 commits into
version-15from
feat_inv_dim_propagation
Open

feat inv dim propagation#340
robproject wants to merge 6 commits into
version-15from
feat_inv_dim_propagation

Conversation

@robproject

@robproject robproject commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

Description

  • Add inventory dimensions to get_handling_unit method, using cached list of dimensions, for update of all target child table documents.
  • Refactor Handling Unit inventory dimension creation into method to be shared by any app for Inventory Dimension creation.
  • Add custom_carry_forward field to Inventory Dimension DocType for use in propagate_inventory_dimensions.
  • Add propagate_inventory_dimensions method as before_submit hook on Stock Entry to enable below behavior. BEAM's handling_unit.py is updated to not overwrite target_handling_unit if it has a value set already, unless the HU qty and transfer qty don't match.
custom_carry_forward Transfer qty to_handling_unit result
On qty == stock (full) Same HU (conserved)
On qty != stock (split) New HU (BEAM overrides)
Off any New HU (BEAM default)
  • Update tests.
  • Syntax changes in scan/init.py for v16: pass frappe._dict(), use SUM dict in frappe.get_all()
  • Similar to 135 preserve complete hu #137 but applies to any configured Inventory Dimension and accounts for qty splitting.

@github-actions

Copy link
Copy Markdown

📝 Draft Changelog Entry

Changelog

This update adds inventory dimension propagation functionality to Stock Entry documents. When a Stock Entry is submitted, inventory dimensions are now automatically carried forward to handling units based on configuration settings.

A new custom_carry_forward field has been added to the Inventory Dimension DocType. When this field is enabled, handling units are preserved during full quantity transfers. For partial quantity transfers, new handling units are created as before. When the field is disabled, the default behavior of creating new handling units applies to all transfers.

The handling unit creation process has been refactored into a shared method that can be utilized across applications for inventory dimension creation. The get_handling_unit method now includes inventory dimensions using a cached list to ensure all target child table documents are updated consistently.

Technical updates include syntax changes in the scan module for compatibility with Frappe v16, including the use of frappe._dict() and SUM dictionary operations in frappe.get_all() calls.

This changelog entry was automatically generated by the Changelog Generator Action.

@github-actions

github-actions Bot commented Apr 17, 2026

Copy link
Copy Markdown

@robproject robproject linked an issue Apr 18, 2026 that may be closed by this pull request
@agritheory

Copy link
Copy Markdown
Owner

@robproject This is a nice feature!

@agritheory
agritheory requested review from agritheory and lauty95 and removed request for lauty95 July 21, 2026 12:45
@robproject

robproject commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

I have two other versions of BEAM that are customized a little differently. Need to try combining them all for this. It started with only this PR but each system diverged.

@github-actions

Copy link
Copy Markdown

Draft Changelog Entry

Changelog Entry

This update adds inventory dimension propagation functionality to stock entries. When submitting a stock entry, inventory dimensions are now automatically carried forward to child table documents based on configuration settings.

A new custom_carry_forward field has been added to the Inventory Dimension DocType. When enabled, this field preserves the original handling unit during full quantity transfers. For partial quantity transfers (splits), a new handling unit is created instead. When the setting is disabled, the default behavior of creating a new handling unit applies to all transfers.

The handling unit creation process has been refactored into a shared method that can be utilized by any application for inventory dimension creation. The system now uses a cached list of inventory dimensions to retrieve and apply them to all target child table documents during stock entry processing.

Technical compatibility updates have been made to support Frappe v16, including syntax adjustments in the scanning module.

This changelog entry was automatically generated by the Changelog Generator Action.

Robert Duncan added 2 commits July 23, 2026 23:24
…an aggregate

Three related fixes so BEAM submits cleanly on ERPNext v16 while staying
v15-compatible:

- Scrap-item field rename: v16 removed `is_scrap_item` from Stock Entry Detail
  (scrap outputs are now `type == "Scrap"`, with the old flag preserved as
  `is_legacy_scrap_item`). Add an `is_scrap_item(row)` helper and route all
  handling_unit / stock_entry references through it, fixing the AttributeError
  on Stock Entry submit.

- Inventory-dimension carry-forward: write the carried value to
  `to_<source_fieldname>` — the field ERPNext's stock controller reads for the
  incoming leg of a transfer — instead of `target_fieldname`, which names the
  SLE column and defaults to the source field (making the old write a no-op).
  Drop the unused manufacture carry-forward field selection.

- Scan aggregate: select the stock_qty sum via the dict form on v16 (which
  rejects string-form SQL functions in SELECT) and the string form on v15
  (which has no dict-function support), chosen by Frappe major version.

Tests: route the test suite's scrap-item checks through the helper, and drop
the `target_fieldname` override hack now that carry-forward writes to the
correct field — aligning these tests with the sibling carry-forward tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve handling unit PK when it is moved in its entirety

2 participants