Compare commits
2 Commits
6fda96983b
...
2bb22f5e72
Author | SHA1 | Date | |
---|---|---|---|
|
2bb22f5e72 | ||
|
77cb64ce34 |
@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2024, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
// frappe.ui.form.on("Master Branch Doctype", {
|
||||
// frappe.ui.form.on("Service Appointment", {
|
||||
// refresh(frm) {
|
||||
|
||||
// },
|
@ -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": []
|
||||
}
|
@ -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()
|
@ -5,5 +5,5 @@
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
|
||||
|
||||
class TestMasterBranchDoctype(FrappeTestCase):
|
||||
class TestServiceAppointment(FrappeTestCase):
|
||||
pass
|
@ -1,41 +0,0 @@
|
||||
{
|
||||
"actions": [],
|
||||
"allow_rename": 1,
|
||||
"creation": "2024-05-22 05:06:27.536438",
|
||||
"doctype": "DocType",
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"custom_name"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "custom_name",
|
||||
"fieldtype": "Data",
|
||||
"label": "Name"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-05-22 05:06:47.486113",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Master Branch Module",
|
||||
"name": "Master Branch Doctype",
|
||||
"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": []
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
# Copyright (c) 2024, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
class MasterBranchDoctype(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
|
||||
|
||||
custom_name: DF.Data | None
|
||||
# end: auto-generated types
|
||||
pass
|
@ -18,4 +18,4 @@ Communication
|
||||
Telephony
|
||||
Bulk Transaction
|
||||
Subcontracting
|
||||
Master Branch Module
|
||||
Programming Module
|
Loading…
Reference in New Issue
Block a user