Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document checklist for Body and Paint in Repair order #372

Open
wants to merge 7 commits into
base: version-14
Choose a base branch
from
4 changes: 2 additions & 2 deletions erpnext/hr/doctype/employee/employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ def get_employees_who_have_birthday_today(date_today=None):


def send_employee_anniversary_notification():
date_today = getdate()

today = getdate()
Comment on lines 458 to +460
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be reverted?

employees = get_employees_who_have_anniversary_today(date_today)
for name in employees:
doc = frappe.get_doc("Employee", name)
Expand Down
25 changes: 24 additions & 1 deletion erpnext/projects/doctype/project/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ erpnext.projects.ProjectController = class ProjectController extends crm.QuickCo
this.make_vehicle_checklist();
this.make_customer_request_checklist();
this.make_customer_vehicle_selector();
this.make_document_checklist();
this.set_sales_data_html();
this.set_service_advisor_from_user();
this.setup_vehicle_panel_fields();
Expand Down Expand Up @@ -571,12 +572,31 @@ erpnext.projects.ProjectController = class ProjectController extends crm.QuickCo
}
}

make_document_checklist() {
if (this.frm.fields_dict.document_checklist_html) {
var is_read_only = cint(this.frm.doc.__onload && this.frm.doc.__onload.cant_change_fields && this.frm.doc.__onload.cant_change_fields.document_checklist);

this.frm.document_checklist_editor = erpnext.vehicles.make_vehicle_checklist(this.frm,
'document_checklist',
this.frm.fields_dict.document_checklist_html.wrapper,
this.frm.doc.__onload && this.frm.doc.__onload.default_document_checklist_items,
is_read_only,
__("Document Checklist"));
}
}

refresh_customer_request_checklist() {
if (this.frm.customer_request_checklist_editor) {
this.frm.customer_request_checklist_editor.refresh();
}
}

render_document_checklist() {
if (this.frm.document_checklist_editor) {
this.frm.document_checklist_editor.render_checklist();
}
}

make_customer_vehicle_selector() {
if (this.frm.fields_dict.customer_vehicle_selector_html) {
this.frm.customer_vehicle_selector = erpnext.vehicles.make_customer_vehicle_selector(this.frm,
Expand Down Expand Up @@ -619,7 +639,10 @@ erpnext.projects.ProjectController = class ProjectController extends crm.QuickCo
},
callback: function (r) {
if (!r.exc) {
return me.frm.set_value(r.message);
return frappe.run_serially([
() => me.frm.set_value(r.message),
() => me.render_document_checklist(),
]);
}
}
});
Expand Down
13 changes: 12 additions & 1 deletion erpnext/projects/doctype/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from erpnext.controllers.status_updater import StatusUpdaterERP
from erpnext.projects.doctype.project_status.project_status import get_auto_project_status, set_manual_project_status,\
get_valid_manual_project_status_names, is_manual_project_status, validate_project_status_for_transaction
from erpnext.projects.doctype.project_workshop.project_workshop import get_project_workshop_details
from erpnext.projects.doctype.project_workshop.project_workshop import get_project_workshop_details, get_project_workshop_document_checklist_items
from erpnext.vehicles.vehicle_checklist import get_default_vehicle_checklist_items, set_missing_checklist
from erpnext.vehicles.doctype.vehicle_log.vehicle_log import get_customer_vehicle_selector_data
from frappe.model.meta import get_field_precision
Expand Down Expand Up @@ -59,6 +59,7 @@ def onload(self):
self.set_onload('activity_summary', self.get_activity_summary())
self.set_onload('default_vehicle_checklist_items', get_default_vehicle_checklist_items('vehicle_checklist'))
self.set_onload('default_customer_request_checklist_items', get_default_vehicle_checklist_items('customer_request_checklist'))
self.set_onload('default_documents_checklist_items', get_project_workshop_document_checklist_items(self.project_workshop))
self.set_onload('cant_change_fields', self.get_cant_change_fields())
self.set_onload('valid_manual_project_status_names', get_valid_manual_project_status_names(self))
self.set_onload('is_manual_project_status', is_manual_project_status(self.project_status))
Expand Down Expand Up @@ -498,6 +499,15 @@ def validate_insurance_details(self):
if not self.get('insurance_loss_no') and self.ready_to_close == 1:
frappe.throw(_("Insurance Loss # is missing"))

def set_mandatory_items_check(self):
unchecked_items = [
d.checklist_item for d in self.document_checklist
if d.is_mandatory and not d.checklist_item_checked
]

if unchecked_items and self.ready_to_close == 1:
frappe.throw(_("These mandatory items are not checked: {}").format(', '.join(unchecked_items)))

def reopen_status(self, update=True):
self.ready_to_close = 0
self.ready_to_close_dt = None
Expand Down Expand Up @@ -1604,6 +1614,7 @@ def set_project_ready_to_close(project):

project.set_ready_to_close(update=True)
project.validate_insurance_details()
project.set_mandatory_items_check()
project.set_status(update=True)
project.update_vehicle_booking_order_pdi_status()
project.notify_update()
Expand Down
11 changes: 9 additions & 2 deletions erpnext/projects/doctype/project_workshop/project_workshop.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"workshop_name",
"service_manager",
"section_break_3",
"default_cost_centers"
"default_cost_centers",
"document_checklist"
],
"fields": [
{
Expand All @@ -35,10 +36,16 @@
"fieldtype": "Table",
"label": "Default Cost Centers",
"options": "Default Cost Center"
},
{
"fieldname": "document_checklist",
"fieldtype": "Table",
"label": "Document Checklist",
"options": "Vehicle Checklist Item"
}
],
"links": [],
"modified": "2023-10-31 15:28:52.930477",
"modified": "2024-09-04 13:05:45.869493",
"modified_by": "Administrator",
"module": "Projects",
"name": "Project Workshop",
Expand Down
15 changes: 15 additions & 0 deletions erpnext/projects/doctype/project_workshop/project_workshop.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,19 @@ def get_project_workshop_details(project_workshop, company):
out.service_manager = doc.service_manager
out.cost_center = doc.get_default_cost_center(company)

out.document_checklist = []
checklist = get_project_workshop_document_checklist_items(project_workshop)
for item in checklist:
out.document_checklist.append({'checklist_item': item.checklist_item, 'checklist_item_checked': 0, "is_mandatory": item.is_mandatory})

return out


@frappe.whitelist()
def get_project_workshop_document_checklist_items(project_workshop):
if not project_workshop:
return []

workshop_doc = frappe.get_cached_doc("Project Workshop", project_workshop)
checklist_items = [d for d in workshop_doc.get('document_checklist')]
return checklist_items
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"actions": [],
"creation": "2022-01-22 01:23:04.488781",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"checklist_item",
"checklist_item_checked",
"is_custom_checklist_item"
"is_custom_checklist_item",
"is_mandatory"
],
"fields": [
{
Expand All @@ -27,10 +29,17 @@
"fieldname": "is_custom_checklist_item",
"fieldtype": "Check",
"label": "Is Custom Checklist Item"
},
{
"default": "0",
"fieldname": "is_mandatory",
"fieldtype": "Check",
"label": "Is Mandatory"
}
],
"istable": 1,
"modified": "2022-01-22 14:06:57.660110",
"links": [],
"modified": "2024-09-16 16:23:35.850191",
"modified_by": "Administrator",
"module": "Vehicles",
"name": "Vehicle Checklist Item",
Expand All @@ -39,5 +48,6 @@
"quick_entry": 1,
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
38 changes: 33 additions & 5 deletions erpnext/vehicles/vehicle_checklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ erpnext.vehicles.VehicleChecklistEditor = Class.extend({
me.checklist_wrapper = $(`<div class="row vehicle-checklist"></div>`).appendTo(me.wrapper);
me.left_container = $(`<div class="col-sm-6"></div>`).appendTo(me.checklist_wrapper);
me.right_container = $(`<div class="col-sm-6"></div>`).appendTo(me.checklist_wrapper);
me.buttons_container = $(`<div style="margin-top: 5px;"></div>`).appendTo(me.wrapper);
me.buttons_container = $(`<div style="margin-bottom: 15px ;"></div>`).appendTo(me.wrapper);
me.empty_checklist_container = $(`<div></div>`).appendTo(me.wrapper);

me.frm = frm;
Expand All @@ -26,10 +26,10 @@ erpnext.vehicles.VehicleChecklistEditor = Class.extend({
me.default_checklist_items = default_items || [];

var checklist_items = me.get_checklist_items();
if (checklist_items && checklist_items.length) {
me.render_checklist();
} else {
if (!checklist_items?.length && ['vehicle_checklist', 'customer_request_checklist'].includes(parentfield)) {
me.load_items_and_render();
} else {
me.render_checklist();
}

me.bind();
Expand Down Expand Up @@ -59,6 +59,27 @@ erpnext.vehicles.VehicleChecklistEditor = Class.extend({
});
},

get_project_workshop_details() {
var me = this;
if (me.frm.doc.project_workshop) {
return frappe.call({
method: "erpnext.projects.doctype.project_workshop.project_workshop.get_project_workshop_details",
args: {
project_workshop: me.frm.doc.project_workshop,
company: me.frm.doc.company,
},
callback: function (r) {
if (!r.exc) {
return frappe.run_serially([
() => me.frm.set_value(r.message),
() => me.render_checklist(),
]);
}
}
});
}
},

set_from_default_checklist_items: function () {
var me = this;
if (me.can_write()) {
Expand Down Expand Up @@ -257,7 +278,14 @@ erpnext.vehicles.VehicleChecklistEditor = Class.extend({
},

on_reset_checklist: function () {
frappe.confirm(__("Are you sure you want to reset the vehicle checklist?"), () => this.load_items_and_render());
var parentfield = this.parentfield;
frappe.confirm(__("Are you sure you want to reset the vehicle checklist?"), () => {
if (['vehicle_checklist', 'customer_request_checklist'].includes(parentfield)){
this.load_items_and_render();
} else {
this.get_project_workshop_details();
}
});
},

get_checklist_items: function () {
Expand Down