diff --git a/crm/fcrm/doctype/crm_product/__init__.py b/crm/fcrm/doctype/crm_product/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/crm/fcrm/doctype/crm_product/crm_product.js b/crm/fcrm/doctype/crm_product/crm_product.js new file mode 100644 index 00000000..66925f81 --- /dev/null +++ b/crm/fcrm/doctype/crm_product/crm_product.js @@ -0,0 +1,9 @@ +// Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on("CRM Product", { + product_code: function (frm) { + if (!frm.doc.product_name) + frm.set_value("product_name", frm.doc.product_code); + } +}); diff --git a/crm/fcrm/doctype/crm_product/crm_product.json b/crm/fcrm/doctype/crm_product/crm_product.json new file mode 100644 index 00000000..18ed3466 --- /dev/null +++ b/crm/fcrm/doctype/crm_product/crm_product.json @@ -0,0 +1,105 @@ +{ + "actions": [], + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:product_code", + "creation": "2025-04-28 11:45:09.309636", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "naming_series", + "product_code", + "product_name", + "column_break_bpdj", + "disabled", + "standard_rate", + "image", + "section_break_rtwm", + "description" + ], + "fields": [ + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Naming Series", + "options": "CRM-PROD-.YYYY.-" + }, + { + "fieldname": "product_code", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Product Code", + "reqd": 1, + "unique": 1 + }, + { + "fieldname": "product_name", + "fieldtype": "Data", + "label": "Product Name" + }, + { + "fieldname": "column_break_bpdj", + "fieldtype": "Column Break" + }, + { + "default": "0", + "fieldname": "disabled", + "fieldtype": "Check", + "label": "Disabled" + }, + { + "fieldname": "image", + "fieldtype": "Attach Image", + "label": "Image" + }, + { + "fieldname": "section_break_rtwm", + "fieldtype": "Section Break" + }, + { + "fieldname": "description", + "fieldtype": "Text Editor", + "label": "Description" + }, + { + "fieldname": "standard_rate", + "fieldtype": "Currency", + "label": "Standard Selling Rate" + } + ], + "grid_page_length": 50, + "image_field": "image", + "index_web_pages_for_search": 1, + "links": [], + "make_attachments_public": 1, + "modified": "2025-04-28 12:47:25.087957", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Product", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "quick_entry": 1, + "row_format": "Dynamic", + "search_fields": "product_name,description", + "show_name_in_global_search": 1, + "show_preview_popup": 1, + "sort_field": "creation", + "sort_order": "DESC", + "states": [], + "title_field": "product_name", + "track_changes": 1 +} diff --git a/crm/fcrm/doctype/crm_product/crm_product.py b/crm/fcrm/doctype/crm_product/crm_product.py new file mode 100644 index 00000000..a04845e1 --- /dev/null +++ b/crm/fcrm/doctype/crm_product/crm_product.py @@ -0,0 +1,16 @@ +# Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +import frappe +from frappe.model.document import Document + + +class CRMProduct(Document): + def validate(self): + self.set_product_name() + + def set_product_name(self): + if not self.product_name: + self.product_name = self.product_code + else: + self.product_name = self.product_name.strip() diff --git a/crm/fcrm/doctype/crm_product/test_crm_product.py b/crm/fcrm/doctype/crm_product/test_crm_product.py new file mode 100644 index 00000000..c6c8b1fb --- /dev/null +++ b/crm/fcrm/doctype/crm_product/test_crm_product.py @@ -0,0 +1,29 @@ +# Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt + +# import frappe +from frappe.tests import IntegrationTestCase, UnitTestCase + +# On IntegrationTestCase, the doctype test records and all +# link-field test record dependencies are recursively loaded +# Use these module variables to add/remove to/from that list +EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] +IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] + + +class UnitTestCRMProduct(UnitTestCase): + """ + Unit tests for CRMProduct. + Use this class for testing individual functions and methods. + """ + + pass + + +class IntegrationTestCRMProduct(IntegrationTestCase): + """ + Integration tests for CRMProduct. + Use this class for testing interactions between multiple components. + """ + + pass