Service Appointment Doctype Created

This commit is contained in:
Landry 2024-06-03 22:29:46 +00:00
parent 77cb64ce34
commit 2bb22f5e72
5 changed files with 147 additions and 0 deletions

View File

@ -0,0 +1,8 @@
// Copyright (c) 2024, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
// frappe.ui.form.on("Service Appointment", {
// refresh(frm) {
// },
// });

View File

@ -0,0 +1,72 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2024-06-03 01:56:46.671951",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"section_break_toee",
"contact",
"appointment_date",
"appointment_time",
"service_details",
"status"
],
"fields": [
{
"fieldname": "section_break_toee",
"fieldtype": "Section Break"
},
{
"fieldname": "appointment_date",
"fieldtype": "Date",
"label": "Appointment Date"
},
{
"fieldname": "appointment_time",
"fieldtype": "Time",
"label": "Appointment Time"
},
{
"fieldname": "service_details",
"fieldtype": "Long Text",
"label": "Service Details"
},
{
"fieldname": "status",
"fieldtype": "Select",
"label": "Status",
"options": "Scheduled\nConfirmed\nDeclined"
},
{
"fieldname": "contact",
"fieldtype": "Link",
"label": "Contact",
"options": "Contact"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-06-03 02:13:09.746413",
"modified_by": "Administrator",
"module": "CRM",
"name": "Service Appointment",
"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": "modified",
"sort_order": "DESC",
"states": []
}

View File

@ -0,0 +1,58 @@
# Copyright (c) 2024, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
# import frappe
import frappe
from frappe.utils import add_days, nowdate
from frappe.model.document import Document
class ServiceAppointment(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
appointment_date: DF.Date | None
appointment_time: DF.Time | None
contact: DF.Link | None
service_details: DF.LongText | None
status: DF.Literal["Scheduled", "Confirmed", "Declined"]
# end: auto-generated types
pass
@frappe.whitelist()
def create_service_appointments(appointment_date, appointment_time, service_details):
# Get all contacts
contacts = frappe.get_all('Contact')
# Loop through contacts
for contact in contacts:
# Fetch contact document
contact_doc = frappe.get_doc('Contact', contact.name)
# Generate a human-readable name
appointment_name = f"{contact_doc.first_name} {contact_doc.last_name} - {appointment_date} {appointment_time}"
# Determine appointment date and time
appointment_date = add_days(nowdate(), 30) # Example: appointment set 30 days from now
appointment_time = '10:00:00' # Example time
# Create a new Service Appointment document
new_appointment = frappe.get_doc({
'doctype': 'Service Appointment',
'contact': contact_doc.name,
'appointment_date': appointment_date,
'appointment_time': appointment_time,
'service_details': service_details,
'status': 'Scheduled'
})
# Insert the new document into the database
new_appointment.insert()
# Commit the transaction
frappe.db.commit()

View File

@ -0,0 +1,9 @@
# Copyright (c) 2024, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
class TestServiceAppointment(FrappeTestCase):
pass