From 660f5ade3ebcd3f31379c704fee03a71ce55fbd2 Mon Sep 17 00:00:00 2001 From: iphenelist Date: Tue, 23 Dec 2025 09:56:02 +0300 Subject: [PATCH] feat: Add Sales Order item duplication check setting and validation to prevent duplicate items in sales invoices --- propms/auto_custom.py | 17 +++--- .../property_management_settings.json | 53 ++++++++++++++++++- 2 files changed, 60 insertions(+), 10 deletions(-) diff --git a/propms/auto_custom.py b/propms/auto_custom.py index 780886d..df48fef 100755 --- a/propms/auto_custom.py +++ b/propms/auto_custom.py @@ -212,15 +212,16 @@ def getIssueName(name): @frappe.whitelist() def validateSalesInvoiceItemDuplication(self, method): - for item in self.items: - for item_child in self.items: - if not item.name == item_child.name: - if item.item_code == item_child.item_code: - frappe.throw( - _("Duplicate Item Exists - {0}. Duplications are not allowed.").format( - item.item_code + if frappe.db.get_single_value("Property Management Settings", "so_item_duplication_check"): + for item in self.items: + for item_child in self.items: + if not item.name == item_child.name: + if item.item_code == item_child.item_code: + frappe.throw( + _("Duplicate Item Exists - {0}. Duplications are not allowed.").format( + item.item_code + ) ) - ) @frappe.whitelist() diff --git a/propms/property_management_solution/doctype/property_management_settings/property_management_settings.json b/propms/property_management_solution/doctype/property_management_settings/property_management_settings.json index a0024b5..5814688 100755 --- a/propms/property_management_solution/doctype/property_management_settings/property_management_settings.json +++ b/propms/property_management_solution/doctype/property_management_settings/property_management_settings.json @@ -27,7 +27,14 @@ "allow_end_of_the_month", "section_break_17", "self_consumption_customer", - "generate_invoice_schedule_next_month" + "generate_invoice_schedule_next_month", + "column_break_fwvp", + "so_item_duplication_check", + "section_break_provider_prioritization", + "enable_provider_auto_assignment", + "enable_nearby_search", + "column_break_provider", + "nearby_search_radius_km" ], "fields": [ { @@ -148,12 +155,54 @@ "fieldname": "make_invoice_schedule_up_to_tomorrow_only", "fieldtype": "Check", "label": "Make Invoice Schedule up to tomorrow only" + }, + { + "fieldname": "section_break_provider_prioritization", + "fieldtype": "Section Break", + "label": "Provider Prioritization Settings" + }, + { + "default": "0", + "description": "Automatically assign service providers to Issues based on prioritization rules", + "fieldname": "enable_provider_auto_assignment", + "fieldtype": "Check", + "label": "Enable Provider Auto-Assignment" + }, + { + "default": "0", + "depends_on": "enable_provider_auto_assignment", + "description": "Enable geolocation-based fallback search for nearby providers", + "fieldname": "enable_nearby_search", + "fieldtype": "Check", + "label": "Enable Nearby Search" + }, + { + "fieldname": "column_break_provider", + "fieldtype": "Column Break" + }, + { + "default": "10", + "depends_on": "enable_nearby_search", + "description": "Search radius in kilometers for nearby provider search", + "fieldname": "nearby_search_radius_km", + "fieldtype": "Float", + "label": "Nearby Search Radius (km)" + }, + { + "fieldname": "column_break_fwvp", + "fieldtype": "Column Break" + }, + { + "default": "0", + "fieldname": "so_item_duplication_check", + "fieldtype": "Check", + "label": "SO Item duplication check" } ], "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2025-06-26 16:00:42.304877", + "modified": "2025-12-23 07:04:05.371373", "modified_by": "Administrator", "module": "Property Management Solution", "name": "Property Management Settings",