Skip to content

Commit

Permalink
feat: visual plant floor
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitwaghchaure committed Jan 29, 2024
1 parent 866df9f commit 68c997a
Show file tree
Hide file tree
Showing 19 changed files with 896 additions and 151 deletions.
Empty file.
19 changes: 19 additions & 0 deletions erpnext/manufacturing/doctype/plant_floor/plant_floor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt

frappe.ui.form.on("Plant Floor", {
refresh(frm) {
frm.trigger('prepare_dashboard')
},

prepare_dashboard(frm) {
let wrapper = $(frm.fields_dict["plant_dashboard"].wrapper);
wrapper.empty();

frappe.visual_plant_floor = new frappe.ui.VisualPlantFloor({
wrapper: wrapper,
skip_filters: true,
plant_floor: frm.doc.name,
});
},
});
81 changes: 81 additions & 0 deletions erpnext/manufacturing/doctype/plant_floor/plant_floor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "field:floor_name",
"creation": "2023-10-06 15:06:07.976066",
"default_view": "List",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"workstations_tab",
"plant_dashboard",
"details_tab",
"column_break_mvbx",
"floor_name",
"section_break_cczv",
"volumetric_weight"
],
"fields": [
{
"fieldname": "floor_name",
"fieldtype": "Data",
"label": "Floor Name",
"unique": 1
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "workstations_tab",
"fieldtype": "Tab Break",
"label": "Dashboard"
},
{
"fieldname": "plant_dashboard",
"fieldtype": "HTML",
"label": "Plant Dashboard"
},
{
"fieldname": "details_tab",
"fieldtype": "Tab Break",
"label": "Details"
},
{
"fieldname": "column_break_mvbx",
"fieldtype": "Column Break"
},
{
"fieldname": "section_break_cczv",
"fieldtype": "Section Break"
},
{
"fieldname": "volumetric_weight",
"fieldtype": "Float",
"label": "Volumetric Weight"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-04 15:36:09.641203",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Plant Floor",
"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
}
],
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
21 changes: 21 additions & 0 deletions erpnext/manufacturing/doctype/plant_floor/plant_floor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document


class PlantFloor(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

floor_name: DF.Data | None
volumetric_weight: DF.Float
# end: auto-generated types

pass
9 changes: 9 additions & 0 deletions erpnext/manufacturing/doctype/plant_floor/test_plant_floor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase


class TestPlantFloor(FrappeTestCase):
pass
61 changes: 61 additions & 0 deletions erpnext/manufacturing/doctype/workstation/workstation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@
// License: GNU General Public License v3. See license.txt

frappe.ui.form.on("Workstation", {
set_illustration_image(frm) {
let status_image_field = frm.doc.status == "Production" ? frm.doc.on_status_image : frm.doc.off_status_image;
if (status_image_field) {
frm.sidebar.image_wrapper.find(".sidebar-image").attr("src", status_image_field);
}
},

refresh(frm) {
frm.trigger("set_illustration_image");
frm.trigger("prepapre_dashboard");
},

prepapre_dashboard(frm) {
let $parent = $(frm.fields_dict["workstation_dashboard"].wrapper);
$parent.empty();

let workstation_dashboard = new WorkstationDashboard({
wrapper: $parent,
frm: frm
});
},

onload(frm) {
if(frm.is_new())
{
Expand Down Expand Up @@ -54,3 +76,42 @@ frappe.tour['Workstation'] = [


];


class WorkstationDashboard {
constructor({ wrapper, frm }) {
this.$wrapper = $(wrapper);
this.frm = frm;

this.prepapre_dashboard();
}

prepapre_dashboard() {
frappe.call({
method: "erpnext.manufacturing.doctype.workstation.workstation.get_job_cards",
args: {
workstation: this.frm.doc.name
},
callback: (r) => {
if (r.message) {
this.render_job_cards(r.message);
}
}
});
}

render_job_cards(job_cards) {
let template = frappe.render_template("workstation_job_card", {
data: job_cards
});

this.$wrapper.html(template);
this.$wrapper.find(".collapse-indicator-job").on("click", (e) => {
$(e.currentTarget).closest(".form-dashboard-section").find(".section-body-job-card").toggleClass("hide")
if ($(e.currentTarget).closest(".form-dashboard-section").find(".section-body-job-card").hasClass("hide"))
$(e.currentTarget).html(frappe.utils.icon("es-line-down", "sm", "mb-1"))
else
$(e.currentTarget).html(frappe.utils.icon("es-line-up", "sm", "mb-1"))
});
}
}
112 changes: 107 additions & 5 deletions erpnext/manufacturing/doctype/workstation/workstation.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,24 @@
"document_type": "Setup",
"engine": "InnoDB",
"field_order": [
"dashboard_tab",
"workstation_dashboard",
"details_tab",
"workstation_name",
"production_capacity",
"column_break_3",
"workstation_type",
"plant_floor",
"column_break_3",
"production_capacity",
"warehouse",
"production_capacity_section",
"parts_per_hour",
"workstation_status_tab",
"status",
"column_break_glcv",
"illustration_section",
"on_status_image",
"column_break_etmc",
"off_status_image",
"over_heads",
"hour_rate_electricity",
"hour_rate_consumable",
Expand All @@ -24,7 +38,9 @@
"description",
"working_hours_section",
"holiday_list",
"working_hours"
"working_hours",
"total_working_hours",
"connections_tab"
],
"fields": [
{
Expand Down Expand Up @@ -120,9 +136,10 @@
},
{
"default": "1",
"description": "Run parallel job cards in a workstation",
"fieldname": "production_capacity",
"fieldtype": "Int",
"label": "Production Capacity",
"label": "Job Capacity",
"reqd": 1
},
{
Expand All @@ -145,12 +162,97 @@
{
"fieldname": "section_break_11",
"fieldtype": "Section Break"
},
{
"fieldname": "plant_floor",
"fieldtype": "Link",
"label": "Plant Floor",
"options": "Plant Floor"
},
{
"fieldname": "workstation_status_tab",
"fieldtype": "Tab Break",
"label": "Workstation Status"
},
{
"fieldname": "illustration_section",
"fieldtype": "Section Break",
"label": "Status Illustration"
},
{
"fieldname": "column_break_etmc",
"fieldtype": "Column Break"
},
{
"fieldname": "status",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Status",
"options": "Production\nOff\nIdle\nProblem\nMaintenance\nSetup"
},
{
"fieldname": "column_break_glcv",
"fieldtype": "Column Break"
},
{
"fieldname": "on_status_image",
"fieldtype": "Attach Image",
"label": "Active Status"
},
{
"fieldname": "off_status_image",
"fieldtype": "Attach Image",
"label": "Inactive Status"
},
{
"fieldname": "warehouse",
"fieldtype": "Link",
"label": "Warehouse",
"options": "Warehouse"
},
{
"fieldname": "production_capacity_section",
"fieldtype": "Section Break",
"label": "Production Capacity"
},
{
"fieldname": "parts_per_hour",
"fieldtype": "Float",
"label": "Parts Per Hour"
},
{
"fieldname": "total_working_hours",
"fieldtype": "Float",
"label": "Total Working Hours"
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "dashboard_tab",
"fieldtype": "Tab Break",
"label": "Job Cards"
},
{
"fieldname": "details_tab",
"fieldtype": "Tab Break",
"label": "Details"
},
{
"fieldname": "connections_tab",
"fieldtype": "Tab Break",
"label": "Connections",
"show_dashboard": 1
},
{
"fieldname": "workstation_dashboard",
"fieldtype": "HTML",
"label": "Workstation Dashboard"
}
],
"icon": "icon-wrench",
"idx": 1,
"image_field": "on_status_image",
"links": [],
"modified": "2022-11-04 17:39:01.549346",
"modified": "2023-11-30 12:43:35.808845",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Workstation",
Expand Down
Loading

0 comments on commit 68c997a

Please sign in to comment.