Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ repos:
additional_dependencies: ['flake8-bugbear']

- repo: https://github.com/agritheory/test_utils
rev: v1.20.1
rev: v1.20.2
hooks:
- id: update_pre_commit_config
- id: validate_frappe_project
Expand Down
32 changes: 30 additions & 2 deletions beam/beam/scan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ def get_barcode_context(barcode: str) -> frappe._dict | None:
"barcode": barcode,
}
)

# Fallback: custom barcode resolvers registered by other apps via beam_barcode_resolver hook
for resolver in frappe.get_hooks("beam_barcode_resolver"):
result = frappe.call(resolver, barcode=barcode)
if result:
return result

return None


Expand Down Expand Up @@ -212,6 +219,11 @@ def get_list_action(barcode_doc: frappe._dict, context: frappe._dict) -> list[di

def get_form_action(barcode_doc: frappe._dict, context: frappe._dict) -> list[dict[str, Any]]:
target = None
beam_override = frappe.get_hooks("beam_frm")
has_frm_override = bool(
beam_override and beam_override.get(barcode_doc.doc.doctype, {}).get(context.frm)
)

if barcode_doc.doc.doctype == "Handling Unit":
hu_details = get_handling_unit(barcode_doc.doc.name, context.frm)
if context.frm == "Stock Entry":
Expand All @@ -224,6 +236,15 @@ def get_form_action(barcode_doc: frappe._dict, context: frappe._dict) -> list[di
"item_code": hu_details.item_code,
}
)
elif has_frm_override:
# A beam_frm override handles this form - skip get_item_details() which would
# fail for forms without a standard "{doctype} Item" child table.
target = frappe._dict(
{
"doctype": context.frm,
"item_code": hu_details.item_code,
}
)
else:
target = get_item_details(
{
Expand Down Expand Up @@ -255,6 +276,15 @@ def get_form_action(barcode_doc: frappe._dict, context: frappe._dict) -> list[di
"item_code": barcode_doc.doc.name,
}
)
elif has_frm_override:
# A beam_frm override handles this form — skip get_item_details() which would
# fail for forms without a standard "{doctype} Item" child table.
target = frappe._dict(
{
"doctype": context.frm,
"item_code": barcode_doc.doc.name,
}
)
else:
target = get_item_details(
{
Expand Down Expand Up @@ -313,8 +343,6 @@ def get_form_action(barcode_doc: frappe._dict, context: frappe._dict) -> list[di
if not target:
return []

beam_override = frappe.get_hooks("beam_frm")

if beam_override:
override_doctype = beam_override.get(barcode_doc.doc.doctype)
if override_doctype:
Expand Down
Loading