Skip to content
Open
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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ repos:
files: '\.md$'

- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
rev: v2.34.0
hooks:
- id: pyupgrade
args: ['--py310-plus']
args: ['--py38-plus']

- repo: https://github.com/agritheory/black
- repo: https://github.com/frappe/black
rev: 951ccf4d5bb0d692b457a5ebc4215d755618eb68
hooks:
- id: black
Expand All @@ -53,7 +53,7 @@ repos:
additional_dependencies: ['flake8-bugbear']

- repo: https://github.com/agritheory/test_utils
rev: v1.20.2
rev: v1.28.0
hooks:
- id: update_pre_commit_config
- id: validate_frappe_project
Expand Down
41 changes: 41 additions & 0 deletions beam/beam/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
def boot_session(bootinfo):
bootinfo.beam = get_scan_doctypes()
bootinfo.beam["settings"] = get_beam_settings()
bootinfo.beam["mass_uoms"] = get_mass_uoms()
bootinfo.beam["scale_configs"] = get_scale_configs()
bootinfo.beam["default_hu_print_format"] = frappe.get_meta("Handling Unit").get(
"default_print_format"
)
Expand All @@ -26,3 +28,42 @@ def get_beam_settings():
"enable_handling_units": setting.enable_handling_units,
}
return settings


def get_mass_uoms():
"""Get all UOMs that have a UOM Conversion Factor record with category='Mass'."""
return frappe.get_all(
"UOM Conversion Factor",
filters={"category": "Mass"},
pluck="from_uom",
distinct=True,
)


def get_scale_configs():
"""Return scale_doctype_configs keyed by doctype_name."""
configs = {}
beam_settings_list = frappe.get_all(
"BEAM Settings",
fields=["name"],
)
for setting in beam_settings_list:
scale_configs = frappe.get_all(
"BEAM Scale Doctype Config",
filters={"parent": setting.name},
fields=[
"doctype_name",
"qty_field",
"items_table_field",
"zero_threshold",
"autoadvance_on_zero",
],
)
for config in scale_configs:
configs[config.doctype_name] = {
"qty_field": config.qty_field,
"items_table_field": config.items_table_field,
"zero_threshold": config.zero_threshold,
"autoadvance_on_zero": config.autoadvance_on_zero,
}
return configs
2 changes: 2 additions & 0 deletions beam/beam/doctype/beam_scale_doctype_config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) 2026, AgriTheory and contributors
# For license information, please see license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"actions": [],
"creation": "2026-06-17 16:07:30.123456",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"doctype_name",
"qty_field",
"items_table_field",
"zero_threshold",
"autoadvance_on_zero"
],
"fields": [
{
"fieldname": "doctype_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Doctype Name",
"reqd": 1
},
{
"fieldname": "qty_field",
"fieldtype": "Data",
"label": "Qty Field",
"default": "qty"
},
{
"fieldname": "items_table_field",
"fieldtype": "Data",
"label": "Items Table Field",
"default": "items"
},
{
"fieldname": "zero_threshold",
"fieldtype": "Float",
"label": "Zero Threshold (oz)",
"default": "0.1"
},
{
"fieldname": "autoadvance_on_zero",
"fieldtype": "Check",
"label": "Auto Advance on Zero",
"default": "1"
}
],
"istable": 1,
"links": [],
"modified": "2026-06-17 16:07:30.123456",
"modified_by": "Administrator",
"module": "BEAM",
"name": "BEAM Scale Doctype Config",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2026, AgriTheory and contributors
# For license information, please see license.txt

from frappe.model.document import Document


class BEAMScaleDoctypeConfig(Document):
pass
15 changes: 14 additions & 1 deletion beam/beam/doctype/beam_settings/beam_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"barcode_generation_section",
"barcode_exclusions_html",
"column_break_barcode",
"auto_barcode_doctypes"
"auto_barcode_doctypes",
"scale_tab",
"scale_doctype_configs"
],
"fields": [
{
Expand Down Expand Up @@ -89,6 +91,17 @@
"fieldtype": "JSON",
"hidden": 1,
"label": "Auto Barcode Doctypes"
},
{
"fieldname": "scale_tab",
"fieldtype": "Tab Break",
"label": "Scale"
},
{
"fieldname": "scale_doctype_configs",
"fieldtype": "Table",
"label": "Scale Doctype Configs",
"options": "BEAM Scale Doctype Config"
}
],
"links": [],
Expand Down
7 changes: 7 additions & 0 deletions beam/docs/scale.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- Copyright (c) 2025, AgriTheory and contributors
For license information, please see license.txt-->

# Using the scale features

The WebHID protocol is not supported in all browsers, [look here for compatibility](https://developer.mozilla.org/en-US/docs/Web/API/WebHID_API#browser_compatibility)

1 change: 1 addition & 0 deletions beam/public/js/beam.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
import './scan/scan.js'
import './print/print.js'
// import './example_custom_callback.js'
import './scale/scale.js'
Loading
Loading