diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index de282cf5..73e8c017 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,7 +55,7 @@ repos: - tomli - repo: https://github.com/agritheory/test_utils - rev: v1.0.0 + rev: v1.7.1 hooks: - id: update_pre_commit_config - id: validate_copyright diff --git a/beam/beam/custom/bom_scrap_item.json b/beam/beam/custom/bom_scrap_item.json index 95230daf..4037dd3e 100644 --- a/beam/beam/custom/bom_scrap_item.json +++ b/beam/beam/custom/bom_scrap_item.json @@ -6,9 +6,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "creation": "2023-08-22 15:23:16.272692", "default": null, - "docstatus": 0, "dt": "BOM Scrap Item", "fetch_if_empty": 0, "fieldname": "create_handling_unit", @@ -29,15 +27,11 @@ "is_virtual": 0, "label": "Create Handling Unit", "length": 0, - "modified": "2023-08-22 15:23:52.267428", - "modified_by": "Administrator", "module": "BEAM", "name": "BOM Scrap Item-create_handling_unit", "no_copy": 0, "non_negative": 0, - "owner": "Administrator", "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -49,9 +43,7 @@ "unique": 0 } ], - "custom_perms": [], "doctype": "BOM Scrap Item", - "links": [], "property_setters": [], "sync_on_migrate": 1 } diff --git a/beam/beam/custom/item.json b/beam/beam/custom/item.json index ee256d60..03099d33 100644 --- a/beam/beam/custom/item.json +++ b/beam/beam/custom/item.json @@ -6,9 +6,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "creation": "2024-02-26 23:52:53.051024", "default": "1", - "docstatus": 0, "dt": "Item", "fetch_if_empty": 0, "fieldname": "enable_handling_unit", @@ -29,15 +27,11 @@ "is_virtual": 0, "label": "Enable Handling Unit", "length": 0, - "modified": "2024-02-26 23:52:53.051024", - "modified_by": "Administrator", "module": "BEAM", "name": "Item-enable_handling_unit", "no_copy": 0, "non_negative": 0, - "owner": "Administrator", "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -49,9 +43,7 @@ "unique": 0 } ], - "custom_perms": [], "doctype": "Item", - "links": [], "property_setters": [], "sync_on_migrate": 1 } diff --git a/beam/beam/custom/item_barcode.json b/beam/beam/custom/item_barcode.json index 2e6bb577..55b70641 100644 --- a/beam/beam/custom/item_barcode.json +++ b/beam/beam/custom/item_barcode.json @@ -1,20 +1,14 @@ { "custom_fields": [], - "custom_perms": [], "doctype": "Item Barcode", "property_setters": [ { - "creation": "2022-06-16 09:40:22.875922", "doc_type": "Item Barcode", - "docstatus": 0, "doctype_or_field": "DocField", "field_name": "barcode_type", "idx": 0, - "modified": "2022-06-16 09:40:22.875922", - "modified_by": "Administrator", "module": "BEAM", "name": "Item Barcode-barcode_type-options", - "owner": "Administrator", "property": "options", "property_type": "Text", "value": "\nEAN\nUPC-A\nCode128" diff --git a/beam/beam/custom/stock_entry_detail.json b/beam/beam/custom/stock_entry_detail.json index 6fc6385b..1728d497 100644 --- a/beam/beam/custom/stock_entry_detail.json +++ b/beam/beam/custom/stock_entry_detail.json @@ -6,10 +6,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "creation": "2023-09-13 12:51:04.950175", "default": null, - "depends_on": "", - "docstatus": 0, "dt": "Stock Entry Detail", "fetch_if_empty": 0, "fieldname": "recombine_on_cancel", @@ -30,15 +27,11 @@ "is_virtual": 0, "label": "Recombine On Cancel", "length": 0, - "modified": "2023-09-13 12:51:04.950175", - "modified_by": "Administrator", "module": "BEAM", "name": "Stock Entry Detail-recombine_on_cancel", "no_copy": 1, "non_negative": 0, - "owner": "Administrator", "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 1, @@ -50,9 +43,7 @@ "unique": 0 } ], - "custom_perms": [], "doctype": "Stock Entry Detail", - "links": [], "property_setters": [], "sync_on_migrate": 1 } diff --git a/beam/beam/custom/user.json b/beam/beam/custom/user.json index e1d92164..9075ecb1 100644 --- a/beam/beam/custom/user.json +++ b/beam/beam/custom/user.json @@ -6,9 +6,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "creation": "2022-06-16 09:48:36.521275", "default": null, - "docstatus": 0, "dt": "User", "fetch_if_empty": 0, "fieldname": "barcode_section", @@ -27,15 +25,11 @@ "insert_after": "mobile_no", "label": "Barcodes", "length": 0, - "modified": "2022-06-16 09:48:36.521275", - "modified_by": "Administrator", "module": "BEAM", "name": "User-barcode_section", "no_copy": 0, "non_negative": 0, - "owner": "Administrator", "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -51,9 +45,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "creation": "2022-06-16 09:48:36.701251", "default": null, - "docstatus": 0, "dt": "User", "fetch_if_empty": 0, "fieldname": "barcodes", @@ -70,18 +62,13 @@ "in_preview": 0, "in_standard_filter": 0, "insert_after": "barcode_section", - "label": "", "length": 0, - "modified": "2022-06-16 09:48:36.701251", - "modified_by": "Administrator", "module": "BEAM", "name": "User-barcodes", "no_copy": 0, "non_negative": 0, "options": "Item Barcode", - "owner": "Administrator", "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -92,7 +79,6 @@ "unique": 0 } ], - "custom_perms": [], "doctype": "User", "property_setters": [], "sync_on_migrate": 1 diff --git a/beam/beam/custom/warehouse.json b/beam/beam/custom/warehouse.json index 8861a08d..79dafeae 100644 --- a/beam/beam/custom/warehouse.json +++ b/beam/beam/custom/warehouse.json @@ -6,9 +6,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "creation": "2022-06-16 09:48:36.521275", "default": null, - "docstatus": 0, "dt": "Warehouse", "fetch_if_empty": 0, "fieldname": "barcode_section", @@ -27,15 +25,11 @@ "insert_after": "pin", "label": "Barcodes", "length": 0, - "modified": "2022-06-16 09:48:36.521275", - "modified_by": "Administrator", "module": "BEAM", "name": "Warehouse-barcode_section", "no_copy": 0, "non_negative": 0, - "owner": "Administrator", "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -51,9 +45,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "creation": "2022-06-16 09:48:36.701251", "default": null, - "docstatus": 0, "dt": "Warehouse", "fetch_if_empty": 0, "fieldname": "barcodes", @@ -70,18 +62,13 @@ "in_preview": 0, "in_standard_filter": 0, "insert_after": "barcode_section", - "label": "", "length": 0, - "modified": "2022-06-16 09:48:36.701251", - "modified_by": "Administrator", "module": "BEAM", "name": "Warehouse-barcodes", "no_copy": 0, "non_negative": 0, "options": "Item Barcode", - "owner": "Administrator", "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -92,7 +79,6 @@ "unique": 0 } ], - "custom_perms": [], "doctype": "Warehouse", "property_setters": [], "sync_on_migrate": 1 diff --git a/beam/beam/overrides/company.py b/beam/beam/overrides/company.py new file mode 100644 index 00000000..86fbbb04 --- /dev/null +++ b/beam/beam/overrides/company.py @@ -0,0 +1,11 @@ +# Copyright (c) 2026, AgriTheory and contributors +# For license information, please see license.txt + +import frappe + +from beam.beam.doctype.beam_settings.beam_settings import create_beam_settings + + +def create_company_beam_settings(doc, method=None): + if not frappe.db.exists("BEAM Settings", {"company": doc.name}): + create_beam_settings(doc.name) diff --git a/beam/customize.py b/beam/customize.py index 45b0a066..06bbc6c3 100644 --- a/beam/customize.py +++ b/beam/customize.py @@ -21,7 +21,8 @@ def load_customizations(): if existing_field else frappe.new_doc("Custom Field") ) - field.pop("modified") + if "modified" in field: + field.pop("modified") {custom_field.set(key, value) for key, value in field.items()} custom_field.flags.ignore_permissions = True custom_field.flags.ignore_version = True diff --git a/beam/hooks.py b/beam/hooks.py index 82cfb93a..7ed4cb2c 100644 --- a/beam/hooks.py +++ b/beam/hooks.py @@ -172,6 +172,9 @@ "beam.beam.demand.demand.modify_allocations", ], }, + "Company": { + "after_insert": "beam.beam.overrides.company.create_company_beam_settings", + }, } # Types diff --git a/beam/tests/setup.py b/beam/tests/setup.py index a437efd0..a6e87b94 100644 --- a/beam/tests/setup.py +++ b/beam/tests/setup.py @@ -30,26 +30,27 @@ def before_test(): frappe.clear_cache() - today = frappe.utils.getdate() - setup_complete( - { - "currency": "USD", - "full_name": "Administrator", - "company_name": "Ambrosia Pie Company", - "timezone": "America/New_York", - "company_abbr": "APC", - "domains": ["Distribution"], - "country": "United States", - "fy_start_date": today.replace(month=1, day=1).isoformat(), - "fy_end_date": today.replace(month=12, day=31).isoformat(), - "language": "english", - "company_tagline": "Ambrosia Pie Company", - "email": "support@agritheory.dev", - "password": "admin", - "chart_of_accounts": "Standard with Numbers", - "bank_account": "Primary Checking", - } - ) + if not frappe.db.exists("Company", "Ambrosia Pie Company"): + today = frappe.utils.getdate() + setup_complete( + { + "currency": "USD", + "full_name": "Administrator", + "company_name": "Ambrosia Pie Company", + "timezone": "America/New_York", + "company_abbr": "APC", + "domains": ["Distribution"], + "country": "United States", + "fy_start_date": today.replace(month=1, day=1).isoformat(), + "fy_end_date": today.replace(month=12, day=31).isoformat(), + "language": "english", + "company_tagline": "Ambrosia Pie Company", + "email": "support@agritheory.dev", + "password": "admin", + "chart_of_accounts": "Standard with Numbers", + "bank_account": "Primary Checking", + } + ) enable_all_roles_and_domains() set_defaults_for_tests() frappe.db.commit() @@ -76,16 +77,23 @@ def create_test_data(): ), } ) - company_address = frappe.new_doc("Address") - company_address.title = settings.company - company_address.address_type = "Office" - company_address.address_line1 = "67C Sweeny Street" - company_address.city = "Chelsea" - company_address.state = "MA" - company_address.pincode = "89077" - company_address.is_your_company_address = True - company_address.append("links", {"link_doctype": "Company", "link_name": settings.company}) - company_address.save() + if not frappe.db.exists( + "Address", + { + "address_type": "Office", + "is_your_company_address": 1, + }, + ): + company_address = frappe.new_doc("Address") + company_address.title = settings.company + company_address.address_type = "Office" + company_address.address_line1 = "67C Sweeny Street" + company_address.city = "Chelsea" + company_address.state = "MA" + company_address.pincode = "89077" + company_address.is_your_company_address = True + company_address.append("links", {"link_doctype": "Company", "link_name": settings.company}) + company_address.save() frappe.set_value("Company", settings.company, "tax_id", "04-1871930") create_warehouses(settings) setup_manufacturing_settings(settings) @@ -117,6 +125,8 @@ def create_suppliers(settings): addresses = frappe._dict({}) for supplier in suppliers: + if frappe.db.exists("Supplier", supplier[0]): + continue biz = frappe.new_doc("Supplier") biz.supplier_name = supplier[0] biz.supplier_group = "Bakery" @@ -147,6 +157,8 @@ def create_suppliers(settings): def create_customers(settings): for customer_name in customers: + if frappe.db.exists("Customer", customer_name): + continue customer = frappe.new_doc("Customer") customer.customer_name = customer_name customer.customer_group = "Commercial" @@ -192,30 +204,33 @@ def setup_manufacturing_settings(settings): def setup_beam_settings(settings): - beams = frappe.new_doc("BEAM Settings") - beams.company = settings.company - beams.enable_demand = True - beams.enable_handling_units = True - beams.receiving_workstation = "Receiving" - beams.shipping_workstation = "Shipping" - beams.set("warehouse_types", [{"warehouse_type": "Quarantine"}]) - beams.set( - "routes", - [ - { - "label": "Manufacture", - "route": "#/manufacture", - "dt": "Stock Entry", - "component": "Manufacture", - }, - {"label": "Demand", "route": "#/demand", "dt": "Stock Entry", "component": "Demand"}, - {"label": "Move", "route": "#/move", "dt": "Stock Entry", "component": "Demand"}, - {"label": "Receive", "route": "#/receive", "dt": "Purchase Receipt", "component": "Receive"}, - {"label": "Ship", "route": "#/ship", "dt": "Delivery Note", "component": "Ship"}, - {"label": "Repack", "route": "#/repack", "dt": "Stock Entry", "component": "Repack"}, - ], - ) - beams.save() + if frappe.db.exists("BEAM Settings", settings.company): + beams = frappe.get_doc("BEAM Settings", settings.company) + else: + beams = frappe.new_doc("BEAM Settings") + beams.company = settings.company + beams.enable_demand = True + beams.enable_handling_units = True + beams.receiving_workstation = "Receiving" + beams.shipping_workstation = "Shipping" + beams.set("warehouse_types", [{"warehouse_type": "Quarantine"}]) + beams.set( + "routes", + [ + { + "label": "Manufacture", + "route": "#/manufacture", + "dt": "Stock Entry", + "component": "Manufacture", + }, + {"label": "Demand", "route": "#/demand", "dt": "Stock Entry", "component": "Demand"}, + {"label": "Move", "route": "#/move", "dt": "Stock Entry", "component": "Demand"}, + {"label": "Receive", "route": "#/receive", "dt": "Purchase Receipt", "component": "Receive"}, + {"label": "Ship", "route": "#/ship", "dt": "Delivery Note", "component": "Ship"}, + {"label": "Repack", "route": "#/repack", "dt": "Stock Entry", "component": "Repack"}, + ], + ) + beams.save() def create_workstations(): diff --git a/poetry.lock b/poetry.lock index c2d72381..09ac8da7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand. [[package]] name = "certifi" @@ -655,4 +655,4 @@ resolved_reference = "45ffc60638814df575d9fe11c7504b1a533e4ecb" [metadata] lock-version = "2.1" python-versions = ">=3.10,<3.14" -content-hash = "f125f1cb02654c1352139afe242a3336876573fdc1e9222a99eb04648802cc17" +content-hash = "943528828f8114492fa2ba8112b91b96557d0182e2507a3c8627db881cb22e8e" diff --git a/pyproject.toml b/pyproject.toml index 61fbe324..0b0b5de4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,13 @@ [project] name = "beam" +version = "15.5.0" +authors = [ + { name = "AgriTheory", email = "support@agritheory.dev" } +] description = "Barcode Scanning for ERPNext" -authors = [{name = "AgriTheory", email = "support@agritheory.dev"}] +requires-python = ">=3.10" readme = "README.md" -license = { file = "LICENSE" } -dynamic = [ "version", "dependencies", "requires-python" ] - -[tool.poetry] -version = "15.4.0" +dynamic = ["dependencies"] [tool.poetry.dependencies] python = ">=3.10,<3.14" @@ -69,7 +69,7 @@ exclude_also = [ ] [tool.semantic_release] -version_toml = ["pyproject.toml:tool.poetry.version"] +version_toml = ["pyproject.toml:project.version"] version_variable = [ "beam/__init__.py:__version__" ] diff --git a/setup.py b/setup.py index ddc3c973..e438b6c0 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,9 @@ -# Copyright (c) 2025, AgriTheory and contributors +# Copyright (c) 2024, AgriTheory and contributors # For license information, please see license.txt from setuptools import setup +# TODO: Remove this file when bench >=v5.11.0 is adopted / v15.0.0 is released name = "beam" setup()