feat: add site code doctype

This commit is contained in:
Rohan Bansal 2025-06-17 11:44:28 +05:30
parent 2089870770
commit 517561f1b2
6 changed files with 109 additions and 0 deletions

View file

@ -246,3 +246,5 @@ website_route_rules = [
{"from_route": "/supplier-portal/<path:app_path>", "to_route": "supplier-portal"},
{"from_route": "/erpnext", "to_route": "/app"},
]
export_python_type_annotations = True

View file

@ -0,0 +1,12 @@
// Copyright (c) 2025, jeowsome15@gmail.com and contributors
// For license information, please see license.txt
frappe.ui.form.on("Site Code", {
refresh(frm) {
if (!frm.doc.__islocal) {
frappe.contacts.render_address_and_contact(frm)
} else {
frappe.contacts.clear_address_and_contact(frm)
}
},
});

View file

@ -0,0 +1,62 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2025-06-17 01:51:35.709515",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"site_code",
"column_break_pwyn",
"address_html"
],
"fields": [
{
"fieldname": "site_code",
"fieldtype": "Data",
"in_global_search": 1,
"in_list_view": 1,
"in_preview": 1,
"in_standard_filter": 1,
"label": "Site Code",
"no_copy": 1,
"not_nullable": 1,
"reqd": 1,
"unique": 1
},
{
"fieldname": "column_break_pwyn",
"fieldtype": "Column Break"
},
{
"depends_on": "eval: !doc.__islocal",
"fieldname": "address_html",
"fieldtype": "HTML",
"label": "Address HTML",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2025-06-17 02:11:43.902766",
"modified_by": "Administrator",
"module": "Suppliers Portal",
"name": "Site Code",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "creation",
"sort_order": "DESC",
"states": []
}

View file

@ -0,0 +1,24 @@
# Copyright (c) 2025, jeowsome15@gmail.com and contributors
# For license information, please see license.txt
from frappe.model.document import Document
from frappe.contacts.address_and_contact import delete_contact_and_address, load_address_and_contact
class SiteCode(Document):
# begin: auto-generated types
# This code is auto-generated. Do not modify anything in this block.
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from frappe.types import DF
site_code: DF.Data
# end: auto-generated types
def onload(self):
load_address_and_contact(self)
def on_trash(self):
delete_contact_and_address("Site Code", self.name)

View file

@ -0,0 +1,9 @@
# Copyright (c) 2025, jeowsome15@gmail.com and Contributors
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
class TestSiteCode(FrappeTestCase):
pass