mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 23:49:19 +00:00
feat: track Semi-finished goods (including subcontracted items) against Job Cards (#38341)
* feat: Track Semi-finished goods (including subcontracted items) against Job Cards * feat: option to add raw materials manually against operation
This commit is contained in:
@@ -369,7 +369,7 @@ class PurchaseOrder(BuyingController):
|
|||||||
item.idx, item.fg_item
|
item.idx, item.fg_item
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif not frappe.get_value("Item", item.fg_item, "default_bom"):
|
elif not item.bom and not frappe.get_value("Item", item.fg_item, "default_bom"):
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_("Row #{0}: Default BOM not found for FG Item {1}").format(
|
_("Row #{0}: Default BOM not found for FG Item {1}").format(
|
||||||
item.idx, item.fg_item
|
item.idx, item.fg_item
|
||||||
@@ -919,6 +919,14 @@ def get_mapped_subcontracting_order(source_name, target_doc=None):
|
|||||||
for idx, item in enumerate(target_doc.items):
|
for idx, item in enumerate(target_doc.items):
|
||||||
item.warehouse = source_doc.items[idx].warehouse
|
item.warehouse = source_doc.items[idx].warehouse
|
||||||
|
|
||||||
|
for idx, item in enumerate(target_doc.items):
|
||||||
|
item.job_card = source_doc.items[idx].job_card
|
||||||
|
if not target_doc.supplier_warehouse:
|
||||||
|
# WIP warehouse is set as Supplier Warehouse in Job Card
|
||||||
|
target_doc.supplier_warehouse = frappe.get_cached_value(
|
||||||
|
"Job Card", item.job_card, "wip_warehouse"
|
||||||
|
)
|
||||||
|
|
||||||
return target_doc
|
return target_doc
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,9 @@
|
|||||||
"production_plan",
|
"production_plan",
|
||||||
"production_plan_item",
|
"production_plan_item",
|
||||||
"production_plan_sub_assembly_item",
|
"production_plan_sub_assembly_item",
|
||||||
"page_break"
|
"page_break",
|
||||||
|
"column_break_pjyo",
|
||||||
|
"job_card"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -909,13 +911,24 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "column_break_fyqr",
|
"fieldname": "column_break_fyqr",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_pjyo",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "job_card",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Job Card",
|
||||||
|
"options": "Job Card",
|
||||||
|
"search_index": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-27 13:10:24.979325",
|
"modified": "2024-03-27 13:12:24.979325",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Purchase Order Item",
|
"name": "Purchase Order Item",
|
||||||
|
|||||||
@@ -19,6 +19,21 @@ frappe.ui.form.on("BOM", {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frm.set_query("bom_no", "operations", function (doc, cdt, cdn) {
|
||||||
|
let row = locals[cdt][cdn];
|
||||||
|
return {
|
||||||
|
query: "erpnext.controllers.queries.bom",
|
||||||
|
filters: {
|
||||||
|
currency: frm.doc.currency,
|
||||||
|
company: frm.doc.company,
|
||||||
|
item: row.finished_good,
|
||||||
|
is_active: 1,
|
||||||
|
docstatus: 1,
|
||||||
|
track_semi_finished_goods: 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
frm.set_query("source_warehouse", "items", function () {
|
frm.set_query("source_warehouse", "items", function () {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
@@ -85,6 +100,27 @@ frappe.ui.form.on("BOM", {
|
|||||||
frm.get_field("items").grid.set_multiple_add("item_code", "qty");
|
frm.get_field("items").grid.set_multiple_add("item_code", "qty");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
default_source_warehouse(frm) {
|
||||||
|
if (frm.doc.default_source_warehouse) {
|
||||||
|
frm.doc.operations.forEach((d) => {
|
||||||
|
frappe.model.set_value(
|
||||||
|
d.doctype,
|
||||||
|
d.name,
|
||||||
|
"source_warehouse",
|
||||||
|
frm.doc.default_source_warehouse
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
default_target_warehouse(frm) {
|
||||||
|
if (frm.doc.default_source_warehouse) {
|
||||||
|
frm.doc.operations.forEach((d) => {
|
||||||
|
frappe.model.set_value(d.doctype, d.name, "fg_warehouse", frm.doc.default_target_warehouse);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
refresh(frm) {
|
refresh(frm) {
|
||||||
frm.toggle_enable("item", frm.doc.__islocal);
|
frm.toggle_enable("item", frm.doc.__islocal);
|
||||||
|
|
||||||
@@ -96,22 +132,35 @@ frappe.ui.form.on("BOM", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!frm.is_new() && frm.doc.docstatus < 2) {
|
if (!frm.is_new() && frm.doc.docstatus < 2) {
|
||||||
frm.add_custom_button(__("Update Cost"), function () {
|
frm.add_custom_button(
|
||||||
frm.events.update_cost(frm, true);
|
__("Update Cost"),
|
||||||
});
|
function () {
|
||||||
frm.add_custom_button(__("Browse BOM"), function () {
|
frm.events.update_cost(frm, true);
|
||||||
frappe.route_options = {
|
},
|
||||||
bom: frm.doc.name,
|
__("Actions")
|
||||||
};
|
);
|
||||||
frappe.set_route("Tree", "BOM");
|
|
||||||
});
|
frm.add_custom_button(
|
||||||
|
__("Browse BOM"),
|
||||||
|
function () {
|
||||||
|
frappe.route_options = {
|
||||||
|
bom: frm.doc.name,
|
||||||
|
};
|
||||||
|
frappe.set_route("Tree", "BOM");
|
||||||
|
},
|
||||||
|
__("Actions")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!frm.is_new() && !frm.doc.docstatus == 0) {
|
if (!frm.is_new() && !frm.doc.docstatus == 0) {
|
||||||
frm.add_custom_button(__("New Version"), function () {
|
frm.add_custom_button(
|
||||||
let new_bom = frappe.model.copy_doc(frm.doc);
|
__("New Version"),
|
||||||
frappe.set_route("Form", "BOM", new_bom.name);
|
function () {
|
||||||
});
|
let new_bom = frappe.model.copy_doc(frm.doc);
|
||||||
|
frappe.set_route("Form", "BOM", new_bom.name);
|
||||||
|
},
|
||||||
|
__("Actions")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frm.doc.docstatus == 1) {
|
if (frm.doc.docstatus == 1) {
|
||||||
@@ -432,6 +481,28 @@ frappe.ui.form.on("BOM", {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frappe.ui.form.on("BOM Operation", {
|
||||||
|
bom_no(frm, cdt, cdn) {
|
||||||
|
let row = locals[cdt][cdn];
|
||||||
|
|
||||||
|
if (row.bom_no && row.finished_good) {
|
||||||
|
frappe.call({
|
||||||
|
method: "add_materials_from_bom",
|
||||||
|
doc: frm.doc,
|
||||||
|
args: {
|
||||||
|
finished_good: row.finished_good,
|
||||||
|
bom_no: row.bom_no,
|
||||||
|
operation_row_id: row.idx,
|
||||||
|
qty: row.finished_good_qty,
|
||||||
|
},
|
||||||
|
callback(r) {
|
||||||
|
refresh_field("items");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
erpnext.bom.BomController = class BomController extends erpnext.TransactionController {
|
erpnext.bom.BomController = class BomController extends erpnext.TransactionController {
|
||||||
conversion_rate(doc) {
|
conversion_rate(doc) {
|
||||||
if (this.frm.doc.currency === this.get_company_currency()) {
|
if (this.frm.doc.currency === this.get_company_currency()) {
|
||||||
@@ -801,3 +872,88 @@ function trigger_process_loss_qty_prompt(frm, cdt, cdn, item_code) {
|
|||||||
__("Set Quantity")
|
__("Set Quantity")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frappe.ui.form.on("BOM Operation", {
|
||||||
|
add_raw_materials(frm, cdt, cdn) {
|
||||||
|
let row = locals[cdt][cdn];
|
||||||
|
frm.events._prompt_for_raw_materials(frm, row);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
frappe.ui.form.on("BOM", {
|
||||||
|
_prompt_for_raw_materials(frm, row) {
|
||||||
|
let fields = frm.events.get_fields_for_prompt(frm, row);
|
||||||
|
frm._bom_rm_dialog = new frappe.ui.Dialog({
|
||||||
|
title: __("Add Raw Materials"),
|
||||||
|
fields: fields,
|
||||||
|
primary_action_label: __("Add"),
|
||||||
|
primary_action: () => {
|
||||||
|
let values = frm._bom_rm_dialog.get_values();
|
||||||
|
if (values) {
|
||||||
|
frm.events._add_raw_materials(frm, values);
|
||||||
|
frm._bom_rm_dialog.hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
frm._bom_rm_dialog.show();
|
||||||
|
},
|
||||||
|
|
||||||
|
get_fields_for_prompt(frm, row) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: __("Raw Materials"),
|
||||||
|
fieldname: "items",
|
||||||
|
fieldtype: "Table",
|
||||||
|
reqd: 1,
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
label: __("Item"),
|
||||||
|
fieldname: "item_code",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Item",
|
||||||
|
reqd: 1,
|
||||||
|
in_list_view: 1,
|
||||||
|
change() {
|
||||||
|
let doc = this.doc;
|
||||||
|
doc.qty = 1.0;
|
||||||
|
this.grid.set_value("qty", 1.0, doc);
|
||||||
|
},
|
||||||
|
get_query() {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
name: ["!=", row.finished_good],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Qty"),
|
||||||
|
fieldname: "qty",
|
||||||
|
default: 1.0,
|
||||||
|
fieldtype: "Float",
|
||||||
|
reqd: 1,
|
||||||
|
in_list_view: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldname: "operation_row_id",
|
||||||
|
fieldtype: "Data",
|
||||||
|
hidden: 1,
|
||||||
|
default: row.idx,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
|
|
||||||
|
_add_raw_materials(frm, values) {
|
||||||
|
frm.call({
|
||||||
|
method: "add_raw_materials",
|
||||||
|
doc: frm.doc,
|
||||||
|
args: {
|
||||||
|
operation_row_id: values.operation_row_id,
|
||||||
|
items: values.items,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|||||||
@@ -26,19 +26,22 @@
|
|||||||
"column_break_ivyw",
|
"column_break_ivyw",
|
||||||
"currency",
|
"currency",
|
||||||
"conversion_rate",
|
"conversion_rate",
|
||||||
"materials_section",
|
|
||||||
"items",
|
|
||||||
"section_break_21",
|
|
||||||
"operations_section_section",
|
"operations_section_section",
|
||||||
"with_operations",
|
"with_operations",
|
||||||
|
"track_semi_finished_goods",
|
||||||
"column_break_23",
|
"column_break_23",
|
||||||
"transfer_material_against",
|
"transfer_material_against",
|
||||||
"routing",
|
"routing",
|
||||||
"fg_based_operating_cost",
|
"fg_based_operating_cost",
|
||||||
|
"column_break_joxb",
|
||||||
|
"default_source_warehouse",
|
||||||
|
"default_target_warehouse",
|
||||||
"fg_based_section_section",
|
"fg_based_section_section",
|
||||||
"operating_cost_per_bom_quantity",
|
"operating_cost_per_bom_quantity",
|
||||||
"operations_section",
|
"operations_section",
|
||||||
"operations",
|
"operations",
|
||||||
|
"materials_section",
|
||||||
|
"items",
|
||||||
"scrap_section",
|
"scrap_section",
|
||||||
"scrap_items_section",
|
"scrap_items_section",
|
||||||
"scrap_items",
|
"scrap_items",
|
||||||
@@ -59,8 +62,8 @@
|
|||||||
"base_total_cost",
|
"base_total_cost",
|
||||||
"more_info_tab",
|
"more_info_tab",
|
||||||
"item_name",
|
"item_name",
|
||||||
"description",
|
|
||||||
"column_break_27",
|
"column_break_27",
|
||||||
|
"description",
|
||||||
"has_variants",
|
"has_variants",
|
||||||
"quality_inspection_section_break",
|
"quality_inspection_section_break",
|
||||||
"inspection_required",
|
"inspection_required",
|
||||||
@@ -211,7 +214,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "Work Order",
|
"default": "Work Order",
|
||||||
"depends_on": "with_operations",
|
"depends_on": "eval: doc.with_operations === 1 && doc.track_semi_finished_goods === 0",
|
||||||
"fieldname": "transfer_material_against",
|
"fieldname": "transfer_material_against",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Transfer Material Against",
|
"label": "Transfer Material Against",
|
||||||
@@ -406,8 +409,8 @@
|
|||||||
{
|
{
|
||||||
"depends_on": "eval:!doc.__islocal",
|
"depends_on": "eval:!doc.__islocal",
|
||||||
"fieldname": "section_break0",
|
"fieldname": "section_break0",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Tab Break",
|
||||||
"label": "Materials Required (Exploded)"
|
"label": "Exploded Items"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "exploded_items",
|
"fieldname": "exploded_items",
|
||||||
@@ -485,11 +488,6 @@
|
|||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Show Operations"
|
"label": "Show Operations"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "section_break_21",
|
|
||||||
"fieldtype": "Tab Break",
|
|
||||||
"label": "Operations"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_23",
|
"fieldname": "column_break_23",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
@@ -534,6 +532,8 @@
|
|||||||
"show_dashboard": 1
|
"show_dashboard": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"collapsible": 1,
|
||||||
|
"collapsible_depends_on": "eval:doc.with_operations",
|
||||||
"fieldname": "operations_section_section",
|
"fieldname": "operations_section_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Operations"
|
"label": "Operations"
|
||||||
@@ -617,7 +617,8 @@
|
|||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "BOM Creator",
|
"options": "BOM Creator",
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1,
|
||||||
|
"search_index": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "bom_creator_item",
|
"fieldname": "bom_creator_item",
|
||||||
@@ -625,11 +626,36 @@
|
|||||||
"label": "BOM Creator Item",
|
"label": "BOM Creator Item",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1,
|
||||||
|
"search_index": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_oxbz",
|
"fieldname": "column_break_oxbz",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"depends_on": "with_operations",
|
||||||
|
"description": "Users can consume raw materials and add semi-finished goods or final finished goods against the operation using job cards.",
|
||||||
|
"fieldname": "track_semi_finished_goods",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Track Semi Finished Goods"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_joxb",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "default_source_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Default Source Warehouse",
|
||||||
|
"options": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "default_target_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Default Target Warehouse",
|
||||||
|
"options": "Warehouse"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-sitemap",
|
"icon": "fa fa-sitemap",
|
||||||
@@ -637,7 +663,7 @@
|
|||||||
"image_field": "image",
|
"image_field": "image",
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-04-02 16:22:47.518411",
|
"modified": "2024-04-02 16:24:47.518411",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "BOM",
|
"name": "BOM",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import frappe
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.core.doctype.version.version import get_diff
|
from frappe.core.doctype.version.version import get_diff
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from frappe.utils import cint, cstr, flt, today
|
from frappe.utils import cint, cstr, flt, parse_json, today
|
||||||
from frappe.website.website_generator import WebsiteGenerator
|
from frappe.website.website_generator import WebsiteGenerator
|
||||||
|
|
||||||
import erpnext
|
import erpnext
|
||||||
@@ -125,6 +125,8 @@ class BOM(WebsiteGenerator):
|
|||||||
company: DF.Link
|
company: DF.Link
|
||||||
conversion_rate: DF.Float
|
conversion_rate: DF.Float
|
||||||
currency: DF.Link
|
currency: DF.Link
|
||||||
|
default_source_warehouse: DF.Link | None
|
||||||
|
default_target_warehouse: DF.Link | None
|
||||||
description: DF.SmallText | None
|
description: DF.SmallText | None
|
||||||
exploded_items: DF.Table[BOMExplosionItem]
|
exploded_items: DF.Table[BOMExplosionItem]
|
||||||
fg_based_operating_cost: DF.Check
|
fg_based_operating_cost: DF.Check
|
||||||
@@ -136,6 +138,7 @@ class BOM(WebsiteGenerator):
|
|||||||
item: DF.Link
|
item: DF.Link
|
||||||
item_name: DF.Data | None
|
item_name: DF.Data | None
|
||||||
items: DF.Table[BOMItem]
|
items: DF.Table[BOMItem]
|
||||||
|
track_semi_finished_goods: DF.Check
|
||||||
operating_cost: DF.Currency
|
operating_cost: DF.Currency
|
||||||
operating_cost_per_bom_quantity: DF.Currency
|
operating_cost_per_bom_quantity: DF.Currency
|
||||||
operations: DF.Table[BOMOperation]
|
operations: DF.Table[BOMOperation]
|
||||||
@@ -245,6 +248,7 @@ class BOM(WebsiteGenerator):
|
|||||||
self.clear_inspection()
|
self.clear_inspection()
|
||||||
self.validate_main_item()
|
self.validate_main_item()
|
||||||
self.validate_currency()
|
self.validate_currency()
|
||||||
|
self.set_materials_based_on_operation_bom()
|
||||||
self.set_conversion_rate()
|
self.set_conversion_rate()
|
||||||
self.set_plc_conversion_rate()
|
self.set_plc_conversion_rate()
|
||||||
self.validate_uom_is_interger()
|
self.validate_uom_is_interger()
|
||||||
@@ -544,6 +548,9 @@ class BOM(WebsiteGenerator):
|
|||||||
if not self.with_operations:
|
if not self.with_operations:
|
||||||
self.set("operations", [])
|
self.set("operations", [])
|
||||||
|
|
||||||
|
if not self.with_operations and self.track_semi_finished_goods:
|
||||||
|
self.track_semi_finished_goods = 0
|
||||||
|
|
||||||
def clear_inspection(self):
|
def clear_inspection(self):
|
||||||
if not self.inspection_required:
|
if not self.inspection_required:
|
||||||
self.quality_inspection_template = None
|
self.quality_inspection_template = None
|
||||||
@@ -645,6 +652,49 @@ class BOM(WebsiteGenerator):
|
|||||||
if self.name in {d.bom_no for d in self.items}:
|
if self.name in {d.bom_no for d in self.items}:
|
||||||
_throw_error(self.name)
|
_throw_error(self.name)
|
||||||
|
|
||||||
|
def set_materials_based_on_operation_bom(self):
|
||||||
|
if not self.track_semi_finished_goods:
|
||||||
|
return
|
||||||
|
|
||||||
|
for row in self.get("operations"):
|
||||||
|
if row.bom_no and row.finished_good:
|
||||||
|
self.add_materials_from_bom(row.finished_good, row.bom_no, row.idx, qty=row.finished_good_qty)
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def add_raw_materials(self, operation_row_id, items):
|
||||||
|
if isinstance(items, str):
|
||||||
|
items = parse_json(items)
|
||||||
|
|
||||||
|
for row in items:
|
||||||
|
row = parse_json(row)
|
||||||
|
|
||||||
|
row.update(get_item_details(row.get("item_code")))
|
||||||
|
row.operation_row_id = operation_row_id
|
||||||
|
row.idx = None
|
||||||
|
row.name = None
|
||||||
|
self.append("items", row)
|
||||||
|
|
||||||
|
self.save()
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def add_materials_from_bom(self, finished_good, bom_no, operation_row_id, qty=None):
|
||||||
|
if not frappe.db.exists("BOM", {"item": finished_good, "name": bom_no, "docstatus": 1}):
|
||||||
|
frappe.throw(_("BOM {0} not found for the item {1}").format(bom_no, finished_good))
|
||||||
|
|
||||||
|
if not qty:
|
||||||
|
qty = 1
|
||||||
|
|
||||||
|
for row in self.items:
|
||||||
|
if row.operation_row_id == operation_row_id:
|
||||||
|
return
|
||||||
|
|
||||||
|
bom_items = get_bom_items(bom_no, self.company, qty=qty, fetch_exploded=0)
|
||||||
|
for row in bom_items:
|
||||||
|
row.uom = row.stock_uom
|
||||||
|
row.operation_row_id = operation_row_id
|
||||||
|
row.idx = None
|
||||||
|
self.append("items", row)
|
||||||
|
|
||||||
def traverse_tree(self, bom_list=None):
|
def traverse_tree(self, bom_list=None):
|
||||||
def _get_children(bom_no):
|
def _get_children(bom_no):
|
||||||
children = frappe.cache().hget("bom_children", bom_no)
|
children = frappe.cache().hget("bom_children", bom_no)
|
||||||
@@ -1094,6 +1144,11 @@ def get_bom_items_as_dict(
|
|||||||
):
|
):
|
||||||
item_dict = {}
|
item_dict = {}
|
||||||
|
|
||||||
|
group_by_cond = "group by item_code, stock_uom"
|
||||||
|
if frappe.get_cached_value("BOM", bom, "track_semi_finished_goods"):
|
||||||
|
fetch_exploded = 0
|
||||||
|
group_by_cond = "group by item_code, operation_row_id, stock_uom"
|
||||||
|
|
||||||
# Did not use qty_consumed_per_unit in the query, as it leads to rounding loss
|
# Did not use qty_consumed_per_unit in the query, as it leads to rounding loss
|
||||||
query = """select
|
query = """select
|
||||||
bom_item.item_code,
|
bom_item.item_code,
|
||||||
@@ -1122,7 +1177,7 @@ def get_bom_items_as_dict(
|
|||||||
and bom.name = %(bom)s
|
and bom.name = %(bom)s
|
||||||
and item.is_stock_item in (1, {is_stock_item})
|
and item.is_stock_item in (1, {is_stock_item})
|
||||||
{where_conditions}
|
{where_conditions}
|
||||||
group by item_code, stock_uom
|
{group_by_cond}
|
||||||
order by idx"""
|
order by idx"""
|
||||||
|
|
||||||
is_stock_item = 0 if include_non_stock_items else 1
|
is_stock_item = 0 if include_non_stock_items else 1
|
||||||
@@ -1132,6 +1187,7 @@ def get_bom_items_as_dict(
|
|||||||
where_conditions="",
|
where_conditions="",
|
||||||
is_stock_item=is_stock_item,
|
is_stock_item=is_stock_item,
|
||||||
qty_field="stock_qty",
|
qty_field="stock_qty",
|
||||||
|
group_by_cond=group_by_cond,
|
||||||
select_columns=""", bom_item.source_warehouse, bom_item.operation,
|
select_columns=""", bom_item.source_warehouse, bom_item.operation,
|
||||||
bom_item.include_item_in_manufacturing, bom_item.description, bom_item.rate, bom_item.sourced_by_supplier,
|
bom_item.include_item_in_manufacturing, bom_item.description, bom_item.rate, bom_item.sourced_by_supplier,
|
||||||
(Select idx from `tabBOM Item` where item_code = bom_item.item_code and parent = %(parent)s limit 1) as idx""",
|
(Select idx from `tabBOM Item` where item_code = bom_item.item_code and parent = %(parent)s limit 1) as idx""",
|
||||||
@@ -1147,6 +1203,7 @@ def get_bom_items_as_dict(
|
|||||||
select_columns=", item.description",
|
select_columns=", item.description",
|
||||||
is_stock_item=is_stock_item,
|
is_stock_item=is_stock_item,
|
||||||
qty_field="stock_qty",
|
qty_field="stock_qty",
|
||||||
|
group_by_cond=group_by_cond,
|
||||||
)
|
)
|
||||||
|
|
||||||
items = frappe.db.sql(query, {"qty": qty, "bom": bom, "company": company}, as_dict=True)
|
items = frappe.db.sql(query, {"qty": qty, "bom": bom, "company": company}, as_dict=True)
|
||||||
@@ -1158,15 +1215,20 @@ def get_bom_items_as_dict(
|
|||||||
qty_field="stock_qty" if fetch_qty_in_stock_uom else "qty",
|
qty_field="stock_qty" if fetch_qty_in_stock_uom else "qty",
|
||||||
select_columns=""", bom_item.uom, bom_item.conversion_factor, bom_item.source_warehouse,
|
select_columns=""", bom_item.uom, bom_item.conversion_factor, bom_item.source_warehouse,
|
||||||
bom_item.operation, bom_item.include_item_in_manufacturing, bom_item.sourced_by_supplier,
|
bom_item.operation, bom_item.include_item_in_manufacturing, bom_item.sourced_by_supplier,
|
||||||
bom_item.description, bom_item.base_rate as rate """,
|
bom_item.description, bom_item.base_rate as rate, bom_item.operation_row_id """,
|
||||||
|
group_by_cond=group_by_cond,
|
||||||
)
|
)
|
||||||
items = frappe.db.sql(query, {"qty": qty, "bom": bom, "company": company}, as_dict=True)
|
items = frappe.db.sql(query, {"qty": qty, "bom": bom, "company": company}, as_dict=True)
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
if item.item_code in item_dict:
|
key = item.item_code
|
||||||
item_dict[item.item_code]["qty"] += flt(item.qty)
|
if item.operation_row_id:
|
||||||
|
key = (item.item_code, item.operation_row_id)
|
||||||
|
|
||||||
|
if key in item_dict:
|
||||||
|
item_dict[key]["qty"] += flt(item.qty)
|
||||||
else:
|
else:
|
||||||
item_dict[item.item_code] = item
|
item_dict[key] = item
|
||||||
|
|
||||||
for item, item_details in item_dict.items():
|
for item, item_details in item_dict.items():
|
||||||
for d in [
|
for d in [
|
||||||
|
|||||||
@@ -88,9 +88,77 @@ frappe.ui.form.on("BOM Creator", {
|
|||||||
reqd: 1,
|
reqd: 1,
|
||||||
default: 1.0,
|
default: 1.0,
|
||||||
},
|
},
|
||||||
|
{ fieldtype: "Section Break" },
|
||||||
|
{
|
||||||
|
label: __("Track Operations"),
|
||||||
|
fieldtype: "Check",
|
||||||
|
fieldname: "track_operations",
|
||||||
|
onchange: (r) => {
|
||||||
|
let track_operations = dialog.get_value("track_operations");
|
||||||
|
if (r.type === "input" && !track_operations) {
|
||||||
|
dialog.set_value("track_semi_finished_goods", 0);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ fieldtype: "Column Break" },
|
||||||
|
{
|
||||||
|
label: __("Track Semi Finished Goods"),
|
||||||
|
fieldtype: "Check",
|
||||||
|
fieldname: "track_semi_finished_goods",
|
||||||
|
depends_on: "eval:doc.track_operations",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldtype: "Section Break",
|
||||||
|
label: __("Final Product Operation"),
|
||||||
|
depends_on: "eval:doc.track_semi_finished_goods",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Operation"),
|
||||||
|
fieldtype: "Link",
|
||||||
|
fieldname: "operation",
|
||||||
|
options: "Operation",
|
||||||
|
default: "Assembly",
|
||||||
|
mandatory_depends_on: "eval:doc.track_semi_finished_goods",
|
||||||
|
depends_on: "eval:doc.track_semi_finished_goods",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Operation Time (in mins)"),
|
||||||
|
fieldtype: "Float",
|
||||||
|
fieldname: "operation_time",
|
||||||
|
mandatory_depends_on: "eval:doc.track_semi_finished_goods",
|
||||||
|
depends_on: "eval:doc.track_semi_finished_goods",
|
||||||
|
},
|
||||||
|
{ fieldtype: "Column Break" },
|
||||||
|
{
|
||||||
|
label: __("Workstation Type"),
|
||||||
|
fieldtype: "Link",
|
||||||
|
fieldname: "workstation_type",
|
||||||
|
options: "Workstation",
|
||||||
|
depends_on: "eval:doc.track_semi_finished_goods",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Workstation"),
|
||||||
|
fieldtype: "Link",
|
||||||
|
fieldname: "workstation",
|
||||||
|
options: "Workstation",
|
||||||
|
depends_on: "eval:doc.track_semi_finished_goods",
|
||||||
|
get_query() {
|
||||||
|
let workstation_type = dialog.get_value("workstation_type");
|
||||||
|
|
||||||
|
if (workstation_type) {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
workstation_type: dialog.get_value("workstation_type"),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
primary_action_label: __("Create"),
|
primary_action_label: __("Create"),
|
||||||
primary_action: (values) => {
|
primary_action: (values) => {
|
||||||
|
frm.events.validate_dialog_values(frm, values);
|
||||||
|
|
||||||
values.doctype = frm.doc.doctype;
|
values.doctype = frm.doc.doctype;
|
||||||
frappe.db.insert(values).then((doc) => {
|
frappe.db.insert(values).then((doc) => {
|
||||||
frappe.set_route("Form", doc.doctype, doc.name);
|
frappe.set_route("Form", doc.doctype, doc.name);
|
||||||
@@ -102,6 +170,18 @@ frappe.ui.form.on("BOM Creator", {
|
|||||||
dialog.show();
|
dialog.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
validate_dialog_values(frm, values) {
|
||||||
|
if (values.track_semi_finished_goods) {
|
||||||
|
if (values.final_operation_time <= 0) {
|
||||||
|
frappe.throw(__("Operation Time must be greater than 0"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!values.workstation && !values.workstation_type) {
|
||||||
|
frappe.throw(__("Either Workstation or Workstation Type is mandatory"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
set_queries(frm) {
|
set_queries(frm) {
|
||||||
frm.set_query("bom_no", "items", function (doc, cdt, cdn) {
|
frm.set_query("bom_no", "items", function (doc, cdt, cdn) {
|
||||||
let item = frappe.get_doc(cdt, cdn);
|
let item = frappe.get_doc(cdt, cdn);
|
||||||
@@ -121,6 +201,16 @@ frappe.ui.form.on("BOM Creator", {
|
|||||||
query: "erpnext.controllers.queries.item_query",
|
query: "erpnext.controllers.queries.item_query",
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frm.set_query("workstation", (doc) => {
|
||||||
|
if (doc.workstation_type) {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
workstation_type: doc.workstation_type,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh(frm) {
|
refresh(frm) {
|
||||||
|
|||||||
@@ -37,6 +37,23 @@
|
|||||||
"items",
|
"items",
|
||||||
"costing_detail",
|
"costing_detail",
|
||||||
"raw_material_cost",
|
"raw_material_cost",
|
||||||
|
"configuration_section",
|
||||||
|
"track_operations",
|
||||||
|
"column_break_obzr",
|
||||||
|
"track_semi_finished_goods",
|
||||||
|
"final_product_operation_section",
|
||||||
|
"operation",
|
||||||
|
"operation_time",
|
||||||
|
"column_break_xnlu",
|
||||||
|
"workstation_type",
|
||||||
|
"workstation",
|
||||||
|
"final_product_warehouse_section",
|
||||||
|
"skip_material_transfer",
|
||||||
|
"backflush_from_wip_warehouse",
|
||||||
|
"source_warehouse",
|
||||||
|
"column_break_buha",
|
||||||
|
"wip_warehouse",
|
||||||
|
"fg_warehouse",
|
||||||
"remarks_tab",
|
"remarks_tab",
|
||||||
"remarks",
|
"remarks",
|
||||||
"section_break_yixm",
|
"section_break_yixm",
|
||||||
@@ -278,6 +295,104 @@
|
|||||||
"fieldtype": "Text",
|
"fieldtype": "Text",
|
||||||
"label": "Error Log",
|
"label": "Error Log",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "configuration_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Operation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"depends_on": "track_operations",
|
||||||
|
"fieldname": "track_semi_finished_goods",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Track Semi Finished Goods"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_obzr",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "track_operations",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Track Operations"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.track_semi_finished_goods === 1",
|
||||||
|
"fieldname": "final_product_operation_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Final Product Operation & Workstation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_xnlu",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "operation",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Operation",
|
||||||
|
"options": "Operation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "operation_time",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"label": "Operation Time (in mins)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "workstation",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Workstation",
|
||||||
|
"options": "Workstation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "workstation_type",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Workstation Type",
|
||||||
|
"options": "Workstation Type"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:!doc.backflush_from_wip_warehouse",
|
||||||
|
"fieldname": "source_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Source Warehouse",
|
||||||
|
"options": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:!doc.skip_material_transfer || doc.backflush_from_wip_warehouse",
|
||||||
|
"fieldname": "wip_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Work In Progress Warehouse",
|
||||||
|
"options": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "fg_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Finished Good Warehouse",
|
||||||
|
"options": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.track_semi_finished_goods === 1",
|
||||||
|
"fieldname": "final_product_warehouse_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Final Product Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "skip_material_transfer",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Skip Material Transfer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"depends_on": "eval:doc.skip_material_transfer",
|
||||||
|
"fieldname": "backflush_from_wip_warehouse",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Backflush Materials From WIP Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_buha",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-sitemap",
|
"icon": "fa fa-sitemap",
|
||||||
@@ -288,7 +403,7 @@
|
|||||||
"link_fieldname": "bom_creator"
|
"link_fieldname": "bom_creator"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2024-04-02 16:30:59.779190",
|
"modified": "2024-05-26 15:47:10.101420",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "BOM Creator",
|
"name": "BOM Creator",
|
||||||
|
|||||||
@@ -43,16 +43,20 @@ class BOMCreator(Document):
|
|||||||
from erpnext.manufacturing.doctype.bom_creator_item.bom_creator_item import BOMCreatorItem
|
from erpnext.manufacturing.doctype.bom_creator_item.bom_creator_item import BOMCreatorItem
|
||||||
|
|
||||||
amended_from: DF.Link | None
|
amended_from: DF.Link | None
|
||||||
|
backflush_from_wip_warehouse: DF.Check
|
||||||
buying_price_list: DF.Link | None
|
buying_price_list: DF.Link | None
|
||||||
company: DF.Link
|
company: DF.Link
|
||||||
conversion_rate: DF.Float
|
conversion_rate: DF.Float
|
||||||
currency: DF.Link
|
currency: DF.Link
|
||||||
default_warehouse: DF.Link | None
|
default_warehouse: DF.Link | None
|
||||||
error_log: DF.Text | None
|
error_log: DF.Text | None
|
||||||
|
fg_warehouse: DF.Link | None
|
||||||
item_code: DF.Link
|
item_code: DF.Link
|
||||||
item_group: DF.Link | None
|
item_group: DF.Link | None
|
||||||
item_name: DF.Data | None
|
item_name: DF.Data | None
|
||||||
items: DF.Table[BOMCreatorItem]
|
items: DF.Table[BOMCreatorItem]
|
||||||
|
operation: DF.Link | None
|
||||||
|
operation_time: DF.Float
|
||||||
plc_conversion_rate: DF.Float
|
plc_conversion_rate: DF.Float
|
||||||
price_list_currency: DF.Link | None
|
price_list_currency: DF.Link | None
|
||||||
project: DF.Link | None
|
project: DF.Link | None
|
||||||
@@ -61,8 +65,15 @@ class BOMCreator(Document):
|
|||||||
remarks: DF.TextEditor | None
|
remarks: DF.TextEditor | None
|
||||||
rm_cost_as_per: DF.Literal["Valuation Rate", "Last Purchase Rate", "Price List"]
|
rm_cost_as_per: DF.Literal["Valuation Rate", "Last Purchase Rate", "Price List"]
|
||||||
set_rate_based_on_warehouse: DF.Check
|
set_rate_based_on_warehouse: DF.Check
|
||||||
|
skip_material_transfer: DF.Check
|
||||||
|
source_warehouse: DF.Link | None
|
||||||
status: DF.Literal["Draft", "Submitted", "In Progress", "Completed", "Failed", "Cancelled"]
|
status: DF.Literal["Draft", "Submitted", "In Progress", "Completed", "Failed", "Cancelled"]
|
||||||
|
track_operations: DF.Check
|
||||||
|
track_semi_finished_goods: DF.Check
|
||||||
uom: DF.Link | None
|
uom: DF.Link | None
|
||||||
|
wip_warehouse: DF.Link | None
|
||||||
|
workstation: DF.Link | None
|
||||||
|
workstation_type: DF.Link | None
|
||||||
# end: auto-generated types
|
# end: auto-generated types
|
||||||
|
|
||||||
def before_save(self):
|
def before_save(self):
|
||||||
@@ -236,8 +247,10 @@ class BOMCreator(Document):
|
|||||||
|
|
||||||
self.db_set("status", "In Progress")
|
self.db_set("status", "In Progress")
|
||||||
production_item_wise_rm = OrderedDict({})
|
production_item_wise_rm = OrderedDict({})
|
||||||
|
|
||||||
|
final_product = (self.item_code, self.name)
|
||||||
production_item_wise_rm.setdefault(
|
production_item_wise_rm.setdefault(
|
||||||
(self.item_code, self.name), frappe._dict({"items": [], "bom_no": "", "fg_item_data": self})
|
final_product, frappe._dict({"items": [], "bom_no": "", "fg_item_data": self})
|
||||||
)
|
)
|
||||||
|
|
||||||
for row in self.items:
|
for row in self.items:
|
||||||
@@ -257,9 +270,15 @@ class BOMCreator(Document):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
for d in reverse_tree:
|
for d in reverse_tree:
|
||||||
|
if self.track_operations and self.track_semi_finished_goods and final_product == d:
|
||||||
|
continue
|
||||||
|
|
||||||
fg_item_data = production_item_wise_rm.get(d).fg_item_data
|
fg_item_data = production_item_wise_rm.get(d).fg_item_data
|
||||||
self.create_bom(fg_item_data, production_item_wise_rm)
|
self.create_bom(fg_item_data, production_item_wise_rm)
|
||||||
|
|
||||||
|
if self.track_operations and self.track_semi_finished_goods:
|
||||||
|
self.make_bom_for_final_product(production_item_wise_rm)
|
||||||
|
|
||||||
frappe.msgprint(_("BOMs created successfully"))
|
frappe.msgprint(_("BOMs created successfully"))
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback = frappe.get_traceback(with_context=True)
|
traceback = frappe.get_traceback(with_context=True)
|
||||||
@@ -272,6 +291,81 @@ class BOMCreator(Document):
|
|||||||
|
|
||||||
frappe.msgprint(_("BOMs creation failed"))
|
frappe.msgprint(_("BOMs creation failed"))
|
||||||
|
|
||||||
|
def make_bom_for_final_product(self, production_item_wise_rm):
|
||||||
|
bom = frappe.new_doc("BOM")
|
||||||
|
bom.update(
|
||||||
|
{
|
||||||
|
"item": self.item_code,
|
||||||
|
"bom_type": "Production",
|
||||||
|
"quantity": self.qty,
|
||||||
|
"allow_alternative_item": 1,
|
||||||
|
"bom_creator": self.name,
|
||||||
|
"bom_creator_item": self.name,
|
||||||
|
"rm_cost_as_per": "Manual",
|
||||||
|
"with_operations": 1,
|
||||||
|
"track_semi_finished_goods": 1,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
for field in BOM_FIELDS:
|
||||||
|
if self.get(field):
|
||||||
|
bom.set(field, self.get(field))
|
||||||
|
|
||||||
|
for item in self.items:
|
||||||
|
if not item.is_expandable or not item.operation:
|
||||||
|
continue
|
||||||
|
|
||||||
|
bom.append(
|
||||||
|
"operations",
|
||||||
|
{
|
||||||
|
"operation": item.operation,
|
||||||
|
"workstation": item.workstation,
|
||||||
|
"source_warehouse": item.source_warehouse,
|
||||||
|
"wip_warehouse": item.wip_warehouse,
|
||||||
|
"fg_warehouse": item.fg_warehouse,
|
||||||
|
"finished_good": item.item_code,
|
||||||
|
"finished_good_qty": item.qty,
|
||||||
|
"bom_no": production_item_wise_rm[(item.item_code, item.name)].bom_no,
|
||||||
|
"workstation_type": item.workstation_type,
|
||||||
|
"time_in_mins": item.operation_time,
|
||||||
|
"is_subcontracted": item.is_subcontracted,
|
||||||
|
"skip_material_transfer": item.skip_material_transfer,
|
||||||
|
"backflush_from_wip_warehouse": item.backflush_from_wip_warehouse,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
operation_row = bom.append(
|
||||||
|
"operations",
|
||||||
|
{
|
||||||
|
"operation": self.operation,
|
||||||
|
"time_in_mins": self.operation_time,
|
||||||
|
"workstation": self.workstation,
|
||||||
|
"workstation_type": self.workstation_type,
|
||||||
|
"finished_good": self.item_code,
|
||||||
|
"finished_good_qty": self.qty,
|
||||||
|
"source_warehouse": self.source_warehouse,
|
||||||
|
"wip_warehouse": self.wip_warehouse,
|
||||||
|
"fg_warehouse": self.fg_warehouse,
|
||||||
|
"skip_material_transfer": self.skip_material_transfer,
|
||||||
|
"backflush_from_wip_warehouse": self.backflush_from_wip_warehouse,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
final_product = (self.item_code, self.name)
|
||||||
|
items = production_item_wise_rm.get(final_product).get("items")
|
||||||
|
|
||||||
|
bom.set_materials_based_on_operation_bom()
|
||||||
|
|
||||||
|
for item in items:
|
||||||
|
item_args = {"operation_row_id": operation_row.idx}
|
||||||
|
for field in BOM_ITEM_FIELDS:
|
||||||
|
item_args[field] = item.get(field)
|
||||||
|
|
||||||
|
bom.append("items", item_args)
|
||||||
|
|
||||||
|
bom.save(ignore_permissions=True)
|
||||||
|
bom.submit()
|
||||||
|
|
||||||
def create_bom(self, row, production_item_wise_rm):
|
def create_bom(self, row, production_item_wise_rm):
|
||||||
bom_creator_item = row.name if row.name != self.name else ""
|
bom_creator_item = row.name if row.name != self.name else ""
|
||||||
if frappe.db.exists(
|
if frappe.db.exists(
|
||||||
@@ -297,6 +391,24 @@ class BOMCreator(Document):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if self.track_operations and not self.track_semi_finished_goods:
|
||||||
|
if row.item_code == self.item_code:
|
||||||
|
bom.with_operations = 1
|
||||||
|
bom.transfer_material_against = "Work Order"
|
||||||
|
for item in self.items:
|
||||||
|
if not item.operation:
|
||||||
|
continue
|
||||||
|
|
||||||
|
bom.append(
|
||||||
|
"operations",
|
||||||
|
{
|
||||||
|
"operation": item.operation,
|
||||||
|
"workstation_type": item.workstation_type,
|
||||||
|
"workstation": item.workstation,
|
||||||
|
"time_in_mins": item.operation_time,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
for field in BOM_FIELDS:
|
for field in BOM_FIELDS:
|
||||||
if self.get(field):
|
if self.get(field):
|
||||||
bom.set(field, self.get(field))
|
bom.set(field, self.get(field))
|
||||||
@@ -352,6 +464,16 @@ def get_children(doctype=None, parent=None, **kwargs):
|
|||||||
"uom",
|
"uom",
|
||||||
"rate",
|
"rate",
|
||||||
"amount",
|
"amount",
|
||||||
|
"workstation_type",
|
||||||
|
"operation",
|
||||||
|
"operation_time",
|
||||||
|
"is_subcontracted",
|
||||||
|
"workstation",
|
||||||
|
"source_warehouse",
|
||||||
|
"wip_warehouse",
|
||||||
|
"fg_warehouse",
|
||||||
|
"skip_material_transfer",
|
||||||
|
"backflush_from_wip_warehouse",
|
||||||
]
|
]
|
||||||
|
|
||||||
query_filters = {
|
query_filters = {
|
||||||
@@ -365,6 +487,12 @@ def get_children(doctype=None, parent=None, **kwargs):
|
|||||||
return frappe.get_all("BOM Creator Item", fields=fields, filters=query_filters, order_by="idx")
|
return frappe.get_all("BOM Creator Item", fields=fields, filters=query_filters, order_by="idx")
|
||||||
|
|
||||||
|
|
||||||
|
def get_parent_row_no(doc, name):
|
||||||
|
for row in doc.items:
|
||||||
|
if row.name == name:
|
||||||
|
return row.idx
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def add_item(**kwargs):
|
def add_item(**kwargs):
|
||||||
if isinstance(kwargs, str):
|
if isinstance(kwargs, str):
|
||||||
@@ -375,6 +503,11 @@ def add_item(**kwargs):
|
|||||||
|
|
||||||
doc = frappe.get_doc("BOM Creator", kwargs.parent)
|
doc = frappe.get_doc("BOM Creator", kwargs.parent)
|
||||||
item_info = get_item_details(kwargs.item_code)
|
item_info = get_item_details(kwargs.item_code)
|
||||||
|
|
||||||
|
parent_row_no = ""
|
||||||
|
if kwargs.fg_reference_id and doc.name != kwargs.fg_reference_id:
|
||||||
|
parent_row_no = get_parent_row_no(doc, kwargs.fg_reference_id)
|
||||||
|
|
||||||
kwargs.update(
|
kwargs.update(
|
||||||
{
|
{
|
||||||
"uom": item_info.stock_uom,
|
"uom": item_info.stock_uom,
|
||||||
@@ -383,6 +516,9 @@ def add_item(**kwargs):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if parent_row_no:
|
||||||
|
kwargs.update({"parent_row_no": parent_row_no})
|
||||||
|
|
||||||
doc.append("items", kwargs)
|
doc.append("items", kwargs)
|
||||||
doc.save()
|
doc.save()
|
||||||
|
|
||||||
@@ -402,6 +538,7 @@ def add_sub_assembly(**kwargs):
|
|||||||
|
|
||||||
name = kwargs.fg_reference_id
|
name = kwargs.fg_reference_id
|
||||||
parent_row_no = ""
|
parent_row_no = ""
|
||||||
|
|
||||||
if not kwargs.convert_to_sub_assembly:
|
if not kwargs.convert_to_sub_assembly:
|
||||||
item_info = get_item_details(bom_item.item_code)
|
item_info = get_item_details(bom_item.item_code)
|
||||||
item_row = doc.append(
|
item_row = doc.append(
|
||||||
@@ -417,6 +554,14 @@ def add_sub_assembly(**kwargs):
|
|||||||
"do_not_explode": 1,
|
"do_not_explode": 1,
|
||||||
"is_expandable": 1,
|
"is_expandable": 1,
|
||||||
"stock_uom": item_info.stock_uom,
|
"stock_uom": item_info.stock_uom,
|
||||||
|
"operation": bom_item.operation,
|
||||||
|
"workstation_type": bom_item.workstation_type,
|
||||||
|
"operation_time": bom_item.operation_time,
|
||||||
|
"is_subcontracted": bom_item.is_subcontracted,
|
||||||
|
"workstation": bom_item.workstation,
|
||||||
|
"source_warehouse": bom_item.source_warehouse,
|
||||||
|
"wip_warehouse": bom_item.wip_warehouse,
|
||||||
|
"fg_warehouse": bom_item.fg_warehouse,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -426,6 +571,20 @@ def add_sub_assembly(**kwargs):
|
|||||||
parent_row_no = [row.idx for row in doc.items if row.name == kwargs.fg_reference_id]
|
parent_row_no = [row.idx for row in doc.items if row.name == kwargs.fg_reference_id]
|
||||||
if parent_row_no:
|
if parent_row_no:
|
||||||
parent_row_no = parent_row_no[0]
|
parent_row_no = parent_row_no[0]
|
||||||
|
doc.items[parent_row_no - 1].update(
|
||||||
|
{
|
||||||
|
"operation": bom_item.operation,
|
||||||
|
"workstation_type": bom_item.workstation_type,
|
||||||
|
"operation_time": bom_item.operation_time,
|
||||||
|
"is_subcontracted": bom_item.is_subcontracted,
|
||||||
|
"workstation": bom_item.workstation,
|
||||||
|
"source_warehouse": bom_item.source_warehouse,
|
||||||
|
"wip_warehouse": bom_item.wip_warehouse,
|
||||||
|
"fg_warehouse": bom_item.fg_warehouse,
|
||||||
|
"skip_material_transfer": bom_item.skip_material_transfer,
|
||||||
|
"backflush_from_wip_warehouse": bom_item.backflush_from_wip_warehouse,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
for row in bom_item.get("items"):
|
for row in bom_item.get("items"):
|
||||||
row = frappe._dict(row)
|
row = frappe._dict(row)
|
||||||
@@ -482,10 +641,16 @@ def delete_node(**kwargs):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def edit_qty(doctype, docname, qty, parent):
|
def edit_bom_creator(doctype, docname, data, parent):
|
||||||
frappe.db.set_value(doctype, docname, "qty", qty)
|
if isinstance(data, str):
|
||||||
|
data = frappe.parse_json(data)
|
||||||
|
|
||||||
|
frappe.db.set_value(doctype, docname, data)
|
||||||
|
|
||||||
doc = frappe.get_doc("BOM Creator", parent)
|
doc = frappe.get_doc("BOM Creator", parent)
|
||||||
doc.set_rate_for_items()
|
doc.set_rate_for_items()
|
||||||
doc.save()
|
doc.save()
|
||||||
|
|
||||||
|
frappe.msgprint(_("Updated successfully"), alert=True)
|
||||||
|
|
||||||
return doc
|
return doc
|
||||||
|
|||||||
@@ -11,10 +11,23 @@
|
|||||||
"item_group",
|
"item_group",
|
||||||
"column_break_f63f",
|
"column_break_f63f",
|
||||||
"fg_item",
|
"fg_item",
|
||||||
"source_warehouse",
|
|
||||||
"is_expandable",
|
"is_expandable",
|
||||||
"sourced_by_supplier",
|
"sourced_by_supplier",
|
||||||
"bom_created",
|
"bom_created",
|
||||||
|
"is_subcontracted",
|
||||||
|
"operation_section",
|
||||||
|
"operation",
|
||||||
|
"operation_time",
|
||||||
|
"column_break_cbnk",
|
||||||
|
"workstation_type",
|
||||||
|
"workstation",
|
||||||
|
"warehouse_section",
|
||||||
|
"skip_material_transfer",
|
||||||
|
"backflush_from_wip_warehouse",
|
||||||
|
"source_warehouse",
|
||||||
|
"column_break_xutc",
|
||||||
|
"wip_warehouse",
|
||||||
|
"fg_warehouse",
|
||||||
"description_section",
|
"description_section",
|
||||||
"description",
|
"description",
|
||||||
"quantity_and_rate_section",
|
"quantity_and_rate_section",
|
||||||
@@ -75,16 +88,18 @@
|
|||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"depends_on": "eval:doc.skip_material_transfer && !doc.backflush_from_wip_warehouse",
|
||||||
"fieldname": "source_warehouse",
|
"fieldname": "source_warehouse",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Source Warehouse",
|
"label": "Source Warehouse",
|
||||||
"options": "Warehouse"
|
"options": "Warehouse"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"columns": 1,
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"fieldname": "is_expandable",
|
"fieldname": "is_expandable",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Is Expandable",
|
"label": "Is Expandable",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
@@ -225,12 +240,87 @@
|
|||||||
"label": "BOM Created",
|
"label": "BOM Created",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"print_hide": 1
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "operation_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Operation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "operation",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Operation",
|
||||||
|
"options": "Operation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_cbnk",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "workstation_type",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Workstation Type",
|
||||||
|
"options": "Workstation Type"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "In Mins",
|
||||||
|
"fieldname": "operation_time",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "Operation Time"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "workstation",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Workstation",
|
||||||
|
"options": "Workstation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "warehouse_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:!doc.skip_material_transfer || doc.backflush_from_wip_warehouse",
|
||||||
|
"fieldname": "wip_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Work In Progress Warehouse",
|
||||||
|
"options": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_xutc",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "fg_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Finished Good Warehouse",
|
||||||
|
"options": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "skip_material_transfer",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Skip Material Transfer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"depends_on": "eval:doc.skip_material_transfer",
|
||||||
|
"fieldname": "backflush_from_wip_warehouse",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Backflush Materials From WIP Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "is_subcontracted",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Is Subcontracted",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-27 13:06:40.764747",
|
"modified": "2024-06-01 18:45:24.339532",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "BOM Creator Item",
|
"name": "BOM Creator Item",
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class BOMCreatorItem(Document):
|
|||||||
from frappe.types import DF
|
from frappe.types import DF
|
||||||
|
|
||||||
amount: DF.Currency
|
amount: DF.Currency
|
||||||
|
backflush_from_wip_warehouse: DF.Check
|
||||||
base_amount: DF.Currency
|
base_amount: DF.Currency
|
||||||
base_rate: DF.Currency
|
base_rate: DF.Currency
|
||||||
bom_created: DF.Check
|
bom_created: DF.Check
|
||||||
@@ -23,22 +24,30 @@ class BOMCreatorItem(Document):
|
|||||||
do_not_explode: DF.Check
|
do_not_explode: DF.Check
|
||||||
fg_item: DF.Link
|
fg_item: DF.Link
|
||||||
fg_reference_id: DF.Data | None
|
fg_reference_id: DF.Data | None
|
||||||
|
fg_warehouse: DF.Link | None
|
||||||
instruction: DF.SmallText | None
|
instruction: DF.SmallText | None
|
||||||
is_expandable: DF.Check
|
is_expandable: DF.Check
|
||||||
|
is_subcontracted: DF.Check
|
||||||
item_code: DF.Link
|
item_code: DF.Link
|
||||||
item_group: DF.Link | None
|
item_group: DF.Link | None
|
||||||
item_name: DF.Data | None
|
item_name: DF.Data | None
|
||||||
|
operation: DF.Link | None
|
||||||
|
operation_time: DF.Int
|
||||||
parent: DF.Data
|
parent: DF.Data
|
||||||
parent_row_no: DF.Data | None
|
parent_row_no: DF.Data | None
|
||||||
parentfield: DF.Data
|
parentfield: DF.Data
|
||||||
parenttype: DF.Data
|
parenttype: DF.Data
|
||||||
qty: DF.Float
|
qty: DF.Float
|
||||||
rate: DF.Currency
|
rate: DF.Currency
|
||||||
|
skip_material_transfer: DF.Check
|
||||||
source_warehouse: DF.Link | None
|
source_warehouse: DF.Link | None
|
||||||
sourced_by_supplier: DF.Check
|
sourced_by_supplier: DF.Check
|
||||||
stock_qty: DF.Float
|
stock_qty: DF.Float
|
||||||
stock_uom: DF.Link | None
|
stock_uom: DF.Link | None
|
||||||
uom: DF.Link | None
|
uom: DF.Link | None
|
||||||
|
wip_warehouse: DF.Link | None
|
||||||
|
workstation: DF.Link | None
|
||||||
|
workstation_type: DF.Link | None
|
||||||
# end: auto-generated types
|
# end: auto-generated types
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"item_code",
|
"item_code",
|
||||||
"item_name",
|
"item_name",
|
||||||
"operation",
|
"operation",
|
||||||
|
"operation_row_id",
|
||||||
"column_break_3",
|
"column_break_3",
|
||||||
"do_not_explode",
|
"do_not_explode",
|
||||||
"bom_no",
|
"bom_no",
|
||||||
@@ -293,13 +294,19 @@
|
|||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Is Stock Item",
|
"label": "Is Stock Item",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:parent.track_semi_finished_goods ==1",
|
||||||
|
"fieldname": "operation_row_id",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "Operation ID"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-27 13:06:41.079752",
|
"modified": "2024-03-27 13:08:41.079752",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "BOM Item",
|
"name": "BOM Item",
|
||||||
|
|||||||
@@ -25,9 +25,11 @@ class BOMItem(Document):
|
|||||||
has_variants: DF.Check
|
has_variants: DF.Check
|
||||||
image: DF.Attach | None
|
image: DF.Attach | None
|
||||||
include_item_in_manufacturing: DF.Check
|
include_item_in_manufacturing: DF.Check
|
||||||
|
is_stock_item: DF.Check
|
||||||
item_code: DF.Link
|
item_code: DF.Link
|
||||||
item_name: DF.Data | None
|
item_name: DF.Data | None
|
||||||
operation: DF.Link | None
|
operation: DF.Link | None
|
||||||
|
operation_row_id: DF.Int
|
||||||
original_item: DF.Link | None
|
original_item: DF.Link | None
|
||||||
parent: DF.Data
|
parent: DF.Data
|
||||||
parentfield: DF.Data
|
parentfield: DF.Data
|
||||||
|
|||||||
@@ -6,24 +6,36 @@
|
|||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"sequence_id",
|
|
||||||
"operation",
|
"operation",
|
||||||
|
"sequence_id",
|
||||||
|
"finished_good",
|
||||||
|
"finished_good_qty",
|
||||||
|
"bom_no",
|
||||||
|
"add_raw_materials",
|
||||||
"col_break1",
|
"col_break1",
|
||||||
"workstation_type",
|
"workstation_type",
|
||||||
"workstation",
|
"workstation",
|
||||||
"time_in_mins",
|
"time_in_mins",
|
||||||
"fixed_time",
|
"fixed_time",
|
||||||
|
"is_subcontracted",
|
||||||
|
"is_final_finished_good",
|
||||||
|
"set_cost_based_on_bom_qty",
|
||||||
|
"warehouse_section",
|
||||||
|
"skip_material_transfer",
|
||||||
|
"backflush_from_wip_warehouse",
|
||||||
|
"source_warehouse",
|
||||||
|
"column_break_lbhy",
|
||||||
|
"wip_warehouse",
|
||||||
|
"fg_warehouse",
|
||||||
"costing_section",
|
"costing_section",
|
||||||
"hour_rate",
|
"hour_rate",
|
||||||
"base_hour_rate",
|
"base_hour_rate",
|
||||||
"column_break_9",
|
|
||||||
"operating_cost",
|
|
||||||
"base_operating_cost",
|
|
||||||
"column_break_11",
|
|
||||||
"batch_size",
|
"batch_size",
|
||||||
"set_cost_based_on_bom_qty",
|
"column_break_11",
|
||||||
"cost_per_unit",
|
"cost_per_unit",
|
||||||
"base_cost_per_unit",
|
"base_cost_per_unit",
|
||||||
|
"operating_cost",
|
||||||
|
"base_operating_cost",
|
||||||
"more_information_section",
|
"more_information_section",
|
||||||
"description",
|
"description",
|
||||||
"column_break_18",
|
"column_break_18",
|
||||||
@@ -71,6 +83,7 @@
|
|||||||
"precision": "2"
|
"precision": "2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"columns": 1,
|
||||||
"description": "In minutes",
|
"description": "In minutes",
|
||||||
"fetch_from": "operation.total_operation_time",
|
"fetch_from": "operation.total_operation_time",
|
||||||
"fetch_if_empty": 1,
|
"fetch_if_empty": 1,
|
||||||
@@ -87,7 +100,6 @@
|
|||||||
"description": "Operation time does not depend on quantity to produce",
|
"description": "Operation time does not depend on quantity to produce",
|
||||||
"fieldname": "fixed_time",
|
"fieldname": "fixed_time",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Fixed Time"
|
"label": "Fixed Time"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -172,10 +184,6 @@
|
|||||||
"fieldname": "column_break_18",
|
"fieldname": "column_break_18",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "column_break_9",
|
|
||||||
"fieldtype": "Column Break"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"fieldname": "set_cost_based_on_bom_qty",
|
"fieldname": "set_cost_based_on_bom_qty",
|
||||||
@@ -183,18 +191,106 @@
|
|||||||
"label": "Set Operating Cost Based On BOM Quantity"
|
"label": "Set Operating Cost Based On BOM Quantity"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"columns": 1,
|
||||||
"fieldname": "workstation_type",
|
"fieldname": "workstation_type",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Workstation Type",
|
"label": "Workstation Type",
|
||||||
"options": "Workstation Type"
|
"options": "Workstation Type"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "finished_good",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "FG / Semi FG Item",
|
||||||
|
"options": "Item"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 1,
|
||||||
|
"fieldname": "bom_no",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "BOM No",
|
||||||
|
"options": "BOM"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 1,
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "finished_good_qty",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "FG Qty"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "is_final_finished_good",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Is Final Finished Good"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "warehouse_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:!doc.skip_material_transfer || doc.backflush_from_wip_warehouse",
|
||||||
|
"fieldname": "wip_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "WIP WH",
|
||||||
|
"options": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_lbhy",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 1,
|
||||||
|
"fieldname": "fg_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "FG WH",
|
||||||
|
"options": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 1,
|
||||||
|
"depends_on": "eval:doc.skip_material_transfer && !doc.backflush_from_wip_warehouse",
|
||||||
|
"fieldname": "source_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Source WH",
|
||||||
|
"options": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "is_subcontracted",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Is Subcontracted"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:!doc.bom_no",
|
||||||
|
"fieldname": "add_raw_materials",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"label": "Add Raw Materials"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "skip_material_transfer",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": " Skip Material Transfer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"depends_on": "eval:doc.skip_material_transfer",
|
||||||
|
"fieldname": "backflush_from_wip_warehouse",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Backflush Materials From WIP Warehouse"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-27 13:06:41.248462",
|
"modified": "2024-05-26 15:46:49.404875",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "BOM Operation",
|
"name": "BOM Operation",
|
||||||
|
|||||||
@@ -14,15 +14,22 @@ class BOMOperation(Document):
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from frappe.types import DF
|
from frappe.types import DF
|
||||||
|
|
||||||
|
backflush_from_wip_warehouse: DF.Check
|
||||||
base_cost_per_unit: DF.Float
|
base_cost_per_unit: DF.Float
|
||||||
base_hour_rate: DF.Currency
|
base_hour_rate: DF.Currency
|
||||||
base_operating_cost: DF.Currency
|
base_operating_cost: DF.Currency
|
||||||
batch_size: DF.Int
|
batch_size: DF.Int
|
||||||
|
bom_no: DF.Link | None
|
||||||
cost_per_unit: DF.Float
|
cost_per_unit: DF.Float
|
||||||
description: DF.TextEditor | None
|
description: DF.TextEditor | None
|
||||||
|
fg_warehouse: DF.Link | None
|
||||||
|
finished_good: DF.Link | None
|
||||||
|
finished_good_qty: DF.Float
|
||||||
fixed_time: DF.Check
|
fixed_time: DF.Check
|
||||||
hour_rate: DF.Currency
|
hour_rate: DF.Currency
|
||||||
image: DF.Attach | None
|
image: DF.Attach | None
|
||||||
|
is_final_finished_good: DF.Check
|
||||||
|
is_subcontracted: DF.Check
|
||||||
operating_cost: DF.Currency
|
operating_cost: DF.Currency
|
||||||
operation: DF.Link
|
operation: DF.Link
|
||||||
parent: DF.Data
|
parent: DF.Data
|
||||||
@@ -30,7 +37,10 @@ class BOMOperation(Document):
|
|||||||
parenttype: DF.Data
|
parenttype: DF.Data
|
||||||
sequence_id: DF.Int
|
sequence_id: DF.Int
|
||||||
set_cost_based_on_bom_qty: DF.Check
|
set_cost_based_on_bom_qty: DF.Check
|
||||||
|
skip_material_transfer: DF.Check
|
||||||
|
source_warehouse: DF.Link | None
|
||||||
time_in_mins: DF.Float
|
time_in_mins: DF.Float
|
||||||
|
wip_warehouse: DF.Link | None
|
||||||
workstation: DF.Link | None
|
workstation: DF.Link | None
|
||||||
workstation_type: DF.Link | None
|
workstation_type: DF.Link | None
|
||||||
# end: auto-generated types
|
# end: auto-generated types
|
||||||
|
|||||||
@@ -32,21 +32,61 @@ frappe.ui.form.on("Job Card", {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
make_fields_read_only(frm) {
|
||||||
|
if (frm.doc.docstatus === 1) {
|
||||||
|
frm.set_df_property("employee", "read_only", 1);
|
||||||
|
frm.set_df_property("time_logs", "read_only", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frm.doc.is_subcontracted) {
|
||||||
|
frm.set_df_property("wip_warehouse", "label", __("Supplier Warehouse"));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setup_stock_entry(frm) {
|
||||||
|
if (
|
||||||
|
frm.doc.finished_good &&
|
||||||
|
frm.doc.docstatus === 1 &&
|
||||||
|
!frm.doc.is_subcontracted &&
|
||||||
|
flt(frm.doc.for_quantity) + flt(frm.doc.process_loss_qty) > flt(frm.doc.manufactured_qty)
|
||||||
|
) {
|
||||||
|
frm.add_custom_button(__("Make Stock Entry"), () => {
|
||||||
|
frm.call({
|
||||||
|
method: "make_stock_entry_for_semi_fg_item",
|
||||||
|
args: {
|
||||||
|
auto_submit: 1,
|
||||||
|
},
|
||||||
|
doc: frm.doc,
|
||||||
|
freeze: true,
|
||||||
|
callback() {
|
||||||
|
frm.reload_doc();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}).addClass("btn-primary");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
refresh: function (frm) {
|
refresh: function (frm) {
|
||||||
frappe.flags.pause_job = 0;
|
frm.trigger("setup_stock_entry");
|
||||||
frappe.flags.resume_job = 0;
|
|
||||||
let has_items = frm.doc.items && frm.doc.items.length;
|
let has_items = frm.doc.items && frm.doc.items.length;
|
||||||
|
frm.trigger("make_fields_read_only");
|
||||||
|
|
||||||
if (!frm.is_new() && frm.doc.__onload.work_order_closed) {
|
if (!frm.is_new() && frm.doc.__onload.work_order_closed) {
|
||||||
frm.disable_save();
|
frm.disable_save();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (frm.doc.is_subcontracted) {
|
||||||
|
frm.trigger("make_subcontracting_po");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let has_stock_entry = frm.doc.__onload && frm.doc.__onload.has_stock_entry ? true : false;
|
let has_stock_entry = frm.doc.__onload && frm.doc.__onload.has_stock_entry ? true : false;
|
||||||
|
|
||||||
frm.toggle_enable("for_quantity", !has_stock_entry);
|
frm.toggle_enable("for_quantity", !has_stock_entry);
|
||||||
|
|
||||||
if (!frm.is_new() && has_items && frm.doc.docstatus < 2) {
|
if (!frm.is_new() && !frm.doc.skip_material_transfer && has_items && frm.doc.docstatus < 2) {
|
||||||
let to_request = frm.doc.for_quantity > frm.doc.transferred_qty;
|
let to_request = frm.doc.for_quantity > frm.doc.transferred_qty;
|
||||||
let excess_transfer_allowed = frm.doc.__onload.job_card_excess_transfer;
|
let excess_transfer_allowed = frm.doc.__onload.job_card_excess_transfer;
|
||||||
|
|
||||||
@@ -63,11 +103,11 @@ frappe.ui.form.on("Job Card", {
|
|||||||
if (to_transfer || excess_transfer_allowed) {
|
if (to_transfer || excess_transfer_allowed) {
|
||||||
frm.add_custom_button(__("Material Transfer"), () => {
|
frm.add_custom_button(__("Material Transfer"), () => {
|
||||||
frm.trigger("make_stock_entry");
|
frm.trigger("make_stock_entry");
|
||||||
}).addClass("btn-primary");
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frm.doc.docstatus == 1 && !frm.doc.is_corrective_job_card) {
|
if (frm.doc.docstatus == 1 && !frm.doc.is_corrective_job_card && !frm.doc.finished_good) {
|
||||||
frm.trigger("setup_corrective_job_card");
|
frm.trigger("setup_corrective_job_card");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,31 +124,67 @@ frappe.ui.form.on("Job Card", {
|
|||||||
frm.trigger("toggle_operation_number");
|
frm.trigger("toggle_operation_number");
|
||||||
|
|
||||||
if (
|
if (
|
||||||
frm.doc.docstatus == 0 &&
|
frm.doc.for_quantity + frm.doc.process_loss_qty > frm.doc.total_completed_qty &&
|
||||||
!frm.is_new() &&
|
(frm.doc.skip_material_transfer ||
|
||||||
(frm.doc.for_quantity > frm.doc.total_completed_qty || !frm.doc.for_quantity) &&
|
frm.doc.transferred_qty >= frm.doc.for_quantity + frm.doc.process_loss_qty ||
|
||||||
(frm.doc.items || !frm.doc.items.length || frm.doc.for_quantity == frm.doc.transferred_qty)
|
!frm.doc.finished_good)
|
||||||
) {
|
) {
|
||||||
// if Job Card is link to Work Order, the job card must not be able to start if Work Order not "Started"
|
if (!frm.doc.time_logs?.length) {
|
||||||
// and if stock mvt for WIP is required
|
frm.add_custom_button(__("Start Job"), () => {
|
||||||
if (frm.doc.work_order) {
|
let from_time = frappe.datetime.now_datetime();
|
||||||
frappe.db.get_value(
|
if ((frm.doc.employee && !frm.doc.employee.length) || !frm.doc.employee) {
|
||||||
"Work Order",
|
frappe.prompt(
|
||||||
frm.doc.work_order,
|
{
|
||||||
["skip_transfer", "status"],
|
fieldtype: "Table MultiSelect",
|
||||||
(result) => {
|
label: __("Select Employees"),
|
||||||
if (
|
options: "Job Card Time Log",
|
||||||
result.skip_transfer === 1 ||
|
fieldname: "employees",
|
||||||
result.status == "In Process" ||
|
},
|
||||||
frm.doc.transferred_qty > 0 ||
|
(d) => {
|
||||||
!frm.doc.items.length
|
frm.events.start_timer(frm, from_time, d.employees);
|
||||||
) {
|
},
|
||||||
frm.trigger("prepare_timer_buttons");
|
__("Assign Job to Employee")
|
||||||
}
|
);
|
||||||
|
} else {
|
||||||
|
frm.events.start_timer(frm, from_time, frm.doc.employee);
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
|
} else if (frm.doc.is_paused) {
|
||||||
|
frm.add_custom_button(__("Resume Job"), () => {
|
||||||
|
frm.call({
|
||||||
|
method: "resume_job",
|
||||||
|
doc: frm.doc,
|
||||||
|
args: {
|
||||||
|
start_time: frappe.datetime.now_datetime(),
|
||||||
|
},
|
||||||
|
callback() {
|
||||||
|
frm.reload_doc();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
frm.trigger("prepare_timer_buttons");
|
if (frm.doc.for_quantity - frm.doc.manufactured_qty > 0) {
|
||||||
|
if (!frm.doc.is_paused) {
|
||||||
|
frm.add_custom_button(__("Pause Job"), () => {
|
||||||
|
frm.call({
|
||||||
|
method: "pause_job",
|
||||||
|
doc: frm.doc,
|
||||||
|
args: {
|
||||||
|
end_time: frappe.datetime.now_datetime(),
|
||||||
|
},
|
||||||
|
callback() {
|
||||||
|
frm.reload_doc();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
frm.add_custom_button(__("Complete Job"), () => {
|
||||||
|
frm.trigger("complete_job_card");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
frm.trigger("make_dashboard");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +192,7 @@ frappe.ui.form.on("Job Card", {
|
|||||||
|
|
||||||
if (frm.doc.work_order) {
|
if (frm.doc.work_order) {
|
||||||
frappe.db.get_value("Work Order", frm.doc.work_order, "transfer_material_against").then((r) => {
|
frappe.db.get_value("Work Order", frm.doc.work_order, "transfer_material_against").then((r) => {
|
||||||
if (r.message.transfer_material_against == "Work Order") {
|
if (r.message.transfer_material_against == "Work Order" && !frm.doc.operation_row_id) {
|
||||||
frm.set_df_property("items", "hidden", 1);
|
frm.set_df_property("items", "hidden", 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -134,6 +210,75 @@ frappe.ui.form.on("Job Card", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
make_subcontracting_po(frm) {
|
||||||
|
if (frm.doc.docstatus === 1 && frm.doc.for_quantity > frm.doc.manufactured_qty) {
|
||||||
|
frm.add_custom_button(__("Make Subcontracting PO"), () => {
|
||||||
|
frappe.model.open_mapped_doc({
|
||||||
|
method: "erpnext.manufacturing.doctype.job_card.job_card.make_subcontracting_po",
|
||||||
|
frm: frm,
|
||||||
|
});
|
||||||
|
}).addClass("btn-primary");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
start_timer(frm, start_time, employees) {
|
||||||
|
frm.call({
|
||||||
|
method: "start_timer",
|
||||||
|
doc: frm.doc,
|
||||||
|
args: {
|
||||||
|
start_time: start_time,
|
||||||
|
employees: employees,
|
||||||
|
},
|
||||||
|
callback: function (r) {
|
||||||
|
frm.reload_doc();
|
||||||
|
frm.trigger("make_dashboard");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
make_finished_good(frm) {
|
||||||
|
let fields = [
|
||||||
|
{
|
||||||
|
fieldtype: "Float",
|
||||||
|
label: __("Completed Quantity"),
|
||||||
|
fieldname: "qty",
|
||||||
|
reqd: 1,
|
||||||
|
default: frm.doc.for_quantity - frm.doc.manufactured_qty,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldtype: "Datetime",
|
||||||
|
label: __("End Time"),
|
||||||
|
fieldname: "end_time",
|
||||||
|
default: frappe.datetime.now_datetime(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
frappe.prompt(
|
||||||
|
fields,
|
||||||
|
(data) => {
|
||||||
|
if (data.qty <= 0) {
|
||||||
|
frappe.throw(__("Quantity should be greater than 0"));
|
||||||
|
}
|
||||||
|
|
||||||
|
frm.call({
|
||||||
|
method: "make_finished_good",
|
||||||
|
doc: frm.doc,
|
||||||
|
args: {
|
||||||
|
qty: data.qty,
|
||||||
|
end_time: data.end_time,
|
||||||
|
},
|
||||||
|
callback: function (r) {
|
||||||
|
var doc = frappe.model.sync(r.message);
|
||||||
|
frappe.set_route("Form", doc[0].doctype, doc[0].name);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
__("Enter Value"),
|
||||||
|
__("Update"),
|
||||||
|
__("Set Finished Good Quantity")
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
setup_quality_inspection: function (frm) {
|
setup_quality_inspection: function (frm) {
|
||||||
let quality_inspection_field = frm.get_docfield("quality_inspection");
|
let quality_inspection_field = frm.get_docfield("quality_inspection");
|
||||||
quality_inspection_field.get_route_options_for_new_doc = function (frm) {
|
quality_inspection_field.get_route_options_for_new_doc = function (frm) {
|
||||||
@@ -262,90 +407,6 @@ frappe.ui.form.on("Job Card", {
|
|||||||
frm.toggle_reqd("operation_row_number", !frm.doc.operation_id && frm.doc.operation);
|
frm.toggle_reqd("operation_row_number", !frm.doc.operation_id && frm.doc.operation);
|
||||||
},
|
},
|
||||||
|
|
||||||
prepare_timer_buttons: function (frm) {
|
|
||||||
frm.trigger("make_dashboard");
|
|
||||||
|
|
||||||
if (!frm.doc.started_time && !frm.doc.current_time) {
|
|
||||||
frm.add_custom_button(__("Start Job"), () => {
|
|
||||||
if ((frm.doc.employee && !frm.doc.employee.length) || !frm.doc.employee) {
|
|
||||||
frappe.prompt(
|
|
||||||
{
|
|
||||||
fieldtype: "Table MultiSelect",
|
|
||||||
label: __("Select Employees"),
|
|
||||||
options: "Job Card Time Log",
|
|
||||||
fieldname: "employees",
|
|
||||||
},
|
|
||||||
(d) => {
|
|
||||||
frm.events.start_job(frm, "Work In Progress", d.employees);
|
|
||||||
},
|
|
||||||
__("Assign Job to Employee")
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
frm.events.start_job(frm, "Work In Progress", frm.doc.employee);
|
|
||||||
}
|
|
||||||
}).addClass("btn-primary");
|
|
||||||
} else if (frm.doc.status == "On Hold") {
|
|
||||||
frm.add_custom_button(__("Resume Job"), () => {
|
|
||||||
frm.events.start_job(frm, "Resume Job", frm.doc.employee);
|
|
||||||
}).addClass("btn-primary");
|
|
||||||
} else {
|
|
||||||
frm.add_custom_button(__("Pause Job"), () => {
|
|
||||||
frm.events.complete_job(frm, "On Hold");
|
|
||||||
});
|
|
||||||
|
|
||||||
frm.add_custom_button(__("Complete Job"), () => {
|
|
||||||
var sub_operations = frm.doc.sub_operations;
|
|
||||||
|
|
||||||
let set_qty = true;
|
|
||||||
if (sub_operations && sub_operations.length > 1) {
|
|
||||||
set_qty = false;
|
|
||||||
let last_op_row = sub_operations[sub_operations.length - 2];
|
|
||||||
|
|
||||||
if (last_op_row.status == "Complete") {
|
|
||||||
set_qty = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (set_qty) {
|
|
||||||
frappe.prompt(
|
|
||||||
{
|
|
||||||
fieldtype: "Float",
|
|
||||||
label: __("Completed Quantity"),
|
|
||||||
fieldname: "qty",
|
|
||||||
default: frm.doc.for_quantity,
|
|
||||||
},
|
|
||||||
(data) => {
|
|
||||||
frm.events.complete_job(frm, "Complete", data.qty);
|
|
||||||
},
|
|
||||||
__("Enter Value")
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
frm.events.complete_job(frm, "Complete", 0.0);
|
|
||||||
}
|
|
||||||
}).addClass("btn-primary");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
start_job: function (frm, status, employee) {
|
|
||||||
const args = {
|
|
||||||
job_card_id: frm.doc.name,
|
|
||||||
start_time: frappe.datetime.now_datetime(),
|
|
||||||
employees: employee,
|
|
||||||
status: status,
|
|
||||||
};
|
|
||||||
frm.events.make_time_log(frm, args);
|
|
||||||
},
|
|
||||||
|
|
||||||
complete_job: function (frm, status, completed_qty) {
|
|
||||||
const args = {
|
|
||||||
job_card_id: frm.doc.name,
|
|
||||||
complete_time: frappe.datetime.now_datetime(),
|
|
||||||
status: status,
|
|
||||||
completed_qty: completed_qty,
|
|
||||||
};
|
|
||||||
frm.events.make_time_log(frm, args);
|
|
||||||
},
|
|
||||||
|
|
||||||
make_time_log: function (frm, args) {
|
make_time_log: function (frm, args) {
|
||||||
frm.events.update_sub_operation(frm, args);
|
frm.events.update_sub_operation(frm, args);
|
||||||
|
|
||||||
@@ -392,7 +453,7 @@ frappe.ui.form.on("Job Card", {
|
|||||||
function updateStopwatch(increment) {
|
function updateStopwatch(increment) {
|
||||||
var hours = Math.floor(increment / 3600);
|
var hours = Math.floor(increment / 3600);
|
||||||
var minutes = Math.floor((increment - hours * 3600) / 60);
|
var minutes = Math.floor((increment - hours * 3600) / 60);
|
||||||
var seconds = increment - hours * 3600 - minutes * 60;
|
var seconds = flt(increment - hours * 3600 - minutes * 60, 2);
|
||||||
|
|
||||||
$(section)
|
$(section)
|
||||||
.find(".hours")
|
.find(".hours")
|
||||||
@@ -415,7 +476,7 @@ frappe.ui.form.on("Job Card", {
|
|||||||
frm.dashboard.refresh();
|
frm.dashboard.refresh();
|
||||||
const timer = `
|
const timer = `
|
||||||
<div class="stopwatch" style="font-weight:bold;margin:0px 13px 0px 2px;
|
<div class="stopwatch" style="font-weight:bold;margin:0px 13px 0px 2px;
|
||||||
color:#545454;font-size:18px;display:inline-block;vertical-align:text-bottom;>
|
color:#545454;font-size:18px;display:inline-block;vertical-align:text-bottom;">
|
||||||
<span class="hours">00</span>
|
<span class="hours">00</span>
|
||||||
<span class="colon">:</span>
|
<span class="colon">:</span>
|
||||||
<span class="minutes">00</span>
|
<span class="minutes">00</span>
|
||||||
@@ -424,21 +485,34 @@ frappe.ui.form.on("Job Card", {
|
|||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
var section = frm.toolbar.page.add_inner_message(timer);
|
var section = frm.toolbar.page.add_inner_message(timer);
|
||||||
|
let currentIncrement = frm.events.get_current_time(frm);
|
||||||
let currentIncrement = frm.doc.current_time || 0;
|
if (frm.doc.time_logs?.length && frm.doc.time_logs[cint(frm.doc.time_logs.length) - 1].to_time) {
|
||||||
if (frm.doc.started_time || frm.doc.current_time) {
|
updateStopwatch(currentIncrement);
|
||||||
if (frm.doc.status == "On Hold") {
|
} else if (frm.doc.status == "On Hold") {
|
||||||
updateStopwatch(currentIncrement);
|
updateStopwatch(currentIncrement);
|
||||||
} else {
|
} else {
|
||||||
currentIncrement += moment(frappe.datetime.now_datetime()).diff(
|
initialiseTimer();
|
||||||
moment(frm.doc.started_time),
|
|
||||||
"seconds"
|
|
||||||
);
|
|
||||||
initialiseTimer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get_current_time(frm) {
|
||||||
|
let current_time = 0;
|
||||||
|
|
||||||
|
frm.doc.time_logs.forEach((d) => {
|
||||||
|
if (d.to_time) {
|
||||||
|
if (d.time_in_mins) {
|
||||||
|
current_time += flt(d.time_in_mins, 2) * 60;
|
||||||
|
} else {
|
||||||
|
current_time += get_seconds_diff(d.to_time, d.from_time);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
current_time += get_seconds_diff(frappe.datetime.now_datetime(), d.from_time);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return current_time;
|
||||||
|
},
|
||||||
|
|
||||||
hide_timer: function (frm) {
|
hide_timer: function (frm) {
|
||||||
frm.toolbar.page.inner_toolbar.find(".stopwatch").remove();
|
frm.toolbar.page.inner_toolbar.find(".stopwatch").remove();
|
||||||
},
|
},
|
||||||
@@ -492,6 +566,14 @@ frappe.ui.form.on("Job Card", {
|
|||||||
|
|
||||||
refresh_field("total_completed_qty");
|
refresh_field("total_completed_qty");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
source_warehouse(frm) {
|
||||||
|
if (frm.doc.source_warehouse) {
|
||||||
|
frm.doc.items.forEach((d) => {
|
||||||
|
frappe.model.set_value(d.doctype, d.name, "source_warehouse", frm.doc.source_warehouse);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on("Job Card Time Log", {
|
frappe.ui.form.on("Job Card Time Log", {
|
||||||
@@ -503,3 +585,7 @@ frappe.ui.form.on("Job Card Time Log", {
|
|||||||
frm.set_value("started_time", "");
|
frm.set_value("started_time", "");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function get_seconds_diff(d1, d2) {
|
||||||
|
return moment(d1).diff(d2, "seconds");
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,43 +8,57 @@
|
|||||||
"field_order": [
|
"field_order": [
|
||||||
"naming_series",
|
"naming_series",
|
||||||
"work_order",
|
"work_order",
|
||||||
"bom_no",
|
|
||||||
"production_item",
|
|
||||||
"employee",
|
"employee",
|
||||||
|
"is_subcontracted",
|
||||||
"column_break_4",
|
"column_break_4",
|
||||||
"posting_date",
|
"posting_date",
|
||||||
"company",
|
"company",
|
||||||
"for_quantity",
|
"project",
|
||||||
|
"bom_no",
|
||||||
|
"semi_finished_good__finished_good_section",
|
||||||
|
"finished_good",
|
||||||
|
"production_item",
|
||||||
|
"semi_fg_bom",
|
||||||
"total_completed_qty",
|
"total_completed_qty",
|
||||||
|
"column_break_mcnb",
|
||||||
|
"for_quantity",
|
||||||
|
"transferred_qty",
|
||||||
|
"manufactured_qty",
|
||||||
"process_loss_qty",
|
"process_loss_qty",
|
||||||
|
"production_section",
|
||||||
|
"operation",
|
||||||
|
"source_warehouse",
|
||||||
|
"wip_warehouse",
|
||||||
|
"skip_material_transfer",
|
||||||
|
"backflush_from_wip_warehouse",
|
||||||
|
"column_break_12",
|
||||||
|
"workstation_type",
|
||||||
|
"workstation",
|
||||||
|
"target_warehouse",
|
||||||
|
"section_break_8",
|
||||||
|
"items",
|
||||||
|
"quality_inspection_section",
|
||||||
|
"quality_inspection_template",
|
||||||
|
"column_break_fcmp",
|
||||||
|
"quality_inspection",
|
||||||
|
"scheduled_time_tab",
|
||||||
"scheduled_time_section",
|
"scheduled_time_section",
|
||||||
"expected_start_date",
|
"expected_start_date",
|
||||||
"time_required",
|
"time_required",
|
||||||
"column_break_jkir",
|
"column_break_jkir",
|
||||||
"expected_end_date",
|
"expected_end_date",
|
||||||
"section_break_05am",
|
"section_break_rzeo",
|
||||||
"scheduled_time_logs",
|
"scheduled_time_logs",
|
||||||
"timing_detail",
|
"timing_detail",
|
||||||
"time_logs",
|
|
||||||
"section_break_13",
|
"section_break_13",
|
||||||
"actual_start_date",
|
"actual_start_date",
|
||||||
"total_time_in_mins",
|
"total_time_in_mins",
|
||||||
"column_break_15",
|
"column_break_15",
|
||||||
"actual_end_date",
|
"actual_end_date",
|
||||||
"production_section",
|
"section_break_jbas",
|
||||||
"operation",
|
"time_logs",
|
||||||
"wip_warehouse",
|
|
||||||
"column_break_12",
|
|
||||||
"workstation_type",
|
|
||||||
"workstation",
|
|
||||||
"quality_inspection_section",
|
|
||||||
"quality_inspection_template",
|
|
||||||
"column_break_fcmp",
|
|
||||||
"quality_inspection",
|
|
||||||
"section_break_21",
|
"section_break_21",
|
||||||
"sub_operations",
|
"sub_operations",
|
||||||
"section_break_8",
|
|
||||||
"items",
|
|
||||||
"scrap_items_section",
|
"scrap_items_section",
|
||||||
"scrap_items",
|
"scrap_items",
|
||||||
"corrective_operation_section",
|
"corrective_operation_section",
|
||||||
@@ -54,11 +68,11 @@
|
|||||||
"hour_rate",
|
"hour_rate",
|
||||||
"for_operation",
|
"for_operation",
|
||||||
"more_information",
|
"more_information",
|
||||||
"project",
|
|
||||||
"item_name",
|
"item_name",
|
||||||
"transferred_qty",
|
|
||||||
"requested_qty",
|
"requested_qty",
|
||||||
"status",
|
"status",
|
||||||
|
"operation_row_id",
|
||||||
|
"is_paused",
|
||||||
"column_break_20",
|
"column_break_20",
|
||||||
"operation_row_number",
|
"operation_row_number",
|
||||||
"operation_id",
|
"operation_id",
|
||||||
@@ -68,7 +82,6 @@
|
|||||||
"batch_no",
|
"batch_no",
|
||||||
"serial_no",
|
"serial_no",
|
||||||
"barcode",
|
"barcode",
|
||||||
"job_started",
|
|
||||||
"started_time",
|
"started_time",
|
||||||
"current_time",
|
"current_time",
|
||||||
"amended_from",
|
"amended_from",
|
||||||
@@ -86,10 +99,11 @@
|
|||||||
"search_index": 1
|
"search_index": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"depends_on": "eval:!doc.finished_good",
|
||||||
"fetch_from": "work_order.bom_no",
|
"fetch_from": "work_order.bom_no",
|
||||||
"fieldname": "bom_no",
|
"fieldname": "bom_no",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "BOM No",
|
"label": "Final BOM",
|
||||||
"options": "BOM",
|
"options": "BOM",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
@@ -105,6 +119,7 @@
|
|||||||
"fieldname": "operation",
|
"fieldname": "operation",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
|
"in_preview": 1,
|
||||||
"label": "Operation",
|
"label": "Operation",
|
||||||
"options": "Operation",
|
"options": "Operation",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
@@ -130,22 +145,24 @@
|
|||||||
"fieldname": "for_quantity",
|
"fieldname": "for_quantity",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
|
"in_preview": 1,
|
||||||
"label": "Qty To Manufacture"
|
"label": "Qty To Manufacture"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "wip_warehouse",
|
"fieldname": "wip_warehouse",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "WIP Warehouse",
|
"label": "WIP Warehouse",
|
||||||
"options": "Warehouse",
|
"mandatory_depends_on": "eval:!doc.finished_good || doc.skip_material_transfer === 0 || (doc.skip_material_transfer && doc.backflush_from_wip_warehouse)",
|
||||||
"reqd": 1
|
"options": "Warehouse"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "timing_detail",
|
"fieldname": "timing_detail",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Tab Break",
|
||||||
"label": "Actual Time"
|
"label": "Actual Time"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 1,
|
"allow_bulk_edit": 1,
|
||||||
|
"allow_on_submit": 1,
|
||||||
"fieldname": "time_logs",
|
"fieldname": "time_logs",
|
||||||
"fieldtype": "Table",
|
"fieldtype": "Table",
|
||||||
"label": "Time Logs",
|
"label": "Time Logs",
|
||||||
@@ -157,9 +174,12 @@
|
|||||||
"hide_border": 1
|
"hide_border": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
"default": "0",
|
"default": "0",
|
||||||
|
"depends_on": "eval:doc.is_subcontracted===0",
|
||||||
"fieldname": "total_completed_qty",
|
"fieldname": "total_completed_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
|
"in_preview": 1,
|
||||||
"label": "Total Completed Qty",
|
"label": "Total Completed Qty",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
@@ -175,7 +195,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "section_break_8",
|
"fieldname": "section_break_8",
|
||||||
"fieldtype": "Tab Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Raw Materials"
|
"label": "Raw Materials"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -199,9 +219,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "0",
|
"default": "0",
|
||||||
|
"depends_on": "items",
|
||||||
"fieldname": "transferred_qty",
|
"fieldname": "transferred_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"label": "FG Qty from Transferred Raw Materials",
|
"label": "Transferred Raw Materials",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -227,6 +248,7 @@
|
|||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
"default": "Open",
|
"default": "Open",
|
||||||
"fieldname": "status",
|
"fieldname": "status",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
@@ -236,16 +258,7 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "0",
|
"allow_on_submit": 1,
|
||||||
"fieldname": "job_started",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Job Started",
|
|
||||||
"no_copy": 1,
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "started_time",
|
"fieldname": "started_time",
|
||||||
"fieldtype": "Datetime",
|
"fieldtype": "Datetime",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
@@ -273,18 +286,19 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "production_section",
|
"fieldname": "production_section",
|
||||||
"fieldtype": "Tab Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Operation & Workstation"
|
"label": "Operation & Materials"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_12",
|
"fieldname": "column_break_12",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"depends_on": "eval:!doc.finished_good",
|
||||||
"fetch_from": "work_order.production_item",
|
"fetch_from": "work_order.production_item",
|
||||||
"fieldname": "production_item",
|
"fieldname": "production_item",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Production Item",
|
"label": "Final Product",
|
||||||
"options": "Item",
|
"options": "Item",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
@@ -302,6 +316,7 @@
|
|||||||
"label": "Item Name"
|
"label": "Item Name"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
"fieldname": "current_time",
|
"fieldname": "current_time",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
@@ -384,6 +399,7 @@
|
|||||||
"options": "Operation"
|
"options": "Operation"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
"fieldname": "employee",
|
"fieldname": "employee",
|
||||||
"fieldtype": "Table MultiSelect",
|
"fieldtype": "Table MultiSelect",
|
||||||
"label": "Employee",
|
"label": "Employee",
|
||||||
@@ -463,6 +479,7 @@
|
|||||||
"show_dashboard": 1
|
"show_dashboard": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"depends_on": "expected_start_date",
|
||||||
"fieldname": "scheduled_time_section",
|
"fieldname": "scheduled_time_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Scheduled Time"
|
"label": "Scheduled Time"
|
||||||
@@ -476,10 +493,6 @@
|
|||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"label": "Expected Time Required (In Mins)"
|
"label": "Expected Time Required (In Mins)"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "section_break_05am",
|
|
||||||
"fieldtype": "Section Break"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "scheduled_time_logs",
|
"fieldname": "scheduled_time_logs",
|
||||||
"fieldtype": "Table",
|
"fieldtype": "Table",
|
||||||
@@ -507,11 +520,101 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "column_break_fcmp",
|
"fieldname": "column_break_fcmp",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "finished_good",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_preview": 1,
|
||||||
|
"label": "Finished Good",
|
||||||
|
"options": "Item",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "target_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Target Warehouse",
|
||||||
|
"mandatory_depends_on": "eval:doc.finished_good",
|
||||||
|
"options": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "operation_row_id",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "Operation Row ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "source_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Source Warehouse",
|
||||||
|
"options": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "semi_finished_good__finished_good_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Semi Finished Good / Finished Good"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "semi_fg_bom",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Semi FG BOM",
|
||||||
|
"options": "BOM",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "is_subcontracted",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": " Is Subcontracted",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_mcnb",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_rzeo",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_jbas",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "scheduled_time_tab",
|
||||||
|
"fieldtype": "Tab Break",
|
||||||
|
"label": "Scheduled Time"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "finished_good",
|
||||||
|
"fieldname": "manufactured_qty",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"label": "Manufactured Qty",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"depends_on": "eval:doc.finished_good",
|
||||||
|
"fieldname": "skip_material_transfer",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Skip Material Transfer to WIP"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"depends_on": "eval:doc.finished_good && doc.skip_material_transfer === 1",
|
||||||
|
"fieldname": "backflush_from_wip_warehouse",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Backflush Materials From WIP Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "is_paused",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Is Paused",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-27 13:09:56.634418",
|
"modified": "2024-05-26 17:44:18.324743",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Job Card",
|
"name": "Job Card",
|
||||||
@@ -564,6 +667,7 @@
|
|||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"show_preview_popup": 1,
|
||||||
"sort_field": "creation",
|
"sort_field": "creation",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": [],
|
"states": [],
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from frappe import _, bold
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from frappe.query_builder import Criterion
|
from frappe.query_builder import Criterion
|
||||||
from frappe.query_builder.functions import IfNull, Max, Min
|
from frappe.query_builder.functions import IfNull, Max, Min, Sum
|
||||||
from frappe.utils import (
|
from frappe.utils import (
|
||||||
add_days,
|
add_days,
|
||||||
add_to_date,
|
add_to_date,
|
||||||
@@ -21,13 +21,15 @@ from frappe.utils import (
|
|||||||
getdate,
|
getdate,
|
||||||
time_diff,
|
time_diff,
|
||||||
time_diff_in_hours,
|
time_diff_in_hours,
|
||||||
time_diff_in_seconds,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from erpnext.manufacturing.doctype.manufacturing_settings.manufacturing_settings import (
|
from erpnext.manufacturing.doctype.manufacturing_settings.manufacturing_settings import (
|
||||||
get_mins_between_operations,
|
get_mins_between_operations,
|
||||||
)
|
)
|
||||||
from erpnext.manufacturing.doctype.workstation_type.workstation_type import get_workstations
|
from erpnext.manufacturing.doctype.workstation_type.workstation_type import get_workstations
|
||||||
|
from erpnext.subcontracting.doctype.subcontracting_bom.subcontracting_bom import (
|
||||||
|
get_subcontracting_boms_for_finished_goods,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class OverlapError(frappe.ValidationError):
|
class OverlapError(frappe.ValidationError):
|
||||||
@@ -64,14 +66,13 @@ class JobCard(Document):
|
|||||||
from erpnext.manufacturing.doctype.job_card_scheduled_time.job_card_scheduled_time import (
|
from erpnext.manufacturing.doctype.job_card_scheduled_time.job_card_scheduled_time import (
|
||||||
JobCardScheduledTime,
|
JobCardScheduledTime,
|
||||||
)
|
)
|
||||||
from erpnext.manufacturing.doctype.job_card_scrap_item.job_card_scrap_item import (
|
from erpnext.manufacturing.doctype.job_card_scrap_item.job_card_scrap_item import JobCardScrapItem
|
||||||
JobCardScrapItem,
|
|
||||||
)
|
|
||||||
from erpnext.manufacturing.doctype.job_card_time_log.job_card_time_log import JobCardTimeLog
|
from erpnext.manufacturing.doctype.job_card_time_log.job_card_time_log import JobCardTimeLog
|
||||||
|
|
||||||
actual_end_date: DF.Datetime | None
|
actual_end_date: DF.Datetime | None
|
||||||
actual_start_date: DF.Datetime | None
|
actual_start_date: DF.Datetime | None
|
||||||
amended_from: DF.Link | None
|
amended_from: DF.Link | None
|
||||||
|
backflush_from_wip_warehouse: DF.Check
|
||||||
barcode: DF.Barcode | None
|
barcode: DF.Barcode | None
|
||||||
batch_no: DF.Link | None
|
batch_no: DF.Link | None
|
||||||
bom_no: DF.Link | None
|
bom_no: DF.Link | None
|
||||||
@@ -80,18 +81,22 @@ class JobCard(Document):
|
|||||||
employee: DF.TableMultiSelect[JobCardTimeLog]
|
employee: DF.TableMultiSelect[JobCardTimeLog]
|
||||||
expected_end_date: DF.Datetime | None
|
expected_end_date: DF.Datetime | None
|
||||||
expected_start_date: DF.Datetime | None
|
expected_start_date: DF.Datetime | None
|
||||||
|
finished_good: DF.Link | None
|
||||||
for_job_card: DF.Link | None
|
for_job_card: DF.Link | None
|
||||||
for_operation: DF.Link | None
|
for_operation: DF.Link | None
|
||||||
for_quantity: DF.Float
|
for_quantity: DF.Float
|
||||||
hour_rate: DF.Currency
|
hour_rate: DF.Currency
|
||||||
is_corrective_job_card: DF.Check
|
is_corrective_job_card: DF.Check
|
||||||
|
is_paused: DF.Check
|
||||||
|
is_subcontracted: DF.Check
|
||||||
item_name: DF.ReadOnly | None
|
item_name: DF.ReadOnly | None
|
||||||
items: DF.Table[JobCardItem]
|
items: DF.Table[JobCardItem]
|
||||||
job_started: DF.Check
|
manufactured_qty: DF.Float
|
||||||
naming_series: DF.Literal["PO-JOB.#####"]
|
naming_series: DF.Literal["PO-JOB.#####"]
|
||||||
operation: DF.Link
|
operation: DF.Link
|
||||||
operation_id: DF.Data | None
|
operation_id: DF.Data | None
|
||||||
operation_row_number: DF.Literal
|
operation_row_id: DF.Int
|
||||||
|
operation_row_number: DF.Literal[None]
|
||||||
posting_date: DF.Date | None
|
posting_date: DF.Date | None
|
||||||
process_loss_qty: DF.Float
|
process_loss_qty: DF.Float
|
||||||
production_item: DF.Link | None
|
production_item: DF.Link | None
|
||||||
@@ -102,9 +107,12 @@ class JobCard(Document):
|
|||||||
requested_qty: DF.Float
|
requested_qty: DF.Float
|
||||||
scheduled_time_logs: DF.Table[JobCardScheduledTime]
|
scheduled_time_logs: DF.Table[JobCardScheduledTime]
|
||||||
scrap_items: DF.Table[JobCardScrapItem]
|
scrap_items: DF.Table[JobCardScrapItem]
|
||||||
|
semi_fg_bom: DF.Link | None
|
||||||
sequence_id: DF.Int
|
sequence_id: DF.Int
|
||||||
serial_and_batch_bundle: DF.Link | None
|
serial_and_batch_bundle: DF.Link | None
|
||||||
serial_no: DF.SmallText | None
|
serial_no: DF.SmallText | None
|
||||||
|
skip_material_transfer: DF.Check
|
||||||
|
source_warehouse: DF.Link | None
|
||||||
started_time: DF.Datetime | None
|
started_time: DF.Datetime | None
|
||||||
status: DF.Literal[
|
status: DF.Literal[
|
||||||
"Open",
|
"Open",
|
||||||
@@ -116,12 +124,13 @@ class JobCard(Document):
|
|||||||
"Completed",
|
"Completed",
|
||||||
]
|
]
|
||||||
sub_operations: DF.Table[JobCardOperation]
|
sub_operations: DF.Table[JobCardOperation]
|
||||||
|
target_warehouse: DF.Link | None
|
||||||
time_logs: DF.Table[JobCardTimeLog]
|
time_logs: DF.Table[JobCardTimeLog]
|
||||||
time_required: DF.Float
|
time_required: DF.Float
|
||||||
total_completed_qty: DF.Float
|
total_completed_qty: DF.Float
|
||||||
total_time_in_mins: DF.Float
|
total_time_in_mins: DF.Float
|
||||||
transferred_qty: DF.Float
|
transferred_qty: DF.Float
|
||||||
wip_warehouse: DF.Link
|
wip_warehouse: DF.Link | None
|
||||||
work_order: DF.Link
|
work_order: DF.Link
|
||||||
workstation: DF.Link
|
workstation: DF.Link
|
||||||
workstation_type: DF.Link | None
|
workstation_type: DF.Link | None
|
||||||
@@ -141,6 +150,7 @@ class JobCard(Document):
|
|||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_time_logs()
|
self.validate_time_logs()
|
||||||
|
self.validate_on_hold()
|
||||||
self.set_status()
|
self.set_status()
|
||||||
self.validate_operation_id()
|
self.validate_operation_id()
|
||||||
self.validate_sequence_id()
|
self.validate_sequence_id()
|
||||||
@@ -151,6 +161,31 @@ class JobCard(Document):
|
|||||||
def on_update(self):
|
def on_update(self):
|
||||||
self.validate_job_card_qty()
|
self.validate_job_card_qty()
|
||||||
|
|
||||||
|
def validate_on_hold(self):
|
||||||
|
if self.is_paused and not self.time_logs:
|
||||||
|
self.is_paused = 0
|
||||||
|
|
||||||
|
def set_manufactured_qty(self):
|
||||||
|
table_name = "Stock Entry"
|
||||||
|
if self.is_subcontracted:
|
||||||
|
table_name = "Subcontracting Receipt Item"
|
||||||
|
|
||||||
|
table = frappe.qb.DocType(table_name)
|
||||||
|
query = frappe.qb.from_(table).where((table.job_card == self.name) & (table.docstatus == 1))
|
||||||
|
|
||||||
|
if self.is_subcontracted:
|
||||||
|
query = query.select(Sum(table.qty))
|
||||||
|
else:
|
||||||
|
query = query.select(Sum(table.fg_completed_qty))
|
||||||
|
query = query.where(table.purpose == "Manufacture")
|
||||||
|
|
||||||
|
qty = query.run()[0][0] or 0.0
|
||||||
|
self.manufactured_qty = flt(qty)
|
||||||
|
self.db_set("manufactured_qty", self.manufactured_qty)
|
||||||
|
|
||||||
|
self.update_semi_finished_good_details()
|
||||||
|
self.set_status(update_status=True)
|
||||||
|
|
||||||
def validate_job_card_qty(self):
|
def validate_job_card_qty(self):
|
||||||
if not (self.operation_id and self.work_order):
|
if not (self.operation_id and self.work_order):
|
||||||
return
|
return
|
||||||
@@ -511,13 +546,14 @@ class JobCard(Document):
|
|||||||
if self.time_logs and len(self.time_logs) > 0:
|
if self.time_logs and len(self.time_logs) > 0:
|
||||||
last_row = self.time_logs[-1]
|
last_row = self.time_logs[-1]
|
||||||
|
|
||||||
self.reset_timer_value(args)
|
|
||||||
if last_row and args.get("complete_time"):
|
if last_row and args.get("complete_time"):
|
||||||
for row in self.time_logs:
|
for row in self.time_logs:
|
||||||
if not row.to_time:
|
if not row.to_time:
|
||||||
row.update(
|
to_time = get_datetime(args.get("complete_time"))
|
||||||
|
row.db_set(
|
||||||
{
|
{
|
||||||
"to_time": get_datetime(args.get("complete_time")),
|
"to_time": to_time,
|
||||||
|
"time_in_mins": time_diff_in_minutes(to_time, row.from_time),
|
||||||
"operation": args.get("sub_operation"),
|
"operation": args.get("sub_operation"),
|
||||||
"completed_qty": (args.get("completed_qty") if last_row.idx == row.idx else 0.0),
|
"completed_qty": (args.get("completed_qty") if last_row.idx == row.idx else 0.0),
|
||||||
}
|
}
|
||||||
@@ -538,35 +574,17 @@ class JobCard(Document):
|
|||||||
else:
|
else:
|
||||||
self.add_start_time_log(new_args)
|
self.add_start_time_log(new_args)
|
||||||
|
|
||||||
if not self.employee and employees:
|
|
||||||
self.set_employees(employees)
|
|
||||||
|
|
||||||
if self.status == "On Hold":
|
|
||||||
self.current_time = time_diff_in_seconds(last_row.to_time, last_row.from_time)
|
|
||||||
|
|
||||||
self.save()
|
|
||||||
|
|
||||||
def add_start_time_log(self, args):
|
def add_start_time_log(self, args):
|
||||||
self.append("time_logs", args)
|
if args.from_time and args.to_time:
|
||||||
|
args.time_in_mins = time_diff_in_minutes(args.to_time, args.from_time)
|
||||||
|
|
||||||
|
row = self.append("time_logs", args)
|
||||||
|
row.db_update()
|
||||||
|
|
||||||
def set_employees(self, employees):
|
def set_employees(self, employees):
|
||||||
for name in employees:
|
for name in employees:
|
||||||
self.append("employee", {"employee": name.get("employee"), "completed_qty": 0.0})
|
self.append("employee", {"employee": name.get("employee"), "completed_qty": 0.0})
|
||||||
|
self.save()
|
||||||
def reset_timer_value(self, args):
|
|
||||||
self.started_time = None
|
|
||||||
|
|
||||||
if args.get("status") in ["Work In Progress", "Complete"]:
|
|
||||||
self.current_time = 0.0
|
|
||||||
|
|
||||||
if args.get("status") == "Work In Progress":
|
|
||||||
self.started_time = get_datetime(args.get("start_time"))
|
|
||||||
|
|
||||||
if args.get("status") == "Resume Job":
|
|
||||||
args["status"] = "Work In Progress"
|
|
||||||
|
|
||||||
if args.get("status"):
|
|
||||||
self.status = args.get("status")
|
|
||||||
|
|
||||||
def update_sub_operation_status(self):
|
def update_sub_operation_status(self):
|
||||||
if not (self.sub_operations and self.time_logs):
|
if not (self.sub_operations and self.time_logs):
|
||||||
@@ -628,23 +646,25 @@ class JobCard(Document):
|
|||||||
return
|
return
|
||||||
|
|
||||||
doc = frappe.get_doc("Work Order", self.get("work_order"))
|
doc = frappe.get_doc("Work Order", self.get("work_order"))
|
||||||
if doc.transfer_material_against == "Work Order" or doc.skip_transfer:
|
if not doc.track_semi_finished_goods and (
|
||||||
|
doc.transfer_material_against == "Work Order" or doc.skip_transfer
|
||||||
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
for d in doc.required_items:
|
for d in doc.required_items:
|
||||||
if not d.operation:
|
if not d.operation and not d.operation_row_id:
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_("Row {0} : Operation is required against the raw material item {1}").format(
|
_("Row {0} : Operation is required against the raw material item {1}").format(
|
||||||
d.idx, d.item_code
|
d.idx, d.item_code
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.get("operation") == d.operation:
|
if self.get("operation") == d.operation or self.operation_row_id == d.operation_row_id:
|
||||||
self.append(
|
self.append(
|
||||||
"items",
|
"items",
|
||||||
{
|
{
|
||||||
"item_code": d.item_code,
|
"item_code": d.item_code,
|
||||||
"source_warehouse": d.source_warehouse,
|
"source_warehouse": self.source_warehouse or d.source_warehouse,
|
||||||
"uom": frappe.db.get_value("Item", d.item_code, "stock_uom"),
|
"uom": frappe.db.get_value("Item", d.item_code, "stock_uom"),
|
||||||
"item_name": d.item_name,
|
"item_name": d.item_name,
|
||||||
"description": d.description,
|
"description": d.description,
|
||||||
@@ -669,7 +689,7 @@ class JobCard(Document):
|
|||||||
self.set_transferred_qty()
|
self.set_transferred_qty()
|
||||||
|
|
||||||
def validate_transfer_qty(self):
|
def validate_transfer_qty(self):
|
||||||
if self.items and self.transferred_qty < self.for_quantity:
|
if not self.finished_good and self.items and self.transferred_qty < self.for_quantity:
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_(
|
_(
|
||||||
"Materials needs to be transferred to the work in progress warehouse for the job card {0}"
|
"Materials needs to be transferred to the work in progress warehouse for the job card {0}"
|
||||||
@@ -677,6 +697,9 @@ class JobCard(Document):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def validate_job_card(self):
|
def validate_job_card(self):
|
||||||
|
if self.finished_good:
|
||||||
|
return
|
||||||
|
|
||||||
if self.work_order and frappe.get_cached_value("Work Order", self.work_order, "status") == "Stopped":
|
if self.work_order and frappe.get_cached_value("Work Order", self.work_order, "status") == "Stopped":
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_("Transaction not allowed against stopped Work Order {0}").format(
|
_("Transaction not allowed against stopped Work Order {0}").format(
|
||||||
@@ -745,6 +768,9 @@ class JobCard(Document):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def update_work_order(self):
|
def update_work_order(self):
|
||||||
|
if self.finished_good:
|
||||||
|
return
|
||||||
|
|
||||||
if not self.work_order:
|
if not self.work_order:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -756,7 +782,6 @@ class JobCard(Document):
|
|||||||
return
|
return
|
||||||
|
|
||||||
for_quantity, time_in_mins, process_loss_qty = 0, 0, 0
|
for_quantity, time_in_mins, process_loss_qty = 0, 0, 0
|
||||||
_from_time_list, _to_time_list = [], []
|
|
||||||
|
|
||||||
data = self.get_current_operation_data()
|
data = self.get_current_operation_data()
|
||||||
if data and len(data) > 0:
|
if data and len(data) > 0:
|
||||||
@@ -773,6 +798,20 @@ class JobCard(Document):
|
|||||||
self.validate_produced_quantity(for_quantity, process_loss_qty, wo)
|
self.validate_produced_quantity(for_quantity, process_loss_qty, wo)
|
||||||
self.update_work_order_data(for_quantity, process_loss_qty, time_in_mins, wo)
|
self.update_work_order_data(for_quantity, process_loss_qty, time_in_mins, wo)
|
||||||
|
|
||||||
|
def update_semi_finished_good_details(self):
|
||||||
|
if self.operation_id:
|
||||||
|
frappe.db.set_value(
|
||||||
|
"Work Order Operation", self.operation_id, "completed_qty", self.manufactured_qty
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
self.finished_good
|
||||||
|
and frappe.get_cached_value("Work Order", self.work_order, "production_item")
|
||||||
|
== self.finished_good
|
||||||
|
):
|
||||||
|
_wo_doc = frappe.get_doc("Work Order", self.work_order)
|
||||||
|
_wo_doc.db_set("produced_qty", self.manufactured_qty)
|
||||||
|
_wo_doc.db_set("status", _wo_doc.get_status())
|
||||||
|
|
||||||
def update_corrective_in_work_order(self, wo):
|
def update_corrective_in_work_order(self, wo):
|
||||||
wo.corrective_operation_cost = 0.0
|
wo.corrective_operation_cost = 0.0
|
||||||
for row in frappe.get_all(
|
for row in frappe.get_all(
|
||||||
@@ -913,64 +952,71 @@ class JobCard(Document):
|
|||||||
frappe.db.set_value("Job Card Item", row.job_card_item, "transferred_qty", flt(transferred_qty))
|
frappe.db.set_value("Job Card Item", row.job_card_item, "transferred_qty", flt(transferred_qty))
|
||||||
|
|
||||||
def set_transferred_qty(self, update_status=False):
|
def set_transferred_qty(self, update_status=False):
|
||||||
"Set total FG Qty in Job Card for which RM was transferred."
|
from frappe.query_builder.functions import Sum
|
||||||
if not self.items:
|
|
||||||
self.transferred_qty = self.for_quantity if self.docstatus == 1 else 0
|
|
||||||
|
|
||||||
doc = frappe.get_doc("Work Order", self.get("work_order"))
|
stock_entry = frappe.qb.DocType("Stock Entry")
|
||||||
if doc.transfer_material_against == "Work Order" or doc.skip_transfer:
|
|
||||||
return
|
|
||||||
|
|
||||||
if self.items:
|
query = (
|
||||||
# sum of 'For Quantity' of Stock Entries against JC
|
frappe.qb.from_(stock_entry)
|
||||||
self.transferred_qty = (
|
.select(Sum(stock_entry.fg_completed_qty))
|
||||||
frappe.db.get_value(
|
.where(
|
||||||
"Stock Entry",
|
(stock_entry.job_card == self.name)
|
||||||
{
|
& (stock_entry.docstatus == 1)
|
||||||
"job_card": self.name,
|
& (stock_entry.purpose == "Material Transfer for Manufacture")
|
||||||
"work_order": self.work_order,
|
|
||||||
"docstatus": 1,
|
|
||||||
"purpose": "Material Transfer for Manufacture",
|
|
||||||
},
|
|
||||||
"sum(fg_completed_qty)",
|
|
||||||
)
|
|
||||||
or 0
|
|
||||||
)
|
)
|
||||||
|
.groupby(stock_entry.job_card)
|
||||||
|
)
|
||||||
|
|
||||||
self.db_set("transferred_qty", self.transferred_qty)
|
query = query.run()
|
||||||
|
|
||||||
qty = 0
|
qty = 0
|
||||||
if self.work_order:
|
|
||||||
doc = frappe.get_doc("Work Order", self.work_order)
|
|
||||||
if doc.transfer_material_against == "Job Card" and not doc.skip_transfer:
|
|
||||||
completed = True
|
|
||||||
for d in doc.operations:
|
|
||||||
if d.status != "Completed":
|
|
||||||
completed = False
|
|
||||||
break
|
|
||||||
|
|
||||||
if completed:
|
if query and query[0][0]:
|
||||||
job_cards = frappe.get_all(
|
qty = flt(query[0][0])
|
||||||
"Job Card",
|
|
||||||
filters={"work_order": self.work_order, "docstatus": ("!=", 2)},
|
|
||||||
fields="sum(transferred_qty) as qty",
|
|
||||||
group_by="operation_id",
|
|
||||||
)
|
|
||||||
|
|
||||||
if job_cards:
|
self.db_set("transferred_qty", qty)
|
||||||
qty = min(d.qty for d in job_cards)
|
self.set_status(update_status)
|
||||||
|
|
||||||
|
if self.work_order and not frappe.get_cached_value(
|
||||||
|
"Work Order", self.work_order, "track_semi_finished_goods"
|
||||||
|
):
|
||||||
|
self.set_transferred_qty_in_work_order()
|
||||||
|
|
||||||
|
def set_transferred_qty_in_work_order(self):
|
||||||
|
doc = frappe.get_doc("Work Order", self.work_order)
|
||||||
|
|
||||||
|
qty = 0.0
|
||||||
|
if doc.transfer_material_against == "Job Card" and not doc.skip_transfer:
|
||||||
|
completed = True
|
||||||
|
for d in doc.operations:
|
||||||
|
if d.status != "Completed":
|
||||||
|
completed = False
|
||||||
|
break
|
||||||
|
|
||||||
|
if completed:
|
||||||
|
job_cards = frappe.get_all(
|
||||||
|
"Job Card",
|
||||||
|
filters={"work_order": self.work_order, "docstatus": ("!=", 2)},
|
||||||
|
fields="sum(transferred_qty) as qty",
|
||||||
|
group_by="operation_id",
|
||||||
|
)
|
||||||
|
|
||||||
|
if job_cards:
|
||||||
|
qty = min(d.qty for d in job_cards)
|
||||||
|
|
||||||
doc.db_set("material_transferred_for_manufacturing", qty)
|
doc.db_set("material_transferred_for_manufacturing", qty)
|
||||||
|
|
||||||
self.set_status(update_status)
|
|
||||||
|
|
||||||
def set_status(self, update_status=False):
|
def set_status(self, update_status=False):
|
||||||
if self.status == "On Hold" and self.docstatus == 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
self.status = {0: "Open", 1: "Submitted", 2: "Cancelled"}[self.docstatus or 0]
|
self.status = {0: "Open", 1: "Submitted", 2: "Cancelled"}[self.docstatus or 0]
|
||||||
|
if self.finished_good and self.docstatus == 1:
|
||||||
|
if self.manufactured_qty >= self.for_quantity:
|
||||||
|
self.status = "Completed"
|
||||||
|
elif self.transferred_qty > 0 or self.skip_material_transfer:
|
||||||
|
self.status = "Work In Progress"
|
||||||
|
|
||||||
if self.docstatus < 2:
|
if self.docstatus == 0 and self.time_logs:
|
||||||
|
self.status = "Work In Progress"
|
||||||
|
|
||||||
|
if not self.finished_good and self.docstatus < 2:
|
||||||
if flt(self.for_quantity) <= flt(self.transferred_qty):
|
if flt(self.for_quantity) <= flt(self.transferred_qty):
|
||||||
self.status = "Material Transferred"
|
self.status = "Material Transferred"
|
||||||
|
|
||||||
@@ -980,16 +1026,14 @@ class JobCard(Document):
|
|||||||
if self.docstatus == 1 and (self.for_quantity <= self.total_completed_qty or not self.items):
|
if self.docstatus == 1 and (self.for_quantity <= self.total_completed_qty or not self.items):
|
||||||
self.status = "Completed"
|
self.status = "Completed"
|
||||||
|
|
||||||
|
if self.is_paused:
|
||||||
|
self.status = "On Hold"
|
||||||
|
|
||||||
if update_status:
|
if update_status:
|
||||||
self.db_set("status", self.status)
|
self.db_set("status", self.status)
|
||||||
|
|
||||||
if self.status in ["Completed", "Work In Progress"]:
|
if self.workstation:
|
||||||
status = {
|
self.update_workstation_status()
|
||||||
"Completed": "Off",
|
|
||||||
"Work In Progress": "Production",
|
|
||||||
}.get(self.status)
|
|
||||||
|
|
||||||
self.update_status_in_workstation(status)
|
|
||||||
|
|
||||||
def set_wip_warehouse(self):
|
def set_wip_warehouse(self):
|
||||||
if not self.wip_warehouse:
|
if not self.wip_warehouse:
|
||||||
@@ -1012,7 +1056,30 @@ class JobCard(Document):
|
|||||||
OperationMismatchError,
|
OperationMismatchError,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def pause_job(self, **kwargs):
|
||||||
|
if isinstance(kwargs, dict):
|
||||||
|
kwargs = frappe._dict(kwargs)
|
||||||
|
|
||||||
|
self.db_set("is_paused", 1)
|
||||||
|
self.add_time_logs(to_time=kwargs.end_time, completed_qty=0.0, employees=self.employee)
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def resume_job(self, **kwargs):
|
||||||
|
if isinstance(kwargs, dict):
|
||||||
|
kwargs = frappe._dict(kwargs)
|
||||||
|
|
||||||
|
self.db_set("is_paused", 0)
|
||||||
|
self.add_time_logs(
|
||||||
|
from_time=kwargs.start_time,
|
||||||
|
employees=self.employee,
|
||||||
|
completed_qty=0.0,
|
||||||
|
)
|
||||||
|
|
||||||
def validate_sequence_id(self):
|
def validate_sequence_id(self):
|
||||||
|
if self.is_new():
|
||||||
|
return
|
||||||
|
|
||||||
if self.is_corrective_job_card:
|
if self.is_corrective_job_card:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1038,6 +1105,14 @@ class JobCard(Document):
|
|||||||
)
|
)
|
||||||
|
|
||||||
for row in data:
|
for row in data:
|
||||||
|
if not row.completed_qty:
|
||||||
|
frappe.throw(
|
||||||
|
_("{0}, complete the operation {1} before the operation {2}.").format(
|
||||||
|
message, bold(row.operation), bold(self.operation)
|
||||||
|
),
|
||||||
|
OperationSequenceError,
|
||||||
|
)
|
||||||
|
|
||||||
if row.status != "Completed" and row.completed_qty < current_operation_qty:
|
if row.status != "Completed" and row.completed_qty < current_operation_qty:
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_("{0}, complete the operation {1} before the operation {2}.").format(
|
_("{0}, complete the operation {1} before the operation {2}.").format(
|
||||||
@@ -1075,16 +1150,173 @@ class JobCard(Document):
|
|||||||
|
|
||||||
frappe.db.set_value("Workstation", self.workstation, "status", status)
|
frappe.db.set_value("Workstation", self.workstation, "status", status)
|
||||||
|
|
||||||
|
def add_time_logs(self, **kwargs):
|
||||||
|
row = None
|
||||||
|
kwargs = frappe._dict(kwargs)
|
||||||
|
|
||||||
|
update_status = False
|
||||||
|
for employee in kwargs.employees:
|
||||||
|
kwargs.employee = employee.get("employee")
|
||||||
|
if kwargs.from_time and not kwargs.to_time:
|
||||||
|
row = self.append("time_logs", kwargs)
|
||||||
|
row.db_update()
|
||||||
|
self.db_set("status", "Work In Progress")
|
||||||
|
else:
|
||||||
|
update_status = True
|
||||||
|
for row in self.time_logs:
|
||||||
|
if row.to_time or row.employee != kwargs.employee:
|
||||||
|
continue
|
||||||
|
|
||||||
|
row.to_time = kwargs.to_time
|
||||||
|
row.time_in_mins = time_diff_in_minutes(row.to_time, row.from_time)
|
||||||
|
|
||||||
|
if kwargs.employees[-1].get("employee") == row.employee:
|
||||||
|
row.completed_qty = kwargs.completed_qty
|
||||||
|
|
||||||
|
row.db_update()
|
||||||
|
|
||||||
|
self.set_status(update_status=update_status)
|
||||||
|
|
||||||
|
if not self.employee and kwargs.employees:
|
||||||
|
self.set_employees(kwargs.employees)
|
||||||
|
|
||||||
|
def update_workstation_status(self):
|
||||||
|
status_map = {
|
||||||
|
"Open": "Off",
|
||||||
|
"Work In Progress": "Production",
|
||||||
|
"Completed": "Off",
|
||||||
|
"On Hold": "Idle",
|
||||||
|
}
|
||||||
|
|
||||||
|
job_cards = frappe.get_all(
|
||||||
|
"Job Card",
|
||||||
|
fields=["name", "status"],
|
||||||
|
filters={"workstation": self.workstation, "docstatus": 0, "status": ("!=", "Completed")},
|
||||||
|
order_by="status desc",
|
||||||
|
)
|
||||||
|
|
||||||
|
if not job_cards:
|
||||||
|
frappe.db.set_value("Workstation", self.workstation, "status", "Off")
|
||||||
|
|
||||||
|
for row in job_cards:
|
||||||
|
frappe.db.set_value("Workstation", self.workstation, "status", status_map.get(row.status))
|
||||||
|
return
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def start_timer(self, **kwargs):
|
||||||
|
if isinstance(kwargs, dict):
|
||||||
|
kwargs = frappe._dict(kwargs)
|
||||||
|
|
||||||
|
if isinstance(kwargs.employees, str):
|
||||||
|
kwargs.employees = [{"employee": kwargs.employees}]
|
||||||
|
|
||||||
|
if kwargs.start_time:
|
||||||
|
self.add_time_logs(from_time=kwargs.start_time, employees=kwargs.employees)
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def complete_job_card(self, **kwargs):
|
||||||
|
if isinstance(kwargs, dict):
|
||||||
|
kwargs = frappe._dict(kwargs)
|
||||||
|
|
||||||
|
if kwargs.end_time:
|
||||||
|
self.add_time_logs(to_time=kwargs.end_time, completed_qty=kwargs.qty, employees=self.employee)
|
||||||
|
self.save()
|
||||||
|
|
||||||
|
if kwargs.auto_submit:
|
||||||
|
self.submit()
|
||||||
|
self.make_stock_entry_for_semi_fg_item(kwargs.auto_submit)
|
||||||
|
frappe.msgprint(
|
||||||
|
_("Job Card {0} has been completed").format(get_link_to_form("Job Card", self.name))
|
||||||
|
)
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def make_stock_entry_for_semi_fg_item(self, auto_submit=False):
|
||||||
|
from erpnext.stock.doctype.stock_entry_type.stock_entry_type import ManufactureEntry
|
||||||
|
|
||||||
|
ste = ManufactureEntry(
|
||||||
|
{
|
||||||
|
"for_quantity": self.for_quantity - self.manufactured_qty,
|
||||||
|
"job_card": self.name,
|
||||||
|
"skip_material_transfer": self.skip_material_transfer,
|
||||||
|
"backflush_from_wip_warehouse": self.backflush_from_wip_warehouse,
|
||||||
|
"work_order": self.work_order,
|
||||||
|
"purpose": "Manufacture",
|
||||||
|
"production_item": self.finished_good,
|
||||||
|
"company": self.company,
|
||||||
|
"wip_warehouse": self.wip_warehouse,
|
||||||
|
"fg_warehouse": self.target_warehouse,
|
||||||
|
"bom_no": self.semi_fg_bom,
|
||||||
|
"project": frappe.db.get_value("Work Order", self.work_order, "project"),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
ste.make_stock_entry()
|
||||||
|
ste.stock_entry.flags.ignore_mandatory = True
|
||||||
|
ste.stock_entry.save()
|
||||||
|
|
||||||
|
if auto_submit:
|
||||||
|
ste.stock_entry.submit()
|
||||||
|
|
||||||
|
frappe.msgprint(
|
||||||
|
_("Stock Entry {0} has created").format(get_link_to_form("Stock Entry", ste.stock_entry.name))
|
||||||
|
)
|
||||||
|
|
||||||
|
return ste.stock_entry.as_dict()
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_time_log(args):
|
def make_subcontracting_po(source_name, target_doc=None):
|
||||||
if isinstance(args, str):
|
def set_missing_values(source, target):
|
||||||
args = json.loads(args)
|
_item_details = get_subcontracting_boms_for_finished_goods(source.finished_good)
|
||||||
|
|
||||||
args = frappe._dict(args)
|
pending_qty = source.for_quantity - source.manufactured_qty
|
||||||
doc = frappe.get_doc("Job Card", args.job_card_id)
|
service_item_qty = flt(_item_details.service_item_qty) or 1.0
|
||||||
|
fg_item_qty = flt(_item_details.finished_good_qty) or 1.0
|
||||||
|
|
||||||
|
target.is_subcontracted = 1
|
||||||
|
target.supplier_warehouse = source.wip_warehouse
|
||||||
|
target.append(
|
||||||
|
"items",
|
||||||
|
{
|
||||||
|
"item_code": _item_details.service_item,
|
||||||
|
"fg_item": source.finished_good,
|
||||||
|
"uom": _item_details.service_item_uom,
|
||||||
|
"stock_uom": _item_details.service_item_uom,
|
||||||
|
"conversion_factor": _item_details.conversion_factor or 1,
|
||||||
|
"item_name": _item_details.service_item,
|
||||||
|
"qty": pending_qty * service_item_qty / fg_item_qty,
|
||||||
|
"fg_item_qty": pending_qty,
|
||||||
|
"job_card": source.name,
|
||||||
|
"bom": source.semi_fg_bom,
|
||||||
|
"warehouse": source.target_warehouse,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
doclist = get_mapped_doc(
|
||||||
|
"Job Card",
|
||||||
|
source_name,
|
||||||
|
{
|
||||||
|
"Job Card": {
|
||||||
|
"doctype": "Purchase Order",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
target_doc,
|
||||||
|
set_missing_values,
|
||||||
|
)
|
||||||
|
|
||||||
|
return doclist
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def make_time_log(kwargs):
|
||||||
|
if isinstance(kwargs, str):
|
||||||
|
kwargs = json.loads(kwargs)
|
||||||
|
|
||||||
|
kwargs = frappe._dict(kwargs)
|
||||||
|
doc = frappe.get_doc("Job Card", kwargs.job_card_id)
|
||||||
doc.validate_sequence_id()
|
doc.validate_sequence_id()
|
||||||
doc.add_time_log(args)
|
doc.add_time_log(kwargs)
|
||||||
|
doc.set_status(update_status=True)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@@ -1271,7 +1503,6 @@ def make_corrective_job_card(source_name, operation=None, for_operation=None, ta
|
|||||||
target.set("sub_operations", [])
|
target.set("sub_operations", [])
|
||||||
target.set_sub_operations()
|
target.set_sub_operations()
|
||||||
target.get_required_items()
|
target.get_required_items()
|
||||||
target.validate_time_logs()
|
|
||||||
|
|
||||||
doclist = get_mapped_doc(
|
doclist = get_mapped_doc(
|
||||||
"Job Card",
|
"Job Card",
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ def get_data():
|
|||||||
"non_standard_fieldnames": {"Quality Inspection": "reference_name"},
|
"non_standard_fieldnames": {"Quality Inspection": "reference_name"},
|
||||||
"transactions": [
|
"transactions": [
|
||||||
{"label": _("Transactions"), "items": ["Material Request", "Stock Entry"]},
|
{"label": _("Transactions"), "items": ["Material Request", "Stock Entry"]},
|
||||||
|
{"label": _("Subcontracting"), "items": ["Purchase Order", "Subcontracting Order"]},
|
||||||
{"label": _("Reference"), "items": ["Quality Inspection"]},
|
{"label": _("Reference"), "items": ["Quality Inspection"]},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,14 @@
|
|||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
"fieldname": "from_time",
|
"fieldname": "from_time",
|
||||||
"fieldtype": "Datetime",
|
"fieldtype": "Datetime",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "From Time"
|
"label": "From Time"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
"fieldname": "to_time",
|
"fieldname": "to_time",
|
||||||
"fieldtype": "Datetime",
|
"fieldtype": "Datetime",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
@@ -31,6 +33,7 @@
|
|||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
"fieldname": "time_in_mins",
|
"fieldname": "time_in_mins",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
@@ -38,6 +41,7 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"fieldname": "completed_qty",
|
"fieldname": "completed_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
@@ -63,7 +67,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-05-21 12:40:55.765860",
|
"modified": "2024-05-21 12:41:55.765860",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Job Card Time Log",
|
"name": "Job Card Time Log",
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "description",
|
"fieldname": "description",
|
||||||
"fieldtype": "Text",
|
"fieldtype": "Text",
|
||||||
|
"in_preview": 1,
|
||||||
"label": "Description"
|
"label": "Description"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -104,7 +105,7 @@
|
|||||||
"icon": "fa fa-wrench",
|
"icon": "fa fa-wrench",
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-27 13:10:06.841479",
|
"modified": "2024-05-26 17:59:44.338741",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Operation",
|
"name": "Operation",
|
||||||
@@ -134,6 +135,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"quick_entry": 1,
|
"quick_entry": 1,
|
||||||
|
"show_preview_popup": 1,
|
||||||
"sort_field": "creation",
|
"sort_field": "creation",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": [],
|
"states": [],
|
||||||
|
|||||||
@@ -149,13 +149,7 @@ frappe.ui.form.on("Work Order", {
|
|||||||
frm.doc.operations &&
|
frm.doc.operations &&
|
||||||
frm.doc.operations.length
|
frm.doc.operations.length
|
||||||
) {
|
) {
|
||||||
const not_completed = frm.doc.operations.filter((d) => {
|
if (frm.doc.__onload?.show_create_job_card_button) {
|
||||||
if (d.status != "Completed") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (not_completed && not_completed.length) {
|
|
||||||
frm.add_custom_button(__("Create Job Card"), () => {
|
frm.add_custom_button(__("Create Job Card"), () => {
|
||||||
frm.trigger("make_job_card");
|
frm.trigger("make_job_card");
|
||||||
}).addClass("btn-primary");
|
}).addClass("btn-primary");
|
||||||
@@ -277,6 +271,18 @@ frappe.ui.form.on("Work Order", {
|
|||||||
label: __("Sequence Id"),
|
label: __("Sequence Id"),
|
||||||
read_only: 1,
|
read_only: 1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fieldtype: "Check",
|
||||||
|
fieldname: "skip_material_transfer",
|
||||||
|
label: __("Skip Material Transfer"),
|
||||||
|
read_only: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldtype: "Check",
|
||||||
|
fieldname: "backflush_from_wip_warehouse",
|
||||||
|
label: __("Backflush Materials From WIP Warehouse"),
|
||||||
|
read_only: 1,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
data: operations_data,
|
data: operations_data,
|
||||||
in_place_edit: true,
|
in_place_edit: true,
|
||||||
@@ -317,6 +323,8 @@ frappe.ui.form.on("Work Order", {
|
|||||||
qty: pending_qty,
|
qty: pending_qty,
|
||||||
pending_qty: pending_qty,
|
pending_qty: pending_qty,
|
||||||
sequence_id: data.sequence_id,
|
sequence_id: data.sequence_id,
|
||||||
|
skip_material_transfer: data.skip_material_transfer,
|
||||||
|
backflush_from_wip_warehouse: data.backflush_from_wip_warehouse,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -615,22 +623,25 @@ erpnext.work_order = {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const show_start_btn =
|
if (!frm.doc.track_semi_finished_goods) {
|
||||||
frm.doc.skip_transfer || frm.doc.transfer_material_against == "Job Card" ? 0 : 1;
|
const show_start_btn =
|
||||||
|
frm.doc.skip_transfer || frm.doc.transfer_material_against == "Job Card" ? 0 : 1;
|
||||||
|
|
||||||
if (show_start_btn) {
|
if (show_start_btn) {
|
||||||
let pending_to_transfer = frm.doc.required_items.some(
|
let pending_to_transfer = frm.doc.required_items.some(
|
||||||
(item) => flt(item.transferred_qty) < flt(item.required_qty)
|
(item) => flt(item.transferred_qty) < flt(item.required_qty)
|
||||||
);
|
);
|
||||||
if (pending_to_transfer && frm.doc.status != "Stopped") {
|
if (pending_to_transfer && frm.doc.status != "Stopped") {
|
||||||
frm.has_start_btn = true;
|
frm.has_start_btn = true;
|
||||||
frm.add_custom_button(__("Create Pick List"), function () {
|
frm.add_custom_button(__("Create Pick List"), function () {
|
||||||
erpnext.work_order.create_pick_list(frm);
|
erpnext.work_order.create_pick_list(frm);
|
||||||
});
|
});
|
||||||
var start_btn = frm.add_custom_button(__("Start"), function () {
|
|
||||||
erpnext.work_order.make_se(frm, "Material Transfer for Manufacture");
|
var start_btn = frm.add_custom_button(__("Start"), function () {
|
||||||
});
|
erpnext.work_order.make_se(frm, "Material Transfer for Manufacture");
|
||||||
start_btn.addClass("btn-primary");
|
});
|
||||||
|
start_btn.addClass("btn-primary");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,16 @@
|
|||||||
"produced_qty",
|
"produced_qty",
|
||||||
"process_loss_qty",
|
"process_loss_qty",
|
||||||
"project",
|
"project",
|
||||||
|
"track_semi_finished_goods",
|
||||||
|
"warehouses",
|
||||||
|
"source_warehouse",
|
||||||
|
"wip_warehouse",
|
||||||
|
"column_break_12",
|
||||||
|
"fg_warehouse",
|
||||||
|
"scrap_warehouse",
|
||||||
|
"operations_section",
|
||||||
|
"transfer_material_against",
|
||||||
|
"operations",
|
||||||
"section_break_ndpq",
|
"section_break_ndpq",
|
||||||
"required_items",
|
"required_items",
|
||||||
"work_order_configuration",
|
"work_order_configuration",
|
||||||
@@ -32,22 +42,11 @@
|
|||||||
"skip_transfer",
|
"skip_transfer",
|
||||||
"from_wip_warehouse",
|
"from_wip_warehouse",
|
||||||
"update_consumed_material_cost_in_project",
|
"update_consumed_material_cost_in_project",
|
||||||
"warehouses",
|
|
||||||
"source_warehouse",
|
|
||||||
"wip_warehouse",
|
|
||||||
"column_break_12",
|
|
||||||
"fg_warehouse",
|
|
||||||
"scrap_warehouse",
|
|
||||||
"serial_no_and_batch_for_finished_good_section",
|
"serial_no_and_batch_for_finished_good_section",
|
||||||
"has_serial_no",
|
"has_serial_no",
|
||||||
"has_batch_no",
|
"has_batch_no",
|
||||||
"column_break_18",
|
"column_break_18",
|
||||||
"batch_size",
|
"batch_size",
|
||||||
"required_items_section",
|
|
||||||
"materials_and_operations_tab",
|
|
||||||
"operations_section",
|
|
||||||
"transfer_material_against",
|
|
||||||
"operations",
|
|
||||||
"time",
|
"time",
|
||||||
"planned_start_date",
|
"planned_start_date",
|
||||||
"planned_end_date",
|
"planned_end_date",
|
||||||
@@ -196,7 +195,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"depends_on": "eval:doc.docstatus==1 && doc.skip_transfer==0",
|
"depends_on": "eval:doc.docstatus==1 && doc.skip_transfer==0 && doc.track_semi_finished_goods === 0",
|
||||||
"fieldname": "material_transferred_for_manufacturing",
|
"fieldname": "material_transferred_for_manufacturing",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"label": "Material Transferred for Manufacturing",
|
"label": "Material Transferred for Manufacturing",
|
||||||
@@ -248,7 +247,7 @@
|
|||||||
"fieldname": "wip_warehouse",
|
"fieldname": "wip_warehouse",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Work-in-Progress Warehouse",
|
"label": "Work-in-Progress Warehouse",
|
||||||
"mandatory_depends_on": "eval:!doc.skip_transfer || doc.from_wip_warehouse",
|
"mandatory_depends_on": "eval:(!doc.skip_transfer || doc.from_wip_warehouse) && !doc.track_semi_finished_goods",
|
||||||
"options": "Warehouse"
|
"options": "Warehouse"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -256,8 +255,7 @@
|
|||||||
"fieldname": "fg_warehouse",
|
"fieldname": "fg_warehouse",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Target Warehouse",
|
"label": "Target Warehouse",
|
||||||
"options": "Warehouse",
|
"options": "Warehouse"
|
||||||
"reqd": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_12",
|
"fieldname": "column_break_12",
|
||||||
@@ -270,15 +268,9 @@
|
|||||||
"label": "Scrap Warehouse",
|
"label": "Scrap Warehouse",
|
||||||
"options": "Warehouse"
|
"options": "Warehouse"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "required_items_section",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "Required Items"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "required_items",
|
"fieldname": "required_items",
|
||||||
"fieldtype": "Table",
|
"fieldtype": "Table",
|
||||||
"label": "Required Items",
|
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "Work Order Item",
|
"options": "Work Order Item",
|
||||||
"print_hide": 1
|
"print_hide": 1
|
||||||
@@ -336,7 +328,7 @@
|
|||||||
"options": "fa fa-wrench"
|
"options": "fa fa-wrench"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "operations",
|
"depends_on": "eval: doc.operations?.length && doc.track_semi_finished_goods === 0",
|
||||||
"fetch_from": "bom_no.transfer_material_against",
|
"fetch_from": "bom_no.transfer_material_against",
|
||||||
"fetch_if_empty": 1,
|
"fetch_if_empty": 1,
|
||||||
"fieldname": "transfer_material_against",
|
"fieldname": "transfer_material_against",
|
||||||
@@ -579,13 +571,19 @@
|
|||||||
"label": "Configuration"
|
"label": "Configuration"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "materials_and_operations_tab",
|
"collapsible": 1,
|
||||||
"fieldtype": "Tab Break",
|
"collapsible_depends_on": "eval:!doc.operations?.length",
|
||||||
"label": "Operations"
|
"fieldname": "section_break_ndpq",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Required Items"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "section_break_ndpq",
|
"default": "0",
|
||||||
"fieldtype": "Section Break"
|
"fetch_from": "bom_no.track_semi_finished_goods",
|
||||||
|
"fieldname": "track_semi_finished_goods",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Track Semi Finished Goods",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-cogs",
|
"icon": "fa fa-cogs",
|
||||||
@@ -593,7 +591,7 @@
|
|||||||
"image_field": "image",
|
"image_field": "image",
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-27 13:11:00.129434",
|
"modified": "2024-03-27 13:13:00.129434",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Work Order",
|
"name": "Work Order",
|
||||||
|
|||||||
@@ -143,6 +143,24 @@ class WorkOrder(Document):
|
|||||||
self.set_onload("material_consumption", ms.material_consumption)
|
self.set_onload("material_consumption", ms.material_consumption)
|
||||||
self.set_onload("backflush_raw_materials_based_on", ms.backflush_raw_materials_based_on)
|
self.set_onload("backflush_raw_materials_based_on", ms.backflush_raw_materials_based_on)
|
||||||
self.set_onload("overproduction_percentage", ms.overproduction_percentage_for_work_order)
|
self.set_onload("overproduction_percentage", ms.overproduction_percentage_for_work_order)
|
||||||
|
self.set_onload("show_create_job_card_button", self.show_create_job_card_button())
|
||||||
|
|
||||||
|
def show_create_job_card_button(self):
|
||||||
|
operation_details = frappe._dict(
|
||||||
|
frappe.get_all(
|
||||||
|
"Job Card",
|
||||||
|
fields=["operation", "for_quantity"],
|
||||||
|
filters={"docstatus": ("<", 2), "work_order": self.name},
|
||||||
|
as_list=1,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
for d in self.operations:
|
||||||
|
job_card_qty = self.qty - flt(operation_details.get(d.operation))
|
||||||
|
if job_card_qty > 0:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_production_item()
|
self.validate_production_item()
|
||||||
@@ -422,15 +440,20 @@ class WorkOrder(Document):
|
|||||||
self.update_status()
|
self.update_status()
|
||||||
production_plan.run_method("update_produced_pending_qty", produced_qty, self.production_plan_item)
|
production_plan.run_method("update_produced_pending_qty", produced_qty, self.production_plan_item)
|
||||||
|
|
||||||
|
def validate_warehouse(self):
|
||||||
|
if self.track_semi_finished_goods:
|
||||||
|
return
|
||||||
|
|
||||||
|
if not self.wip_warehouse and not self.skip_transfer:
|
||||||
|
frappe.throw(_("Work-in-Progress Warehouse is required before Submit"))
|
||||||
|
if not self.fg_warehouse:
|
||||||
|
frappe.throw(_("Target Warehouse is required before Submit"))
|
||||||
|
|
||||||
def before_submit(self):
|
def before_submit(self):
|
||||||
self.create_serial_no_batch_no()
|
self.create_serial_no_batch_no()
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
if not self.wip_warehouse and not self.skip_transfer:
|
self.validate_warehouse()
|
||||||
frappe.throw(_("Work-in-Progress Warehouse is required before Submit"))
|
|
||||||
if not self.fg_warehouse:
|
|
||||||
frappe.throw(_("For Warehouse is required before Submit"))
|
|
||||||
|
|
||||||
if self.production_plan and frappe.db.exists(
|
if self.production_plan and frappe.db.exists(
|
||||||
"Production Plan Item Reference", {"parent": self.production_plan}
|
"Production Plan Item Reference", {"parent": self.production_plan}
|
||||||
):
|
):
|
||||||
@@ -667,6 +690,9 @@ class WorkOrder(Document):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def update_planned_qty(self):
|
def update_planned_qty(self):
|
||||||
|
if self.track_semi_finished_goods:
|
||||||
|
return
|
||||||
|
|
||||||
from erpnext.manufacturing.doctype.production_plan.production_plan import (
|
from erpnext.manufacturing.doctype.production_plan.production_plan import (
|
||||||
get_reserved_qty_for_sub_assembly,
|
get_reserved_qty_for_sub_assembly,
|
||||||
)
|
)
|
||||||
@@ -811,13 +837,21 @@ class WorkOrder(Document):
|
|||||||
"description",
|
"description",
|
||||||
"workstation",
|
"workstation",
|
||||||
"idx",
|
"idx",
|
||||||
|
"finished_good",
|
||||||
|
"is_subcontracted",
|
||||||
|
"wip_warehouse",
|
||||||
|
"source_warehouse",
|
||||||
|
"fg_warehouse",
|
||||||
"workstation_type",
|
"workstation_type",
|
||||||
"base_hour_rate as hour_rate",
|
"base_hour_rate as hour_rate",
|
||||||
"time_in_mins",
|
"time_in_mins",
|
||||||
"parent as bom",
|
"parent as bom",
|
||||||
|
"bom_no",
|
||||||
"batch_size",
|
"batch_size",
|
||||||
"sequence_id",
|
"sequence_id",
|
||||||
"fixed_time",
|
"fixed_time",
|
||||||
|
"skip_material_transfer",
|
||||||
|
"backflush_from_wip_warehouse",
|
||||||
],
|
],
|
||||||
order_by="idx",
|
order_by="idx",
|
||||||
)
|
)
|
||||||
@@ -827,6 +861,9 @@ class WorkOrder(Document):
|
|||||||
d.time_in_mins = flt(d.time_in_mins) * flt(qty)
|
d.time_in_mins = flt(d.time_in_mins) * flt(qty)
|
||||||
d.status = "Pending"
|
d.status = "Pending"
|
||||||
|
|
||||||
|
if self.track_semi_finished_goods and not d.sequence_id:
|
||||||
|
d.sequence_id = d.idx
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
self.set("operations", [])
|
self.set("operations", [])
|
||||||
@@ -1084,6 +1121,7 @@ class WorkOrder(Document):
|
|||||||
"required_qty": item.qty,
|
"required_qty": item.qty,
|
||||||
"source_warehouse": item.source_warehouse or item.default_warehouse,
|
"source_warehouse": item.source_warehouse or item.default_warehouse,
|
||||||
"include_item_in_manufacturing": item.include_item_in_manufacturing,
|
"include_item_in_manufacturing": item.include_item_in_manufacturing,
|
||||||
|
"operation_row_id": item.operation_row_id,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1284,6 +1322,7 @@ def make_work_order(bom_no, item, qty=0, project=None, variant_items=None):
|
|||||||
item_details = get_item_details(item, project)
|
item_details = get_item_details(item, project)
|
||||||
|
|
||||||
wo_doc = frappe.new_doc("Work Order")
|
wo_doc = frappe.new_doc("Work Order")
|
||||||
|
wo_doc.track_semi_finished_goods = frappe.db.get_value("BOM", bom_no, "track_semi_finished_goods")
|
||||||
wo_doc.production_item = item
|
wo_doc.production_item = item
|
||||||
wo_doc.update(item_details)
|
wo_doc.update(item_details)
|
||||||
wo_doc.bom_no = bom_no
|
wo_doc.bom_no = bom_no
|
||||||
@@ -1450,6 +1489,8 @@ def make_job_card(work_order, operations):
|
|||||||
work_order = frappe.get_doc("Work Order", work_order)
|
work_order = frappe.get_doc("Work Order", work_order)
|
||||||
for row in operations:
|
for row in operations:
|
||||||
row = frappe._dict(row)
|
row = frappe._dict(row)
|
||||||
|
row.update(get_operation_details(row.name, work_order))
|
||||||
|
|
||||||
validate_operation_data(row)
|
validate_operation_data(row)
|
||||||
qty = row.get("qty")
|
qty = row.get("qty")
|
||||||
while qty > 0:
|
while qty > 0:
|
||||||
@@ -1458,6 +1499,21 @@ def make_job_card(work_order, operations):
|
|||||||
create_job_card(work_order, row, auto_create=True)
|
create_job_card(work_order, row, auto_create=True)
|
||||||
|
|
||||||
|
|
||||||
|
def get_operation_details(name, work_order):
|
||||||
|
for row in work_order.operations:
|
||||||
|
if row.name == name:
|
||||||
|
return {
|
||||||
|
"workstation": row.workstation,
|
||||||
|
"workstation_type": row.workstation_type,
|
||||||
|
"source_warehouse": row.source_warehouse,
|
||||||
|
"fg_warehouse": row.fg_warehouse,
|
||||||
|
"wip_warehouse": row.wip_warehouse,
|
||||||
|
"finished_good": row.finished_good,
|
||||||
|
"bom_no": row.get("bom_no"),
|
||||||
|
"is_subcontracted": row.get("is_subcontracted"),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def close_work_order(work_order, status):
|
def close_work_order(work_order, status):
|
||||||
if not frappe.has_permission("Work Order", "write"):
|
if not frappe.has_permission("Work Order", "write"):
|
||||||
@@ -1558,6 +1614,7 @@ def create_job_card(work_order, row, enable_capacity_planning=False, auto_create
|
|||||||
"workstation_type": row.get("workstation_type"),
|
"workstation_type": row.get("workstation_type"),
|
||||||
"operation": row.get("operation"),
|
"operation": row.get("operation"),
|
||||||
"workstation": row.get("workstation"),
|
"workstation": row.get("workstation"),
|
||||||
|
"operation_row_id": cint(row.idx),
|
||||||
"posting_date": nowdate(),
|
"posting_date": nowdate(),
|
||||||
"for_quantity": row.job_card_qty or work_order.get("qty", 0),
|
"for_quantity": row.job_card_qty or work_order.get("qty", 0),
|
||||||
"operation_id": row.get("name"),
|
"operation_id": row.get("name"),
|
||||||
@@ -1565,13 +1622,22 @@ def create_job_card(work_order, row, enable_capacity_planning=False, auto_create
|
|||||||
"project": work_order.project,
|
"project": work_order.project,
|
||||||
"company": work_order.company,
|
"company": work_order.company,
|
||||||
"sequence_id": row.get("sequence_id"),
|
"sequence_id": row.get("sequence_id"),
|
||||||
"wip_warehouse": work_order.wip_warehouse,
|
|
||||||
"hour_rate": row.get("hour_rate"),
|
"hour_rate": row.get("hour_rate"),
|
||||||
"serial_no": row.get("serial_no"),
|
"serial_no": row.get("serial_no"),
|
||||||
|
"source_warehouse": row.get("source_warehouse"),
|
||||||
|
"target_warehouse": row.get("fg_warehouse"),
|
||||||
|
"wip_warehouse": work_order.wip_warehouse or row.get("wip_warehouse"),
|
||||||
|
"skip_material_transfer": row.get("skip_material_transfer"),
|
||||||
|
"backflush_from_wip_warehouse": row.get("backflush_from_wip_warehouse"),
|
||||||
|
"finished_good": row.get("finished_good"),
|
||||||
|
"semi_fg_bom": row.get("bom_no"),
|
||||||
|
"is_subcontracted": row.get("is_subcontracted"),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if work_order.transfer_material_against == "Job Card" and not work_order.skip_transfer:
|
if work_order.track_semi_finished_goods or (
|
||||||
|
work_order.transfer_material_against == "Job Card" and not work_order.skip_transfer
|
||||||
|
):
|
||||||
doc.get_required_items()
|
doc.get_required_items()
|
||||||
|
|
||||||
if auto_create:
|
if auto_create:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
"operation",
|
"operation",
|
||||||
"item_code",
|
"item_code",
|
||||||
"source_warehouse",
|
"source_warehouse",
|
||||||
|
"operation_row_id",
|
||||||
"column_break_3",
|
"column_break_3",
|
||||||
"item_name",
|
"item_name",
|
||||||
"description",
|
"description",
|
||||||
@@ -138,11 +139,17 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Returned Qty ",
|
"label": "Returned Qty ",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "operation_row_id",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "Operation Row Id",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-27 13:11:00.429838",
|
"modified": "2024-03-27 13:12:00.429838",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Work Order Item",
|
"name": "Work Order Item",
|
||||||
|
|||||||
@@ -15,6 +15,16 @@
|
|||||||
"workstation_type",
|
"workstation_type",
|
||||||
"workstation",
|
"workstation",
|
||||||
"sequence_id",
|
"sequence_id",
|
||||||
|
"section_break_insy",
|
||||||
|
"bom_no",
|
||||||
|
"finished_good",
|
||||||
|
"is_subcontracted",
|
||||||
|
"skip_material_transfer",
|
||||||
|
"backflush_from_wip_warehouse",
|
||||||
|
"column_break_vjih",
|
||||||
|
"source_warehouse",
|
||||||
|
"wip_warehouse",
|
||||||
|
"fg_warehouse",
|
||||||
"section_break_10",
|
"section_break_10",
|
||||||
"description",
|
"description",
|
||||||
"estimated_time_and_cost",
|
"estimated_time_and_cost",
|
||||||
@@ -52,7 +62,6 @@
|
|||||||
"columns": 2,
|
"columns": 2,
|
||||||
"fieldname": "bom",
|
"fieldname": "bom",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "BOM",
|
"label": "BOM",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "BOM",
|
"options": "BOM",
|
||||||
@@ -66,11 +75,10 @@
|
|||||||
"oldfieldtype": "Text"
|
"oldfieldtype": "Text"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": 2,
|
"columns": 1,
|
||||||
"description": "Operation completed for how many finished goods?",
|
"description": "Operation completed for how many finished goods?",
|
||||||
"fieldname": "completed_qty",
|
"fieldname": "completed_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Completed Qty",
|
"label": "Completed Qty",
|
||||||
"no_copy": 1
|
"no_copy": 1
|
||||||
},
|
},
|
||||||
@@ -213,16 +221,83 @@
|
|||||||
"columns": 2,
|
"columns": 2,
|
||||||
"fieldname": "process_loss_qty",
|
"fieldname": "process_loss_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Process Loss Qty",
|
"label": "Process Loss Qty",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:parent.track_semi_finished_goods === 1",
|
||||||
|
"fieldname": "section_break_insy",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "bom_no",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "BOM No (For Semi-FG)",
|
||||||
|
"options": "BOM",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_vjih",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "finished_good",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Semi FG / FG",
|
||||||
|
"options": "Item",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 1,
|
||||||
|
"fieldname": "wip_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "WIP WH",
|
||||||
|
"options": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 2,
|
||||||
|
"fieldname": "fg_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "FG Warehouse",
|
||||||
|
"options": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 2,
|
||||||
|
"fieldname": "source_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Source Warehouse",
|
||||||
|
"options": "Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "is_subcontracted",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Is Subcontracted",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "skip_material_transfer",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Skip Material Transfer",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "backflush_from_wip_warehouse",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Backflush Materials From WIP Warehouse",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-27 13:11:00.595376",
|
"modified": "2024-05-26 15:57:17.958543",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Work Order Operation",
|
"name": "Work Order Operation",
|
||||||
|
|||||||
@@ -18,11 +18,16 @@ class WorkOrderOperation(Document):
|
|||||||
actual_operating_cost: DF.Currency
|
actual_operating_cost: DF.Currency
|
||||||
actual_operation_time: DF.Float
|
actual_operation_time: DF.Float
|
||||||
actual_start_time: DF.Datetime | None
|
actual_start_time: DF.Datetime | None
|
||||||
|
backflush_from_wip_warehouse: DF.Check
|
||||||
batch_size: DF.Float
|
batch_size: DF.Float
|
||||||
bom: DF.Link | None
|
bom: DF.Link | None
|
||||||
|
bom_no: DF.Link | None
|
||||||
completed_qty: DF.Float
|
completed_qty: DF.Float
|
||||||
description: DF.TextEditor | None
|
description: DF.TextEditor | None
|
||||||
|
fg_warehouse: DF.Link | None
|
||||||
|
finished_good: DF.Link | None
|
||||||
hour_rate: DF.Float
|
hour_rate: DF.Float
|
||||||
|
is_subcontracted: DF.Check
|
||||||
operation: DF.Link
|
operation: DF.Link
|
||||||
parent: DF.Data
|
parent: DF.Data
|
||||||
parentfield: DF.Data
|
parentfield: DF.Data
|
||||||
@@ -32,8 +37,11 @@ class WorkOrderOperation(Document):
|
|||||||
planned_start_time: DF.Datetime | None
|
planned_start_time: DF.Datetime | None
|
||||||
process_loss_qty: DF.Float
|
process_loss_qty: DF.Float
|
||||||
sequence_id: DF.Int
|
sequence_id: DF.Int
|
||||||
|
skip_material_transfer: DF.Check
|
||||||
|
source_warehouse: DF.Link | None
|
||||||
status: DF.Literal["Pending", "Work in Progress", "Completed"]
|
status: DF.Literal["Pending", "Work in Progress", "Completed"]
|
||||||
time_in_mins: DF.Float
|
time_in_mins: DF.Float
|
||||||
|
wip_warehouse: DF.Link | None
|
||||||
workstation: DF.Link | None
|
workstation: DF.Link | None
|
||||||
workstation_type: DF.Link | None
|
workstation_type: DF.Link | None
|
||||||
# end: auto-generated types
|
# end: auto-generated types
|
||||||
|
|||||||
@@ -105,16 +105,118 @@ class WorkstationDashboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render_job_cards() {
|
render_job_cards() {
|
||||||
let template = frappe.render_template("workstation_job_card", {
|
this.template = frappe.render_template("workstation_job_card", {
|
||||||
data: this.job_cards,
|
data: this.job_cards,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$wrapper.html(template);
|
this.timer_job_cards = {};
|
||||||
|
this.$wrapper.html(this.template);
|
||||||
|
this.setup_qrcode_fields();
|
||||||
this.prepare_timer();
|
this.prepare_timer();
|
||||||
|
this.setup_menu_actions();
|
||||||
this.toggle_job_card();
|
this.toggle_job_card();
|
||||||
this.bind_events();
|
this.bind_events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setup_qrcode_fields() {
|
||||||
|
this.start_job_qrcode = frappe.ui.form.make_control({
|
||||||
|
df: {
|
||||||
|
label: __("Start Job"),
|
||||||
|
fieldtype: "Data",
|
||||||
|
options: "Barcode",
|
||||||
|
placeholder: __("Scan Job Card Qrcode"),
|
||||||
|
},
|
||||||
|
parent: this.$wrapper.find(".qrcode-fields"),
|
||||||
|
render_input: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.start_job_qrcode.$wrapper.addClass("form-column col-sm-6");
|
||||||
|
|
||||||
|
this.start_job_qrcode.$input.on("input", (e) => {
|
||||||
|
clearTimeout(this.start_job_qrcode_search);
|
||||||
|
this.start_job_qrcode_search = setTimeout(() => {
|
||||||
|
let job_card = this.start_job_qrcode.get_value();
|
||||||
|
if (job_card) {
|
||||||
|
this.validate_job_card(job_card, "Open", (job_card, qty) => {
|
||||||
|
this.start_job(job_card);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.start_job_qrcode.set_value("");
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.complete_job_qrcode = frappe.ui.form.make_control({
|
||||||
|
df: {
|
||||||
|
label: __("Complete Job"),
|
||||||
|
fieldtype: "Data",
|
||||||
|
options: "Barcode",
|
||||||
|
placeholder: __("Scan Job Card Qrcode"),
|
||||||
|
},
|
||||||
|
parent: this.$wrapper.find(".qrcode-fields"),
|
||||||
|
render_input: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.complete_job_qrcode.$input.on("input", (e) => {
|
||||||
|
clearTimeout(this.complete_job_qrcode_search);
|
||||||
|
this.complete_job_qrcode_search = setTimeout(() => {
|
||||||
|
let job_card = this.complete_job_qrcode.get_value();
|
||||||
|
if (job_card) {
|
||||||
|
this.validate_job_card(job_card, "Work In Progress", (job_card, qty) => {
|
||||||
|
this.complete_job(job_card, qty);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.complete_job_qrcode.set_value("");
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.complete_job_qrcode.$wrapper.addClass("form-column col-sm-6");
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_job_card(job_card, status, callback) {
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.manufacturing.doctype.workstation.workstation.validate_job_card",
|
||||||
|
args: {
|
||||||
|
job_card: job_card,
|
||||||
|
status: status,
|
||||||
|
},
|
||||||
|
callback(r) {
|
||||||
|
callback(job_card, r.message);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_menu_actions() {
|
||||||
|
let me = this;
|
||||||
|
this.job_cards.forEach((data) => {
|
||||||
|
me.menu_actions = me.$wrapper.find(`.menu-actions[data-job-card='${data.name}']`);
|
||||||
|
$(me.menu_actions).find(".btn-start").hide();
|
||||||
|
$(me.menu_actions).find(".btn-resume").hide();
|
||||||
|
$(me.menu_actions).find(".btn-pause").hide();
|
||||||
|
$(me.menu_actions).find(".btn-complete").hide();
|
||||||
|
|
||||||
|
if (
|
||||||
|
data.for_quantity + data.process_loss_qty > data.total_completed_qty &&
|
||||||
|
(data.skip_material_transfer ||
|
||||||
|
data.transferred_qty >= data.for_quantity + data.process_loss_qty ||
|
||||||
|
!data.finished_good)
|
||||||
|
) {
|
||||||
|
if (!data.time_logs?.length) {
|
||||||
|
$(me.menu_actions).find(".btn-start").show();
|
||||||
|
} else if (data.is_paused) {
|
||||||
|
$(me.menu_actions).find(".btn-resume").show();
|
||||||
|
} else if (data.for_quantity - data.manufactured_qty > 0) {
|
||||||
|
if (!data.is_paused) {
|
||||||
|
$(me.menu_actions).find(".btn-pause").show();
|
||||||
|
}
|
||||||
|
|
||||||
|
$(me.menu_actions).find(".btn-complete").show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
toggle_job_card() {
|
toggle_job_card() {
|
||||||
this.$wrapper.find(".collapse-indicator-job").on("click", (e) => {
|
this.$wrapper.find(".collapse-indicator-job").on("click", (e) => {
|
||||||
$(e.currentTarget)
|
$(e.currentTarget)
|
||||||
@@ -133,106 +235,75 @@ class WorkstationDashboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bind_events() {
|
bind_events() {
|
||||||
this.$wrapper.find(".make-material-request").on("click", (e) => {
|
let me = this;
|
||||||
let job_card = $(e.currentTarget).attr("job-card");
|
|
||||||
|
this.$wrapper.find(".btn-transfer-materials").on("click", (e) => {
|
||||||
|
let job_card = $(e.currentTarget).closest("ul").attr("data-job-card");
|
||||||
this.make_material_request(job_card);
|
this.make_material_request(job_card);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$wrapper.find(".btn-start").on("click", (e) => {
|
this.$wrapper.find(".btn-start").on("click", (e) => {
|
||||||
let job_card = $(e.currentTarget).attr("job-card");
|
let job_card = $(e.currentTarget).closest("ul").attr("data-job-card");
|
||||||
this.start_job(job_card);
|
this.start_job(job_card);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.$wrapper.find(".btn-pause").on("click", (e) => {
|
||||||
|
let job_card = $(e.currentTarget).closest("ul").attr("data-job-card");
|
||||||
|
me.update_job_card(job_card, "pause_job", {
|
||||||
|
end_time: frappe.datetime.now_datetime(),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$wrapper.find(".btn-resume").on("click", (e) => {
|
||||||
|
let job_card = $(e.currentTarget).closest("ul").attr("data-job-card");
|
||||||
|
me.update_job_card(job_card, "resume_job", {
|
||||||
|
start_time: frappe.datetime.now_datetime(),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.$wrapper.find(".btn-complete").on("click", (e) => {
|
this.$wrapper.find(".btn-complete").on("click", (e) => {
|
||||||
let job_card = $(e.currentTarget).attr("job-card");
|
let job_card = $(e.currentTarget).closest("ul").attr("data-job-card");
|
||||||
let pending_qty = flt($(e.currentTarget).attr("pending-qty"));
|
let for_quantity = $(e.currentTarget).attr("data-qty");
|
||||||
this.complete_job(job_card, pending_qty);
|
me.complete_job(job_card, for_quantity);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
start_job(job_card) {
|
start_job(job_card) {
|
||||||
let me = this;
|
let me = this;
|
||||||
frappe.prompt(
|
|
||||||
[
|
let fields = this.get_fields_for_employee();
|
||||||
{
|
|
||||||
fieldtype: "Datetime",
|
this.employee_dialog = frappe.prompt(fields, (values) => {
|
||||||
label: __("Start Time"),
|
me.update_job_card(job_card, "start_timer", values);
|
||||||
fieldname: "start_time",
|
});
|
||||||
reqd: 1,
|
|
||||||
default: frappe.datetime.now_datetime(),
|
let default_employee = this.job_cards[0]?.user_employee;
|
||||||
},
|
if (default_employee) {
|
||||||
{
|
this.employee_dialog.fields_dict.employees.df.data.push({
|
||||||
label: __("Operator"),
|
employee: default_employee,
|
||||||
fieldname: "employee",
|
});
|
||||||
fieldtype: "Link",
|
this.employee_dialog.fields_dict.employees.grid.refresh();
|
||||||
options: "Employee",
|
}
|
||||||
},
|
|
||||||
],
|
|
||||||
(data) => {
|
|
||||||
this.frm.call({
|
|
||||||
method: "start_job",
|
|
||||||
doc: this.frm.doc,
|
|
||||||
args: {
|
|
||||||
job_card: job_card,
|
|
||||||
from_time: data.start_time,
|
|
||||||
employee: data.employee,
|
|
||||||
},
|
|
||||||
callback(r) {
|
|
||||||
if (r.message) {
|
|
||||||
me.job_cards = [r.message];
|
|
||||||
me.prepare_timer();
|
|
||||||
me.update_job_card_details();
|
|
||||||
me.frm.reload_doc();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
__("Enter Value"),
|
|
||||||
__("Start Job")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
complete_job(job_card, qty_to_manufacture) {
|
complete_job(job_card, for_quantity) {
|
||||||
let me = this;
|
|
||||||
let fields = [
|
|
||||||
{
|
|
||||||
fieldtype: "Float",
|
|
||||||
label: __("Completed Quantity"),
|
|
||||||
fieldname: "qty",
|
|
||||||
reqd: 1,
|
|
||||||
default: flt(qty_to_manufacture || 0),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldtype: "Datetime",
|
|
||||||
label: __("End Time"),
|
|
||||||
fieldname: "end_time",
|
|
||||||
default: frappe.datetime.now_datetime(),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
frappe.prompt(
|
frappe.prompt(
|
||||||
fields,
|
{
|
||||||
|
fieldname: "qty",
|
||||||
|
label: __("Completed Quantity"),
|
||||||
|
fieldtype: "Float",
|
||||||
|
reqd: 1,
|
||||||
|
default: flt(for_quantity || 0),
|
||||||
|
},
|
||||||
(data) => {
|
(data) => {
|
||||||
if (data.qty <= 0) {
|
if (flt(data.qty) <= 0) {
|
||||||
frappe.throw(__("Quantity should be greater than 0"));
|
frappe.throw(__("Quantity should be greater than 0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.frm.call({
|
this.update_job_card(job_card, "complete_job_card", {
|
||||||
method: "complete_job",
|
qty: flt(data.qty),
|
||||||
doc: this.frm.doc,
|
end_time: frappe.datetime.now_datetime(),
|
||||||
args: {
|
auto_submit: 1,
|
||||||
job_card: job_card,
|
|
||||||
qty: data.qty,
|
|
||||||
to_time: data.end_time,
|
|
||||||
},
|
|
||||||
callback: function (r) {
|
|
||||||
if (r.message) {
|
|
||||||
me.job_cards = [r.message];
|
|
||||||
me.prepare_timer();
|
|
||||||
me.update_job_card_details();
|
|
||||||
me.frm.reload_doc();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
__("Enter Value"),
|
__("Enter Value"),
|
||||||
@@ -240,26 +311,219 @@ class WorkstationDashboard {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
make_material_request(job_card) {
|
get_fields_for_employee() {
|
||||||
|
let me = this;
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: __("Employee"),
|
||||||
|
fieldname: "employee",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Employee",
|
||||||
|
change() {
|
||||||
|
let employee = this.get_value();
|
||||||
|
let employees = me.employee_dialog.fields_dict.employees.df.data;
|
||||||
|
|
||||||
|
if (employee) {
|
||||||
|
let employee_exists = employees.find((d) => d.employee === employee);
|
||||||
|
|
||||||
|
if (!employee_exists) {
|
||||||
|
me.employee_dialog.fields_dict.employees.df.data.push({
|
||||||
|
employee: employee,
|
||||||
|
});
|
||||||
|
|
||||||
|
me.employee_dialog.fields_dict.employees.grid.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Start Time"),
|
||||||
|
fieldname: "start_time",
|
||||||
|
fieldtype: "Datetime",
|
||||||
|
default: frappe.datetime.now_datetime(),
|
||||||
|
},
|
||||||
|
{ fieldtype: "Section Break" },
|
||||||
|
{
|
||||||
|
label: __("Employees"),
|
||||||
|
fieldname: "employees",
|
||||||
|
fieldtype: "Table",
|
||||||
|
data: [],
|
||||||
|
cannot_add_rows: 1,
|
||||||
|
cannot_delete_rows: 1,
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
label: __("Employee"),
|
||||||
|
fieldname: "employee",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Employee",
|
||||||
|
in_list_view: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
update_job_card(job_card, method, data) {
|
||||||
|
let me = this;
|
||||||
|
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.manufacturing.doctype.job_card.job_card.make_material_request",
|
method: "erpnext.manufacturing.doctype.workstation.workstation.update_job_card",
|
||||||
args: {
|
args: {
|
||||||
source_name: job_card,
|
job_card: job_card,
|
||||||
|
method: method,
|
||||||
|
start_time: data.start_time || "",
|
||||||
|
employees: data.employees || [],
|
||||||
|
end_time: data.end_time || "",
|
||||||
|
qty: data.qty || 0,
|
||||||
|
auto_submit: data.auto_submit || 0,
|
||||||
|
},
|
||||||
|
callback: () => {
|
||||||
|
$.each(me.timer_job_cards, (index, value) => {
|
||||||
|
clearInterval(value);
|
||||||
|
});
|
||||||
|
|
||||||
|
me.frm.reload_doc();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
make_material_request(job_card) {
|
||||||
|
let me = this;
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.manufacturing.doctype.workstation.workstation.get_raw_materials",
|
||||||
|
args: {
|
||||||
|
job_card: job_card,
|
||||||
},
|
},
|
||||||
callback: (r) => {
|
callback: (r) => {
|
||||||
if (r.message) {
|
if (r.message) {
|
||||||
var doc = frappe.model.sync(r.message)[0];
|
me.prepare_materials_modal(r.message, job_card, (job_card) => {
|
||||||
frappe.set_route("Form", doc.doctype, doc.name);
|
frappe.call({
|
||||||
|
method: "erpnext.manufacturing.doctype.job_card.job_card.make_stock_entry",
|
||||||
|
args: {
|
||||||
|
source_name: job_card,
|
||||||
|
},
|
||||||
|
callback: (r) => {
|
||||||
|
var doc = frappe.model.sync(r.message);
|
||||||
|
frappe.set_route("Form", doc[0].doctype, doc[0].name);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prepare_materials_modal(raw_materials, job_card, callback) {
|
||||||
|
let fields = this.get_raw_material_fields(raw_materials);
|
||||||
|
|
||||||
|
this.materials_dialog = new frappe.ui.Dialog({
|
||||||
|
title: "Raw Materials",
|
||||||
|
fields: fields,
|
||||||
|
size: "large",
|
||||||
|
primary_action_label: __("Make Transfer Entry"),
|
||||||
|
primary_action: () => {
|
||||||
|
this.materials_dialog.hide();
|
||||||
|
callback(job_card);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
raw_materials.forEach((row) => {
|
||||||
|
this.materials_dialog.fields_dict.items.df.data.push(row);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.materials_dialog.fields_dict.items.grid.refresh();
|
||||||
|
this.materials_dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
get_raw_material_fields(raw_materials) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: __("Warehouse"),
|
||||||
|
fieldname: "warehouse",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Warehouse",
|
||||||
|
read_only: 1,
|
||||||
|
default: raw_materials[0].warehouse,
|
||||||
|
},
|
||||||
|
{ fieldtype: "Column Break" },
|
||||||
|
{
|
||||||
|
label: __("Skip Material Transfer"),
|
||||||
|
fieldname: "skip_material_transfer",
|
||||||
|
fieldtype: "Check",
|
||||||
|
read_only: 1,
|
||||||
|
default: raw_materials[0].skip_material_transfer,
|
||||||
|
},
|
||||||
|
{ fieldtype: "Section Break" },
|
||||||
|
{
|
||||||
|
label: __("Raw Materials"),
|
||||||
|
fieldname: "items",
|
||||||
|
fieldtype: "Table",
|
||||||
|
cannot_add_rows: 1,
|
||||||
|
cannot_delete_rows: 1,
|
||||||
|
data: [],
|
||||||
|
size: "extra-large",
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
label: __("Item Code"),
|
||||||
|
fieldname: "item_code",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Item",
|
||||||
|
in_list_view: 1,
|
||||||
|
read_only: 1,
|
||||||
|
columns: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("UOM"),
|
||||||
|
fieldname: "uom",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "UOM",
|
||||||
|
in_list_view: 1,
|
||||||
|
read_only: 1,
|
||||||
|
columns: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Reqired Qty"),
|
||||||
|
fieldname: "required_qty",
|
||||||
|
fieldtype: "Float",
|
||||||
|
in_list_view: 1,
|
||||||
|
read_only: 1,
|
||||||
|
columns: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Transferred Qty"),
|
||||||
|
fieldname: "transferred_qty",
|
||||||
|
fieldtype: "Float",
|
||||||
|
in_list_view: 1,
|
||||||
|
read_only: 1,
|
||||||
|
columns: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Available Qty"),
|
||||||
|
fieldname: "stock_qty",
|
||||||
|
fieldtype: "Float",
|
||||||
|
in_list_view: 1,
|
||||||
|
read_only: 1,
|
||||||
|
columns: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Available"),
|
||||||
|
fieldname: "material_availability_status",
|
||||||
|
fieldtype: "Check",
|
||||||
|
in_list_view: 1,
|
||||||
|
read_only: 1,
|
||||||
|
columns: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
prepare_timer() {
|
prepare_timer() {
|
||||||
this.job_cards.forEach((data) => {
|
this.job_cards.forEach((data) => {
|
||||||
if (data.time_logs?.length) {
|
if (data.time_logs?.length) {
|
||||||
data._current_time = this.get_current_time(data);
|
data._current_time = this.get_current_time(data);
|
||||||
if (data.time_logs[cint(data.time_logs.length) - 1].to_time) {
|
if (data.time_logs[cint(data.time_logs.length) - 1].to_time || data.is_paused) {
|
||||||
this.updateStopwatch(data);
|
this.updateStopwatch(data);
|
||||||
} else {
|
} else {
|
||||||
this.initialiseTimer(data);
|
this.initialiseTimer(data);
|
||||||
@@ -283,23 +547,23 @@ class WorkstationDashboard {
|
|||||||
[data-name='${data.name}']`);
|
[data-name='${data.name}']`);
|
||||||
|
|
||||||
$(job_card_selector).find(".job-card-status").text(data.status);
|
$(job_card_selector).find(".job-card-status").text(data.status);
|
||||||
$(job_card_selector).find(".job-card-status").css("backgroundColor", color_map[data.status]);
|
|
||||||
|
|
||||||
if (data.status === "Work In Progress") {
|
["blue", "gray", "green", "orange", "yellow"].forEach((color) => {
|
||||||
$(job_card_selector).find(".btn-start").addClass("hide");
|
$(job_card_selector).find(".job-card-status").removeClass(color);
|
||||||
$(job_card_selector).find(".btn-complete").removeClass("hide");
|
});
|
||||||
} else if (data.status === "Completed") {
|
|
||||||
$(job_card_selector).find(".btn-start").addClass("hide");
|
$(job_card_selector).find(".job-card-status").addClass(data.status_color);
|
||||||
$(job_card_selector).find(".btn-complete").addClass("hide");
|
$(job_card_selector).find(".job-card-status").css("backgroundColor", color_map[data.status]);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initialiseTimer(data) {
|
initialiseTimer(data) {
|
||||||
setInterval(() => {
|
let timeout = setInterval(() => {
|
||||||
data._current_time += 1;
|
data._current_time += 1;
|
||||||
this.updateStopwatch(data);
|
this.updateStopwatch(data);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
this.timer_job_cards[data.name] = timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStopwatch(data) {
|
updateStopwatch(data) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"dashboard_tab",
|
"dashboard_tab",
|
||||||
|
"section_break_mqqv",
|
||||||
"workstation_dashboard",
|
"workstation_dashboard",
|
||||||
"details_tab",
|
"details_tab",
|
||||||
"workstation_name",
|
"workstation_name",
|
||||||
@@ -246,13 +247,18 @@
|
|||||||
"fieldname": "workstation_dashboard",
|
"fieldname": "workstation_dashboard",
|
||||||
"fieldtype": "HTML",
|
"fieldtype": "HTML",
|
||||||
"label": "Workstation Dashboard"
|
"label": "Workstation Dashboard"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_mqqv",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"hide_border": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "icon-wrench",
|
"icon": "icon-wrench",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"image_field": "on_status_image",
|
"image_field": "on_status_image",
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-27 13:11:00.760717",
|
"modified": "2024-06-01 14:48:47.341354",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Workstation",
|
"name": "Workstation",
|
||||||
|
|||||||
@@ -55,7 +55,14 @@ class Workstation(Document):
|
|||||||
hour_rate_electricity: DF.Currency
|
hour_rate_electricity: DF.Currency
|
||||||
hour_rate_labour: DF.Currency
|
hour_rate_labour: DF.Currency
|
||||||
hour_rate_rent: DF.Currency
|
hour_rate_rent: DF.Currency
|
||||||
|
off_status_image: DF.AttachImage | None
|
||||||
|
on_status_image: DF.AttachImage | None
|
||||||
|
parts_per_hour: DF.Float
|
||||||
|
plant_floor: DF.Link | None
|
||||||
production_capacity: DF.Int
|
production_capacity: DF.Int
|
||||||
|
status: DF.Literal["Production", "Off", "Idle", "Problem", "Maintenance", "Setup"]
|
||||||
|
total_working_hours: DF.Float
|
||||||
|
warehouse: DF.Link | None
|
||||||
working_hours: DF.Table[WorkstationWorkingHour]
|
working_hours: DF.Table[WorkstationWorkingHour]
|
||||||
workstation_name: DF.Data
|
workstation_name: DF.Data
|
||||||
workstation_type: DF.Link | None
|
workstation_type: DF.Link | None
|
||||||
@@ -189,7 +196,7 @@ class Workstation(Document):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_job_cards(workstation):
|
def get_job_cards(workstation, job_card=None):
|
||||||
if frappe.has_permission("Job Card", "read"):
|
if frappe.has_permission("Job Card", "read"):
|
||||||
jc_data = frappe.get_all(
|
jc_data = frappe.get_all(
|
||||||
"Job Card",
|
"Job Card",
|
||||||
@@ -200,15 +207,22 @@ def get_job_cards(workstation):
|
|||||||
"operation",
|
"operation",
|
||||||
"total_completed_qty",
|
"total_completed_qty",
|
||||||
"for_quantity",
|
"for_quantity",
|
||||||
|
"process_loss_qty",
|
||||||
|
"finished_good",
|
||||||
"transferred_qty",
|
"transferred_qty",
|
||||||
"status",
|
"status",
|
||||||
"expected_start_date",
|
"expected_start_date",
|
||||||
"expected_end_date",
|
"expected_end_date",
|
||||||
"time_required",
|
"time_required",
|
||||||
"wip_warehouse",
|
"wip_warehouse",
|
||||||
|
"skip_material_transfer",
|
||||||
|
"backflush_from_wip_warehouse",
|
||||||
|
"is_paused",
|
||||||
|
"manufactured_qty",
|
||||||
],
|
],
|
||||||
filters={
|
filters={
|
||||||
"workstation": workstation,
|
"workstation": workstation,
|
||||||
|
"is_subcontracted": 0,
|
||||||
"docstatus": ("<", 2),
|
"docstatus": ("<", 2),
|
||||||
"status": ["not in", ["Completed", "Stopped"]],
|
"status": ["not in", ["Completed", "Stopped"]],
|
||||||
},
|
},
|
||||||
@@ -216,64 +230,98 @@ def get_job_cards(workstation):
|
|||||||
)
|
)
|
||||||
|
|
||||||
job_cards = [row.name for row in jc_data]
|
job_cards = [row.name for row in jc_data]
|
||||||
raw_materials = get_raw_materials(job_cards)
|
|
||||||
time_logs = get_time_logs(job_cards)
|
time_logs = get_time_logs(job_cards)
|
||||||
|
|
||||||
allow_excess_transfer = frappe.db.get_single_value(
|
allow_excess_transfer = frappe.db.get_single_value(
|
||||||
"Manufacturing Settings", "job_card_excess_transfer"
|
"Manufacturing Settings", "job_card_excess_transfer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
user_employee = frappe.db.get_value("Employee", {"user_id": frappe.session.user}, "name")
|
||||||
|
|
||||||
for row in jc_data:
|
for row in jc_data:
|
||||||
row.progress_percent = (
|
item_code = row.finished_good or row.production_item
|
||||||
flt(row.total_completed_qty / row.for_quantity * 100, 2) if row.for_quantity else 0
|
row.fg_uom = frappe.get_cached_value("Item", item_code, "stock_uom")
|
||||||
)
|
|
||||||
row.progress_title = _("Total completed quantity: {0}").format(row.total_completed_qty)
|
|
||||||
row.status_color = get_status_color(row.status)
|
row.status_color = get_status_color(row.status)
|
||||||
row.job_card_link = get_link_to_form("Job Card", row.name)
|
row.job_card_link = f"""
|
||||||
|
<a class="ellipsis" data-doctype="Job Card" data-name="{row.name}" href="/app/job-card/{row.name}" title="" data-original-title="{row.name}">{row.name}</a>
|
||||||
|
"""
|
||||||
|
|
||||||
|
row.operation_link = f"""
|
||||||
|
<a class="ellipsis" data-doctype="Operation" data-name="{row.operation}" href="/app/operation/{row.operation}" title="" data-original-title="{row.operation}">{row.operation}</a>
|
||||||
|
"""
|
||||||
row.work_order_link = get_link_to_form("Work Order", row.work_order)
|
row.work_order_link = get_link_to_form("Work Order", row.work_order)
|
||||||
|
|
||||||
row.raw_materials = raw_materials.get(row.name, [])
|
|
||||||
row.time_logs = time_logs.get(row.name, [])
|
row.time_logs = time_logs.get(row.name, [])
|
||||||
row.make_material_request = False
|
row.make_material_request = False
|
||||||
if row.for_quantity > row.transferred_qty or allow_excess_transfer:
|
if row.for_quantity > row.transferred_qty or allow_excess_transfer:
|
||||||
row.make_material_request = True
|
row.make_material_request = True
|
||||||
|
|
||||||
|
row.user_employee = user_employee
|
||||||
|
|
||||||
return jc_data
|
return jc_data
|
||||||
|
|
||||||
|
|
||||||
def get_status_color(status):
|
def get_status_color(status):
|
||||||
color_map = {
|
color_map = {
|
||||||
"Pending": "var(--bg-blue)",
|
"Pending": "blue",
|
||||||
"In Process": "var(--bg-yellow)",
|
"In Process": "yellow",
|
||||||
"Submitted": "var(--bg-blue)",
|
"Submitted": "blue",
|
||||||
"Open": "var(--bg-gray)",
|
"Open": "gray",
|
||||||
"Closed": "var(--bg-green)",
|
"Closed": "green",
|
||||||
"Work In Progress": "var(--bg-orange)",
|
"Work In Progress": "orange",
|
||||||
}
|
}
|
||||||
|
|
||||||
return color_map.get(status, "var(--bg-blue)")
|
return color_map.get(status, "blue")
|
||||||
|
|
||||||
|
|
||||||
def get_raw_materials(job_cards):
|
@frappe.whitelist()
|
||||||
raw_materials = {}
|
def get_raw_materials(job_card):
|
||||||
|
raw_materials = frappe.get_all(
|
||||||
data = frappe.get_all(
|
"Job Card",
|
||||||
"Job Card Item",
|
|
||||||
fields=[
|
fields=[
|
||||||
"parent",
|
"`tabJob Card`.`skip_material_transfer`",
|
||||||
"item_code",
|
"`tabJob Card`.`backflush_from_wip_warehouse`",
|
||||||
"item_group",
|
"`tabJob Card`.`wip_warehouse`",
|
||||||
"uom",
|
"`tabJob Card Item`.`parent`",
|
||||||
"item_name",
|
"`tabJob Card Item`.`item_code`",
|
||||||
"source_warehouse",
|
"`tabJob Card Item`.`item_group`",
|
||||||
"required_qty",
|
"`tabJob Card Item`.`uom`",
|
||||||
"transferred_qty",
|
"`tabJob Card Item`.`item_name`",
|
||||||
|
"`tabJob Card Item`.`source_warehouse`",
|
||||||
|
"`tabJob Card Item`.`required_qty`",
|
||||||
|
"`tabJob Card Item`.`transferred_qty`",
|
||||||
],
|
],
|
||||||
filters={"parent": ["in", job_cards]},
|
filters={"name": job_card},
|
||||||
)
|
)
|
||||||
|
|
||||||
for row in data:
|
if not raw_materials:
|
||||||
raw_materials.setdefault(row.parent, []).append(row)
|
return []
|
||||||
|
|
||||||
|
for row in raw_materials:
|
||||||
|
warehouse = row.source_warehouse
|
||||||
|
if row.skip_material_transfer and row.backflush_from_wip_warehouse:
|
||||||
|
warehouse = row.wip_warehouse
|
||||||
|
|
||||||
|
row.stock_qty = (
|
||||||
|
frappe.db.get_value(
|
||||||
|
"Bin",
|
||||||
|
{
|
||||||
|
"item_code": row.item_code,
|
||||||
|
"warehouse": warehouse,
|
||||||
|
},
|
||||||
|
"actual_qty",
|
||||||
|
)
|
||||||
|
or 0.0
|
||||||
|
)
|
||||||
|
|
||||||
|
row.warehouse = warehouse
|
||||||
|
|
||||||
|
row.material_availability_status = 0
|
||||||
|
if row.skip_material_transfer and row.stock_qty >= row.required_qty:
|
||||||
|
row.material_availability_status = 1
|
||||||
|
elif row.transferred_qty >= row.required_qty:
|
||||||
|
row.material_availability_status = 1
|
||||||
|
|
||||||
return raw_materials
|
return raw_materials
|
||||||
|
|
||||||
@@ -392,20 +440,57 @@ def get_workstations(**kwargs):
|
|||||||
data = query.run(as_dict=True)
|
data = query.run(as_dict=True)
|
||||||
|
|
||||||
color_map = {
|
color_map = {
|
||||||
"Production": "var(--green-600)",
|
"Production": "green",
|
||||||
"Off": "var(--gray-600)",
|
"Off": "gray",
|
||||||
"Idle": "var(--gray-600)",
|
"Idle": "gray",
|
||||||
"Problem": "var(--red-600)",
|
"Problem": "red",
|
||||||
"Maintenance": "var(--yellow-600)",
|
"Maintenance": "yellow",
|
||||||
"Setup": "var(--blue-600)",
|
"Setup": "blue",
|
||||||
}
|
}
|
||||||
|
|
||||||
for d in data:
|
for d in data:
|
||||||
d.workstation_name = get_link_to_form("Workstation", d.name)
|
d.workstation_name = get_link_to_form("Workstation", d.name)
|
||||||
d.status_image = d.on_status_image
|
d.status_image = d.on_status_image
|
||||||
d.background_color = color_map.get(d.status, "var(--red-600)")
|
d.color = color_map.get(d.status, "red")
|
||||||
d.workstation_link = get_url_to_form("Workstation", d.name)
|
d.workstation_link = get_url_to_form("Workstation", d.name)
|
||||||
if d.status != "Production":
|
if d.status != "Production":
|
||||||
d.status_image = d.off_status_image
|
d.status_image = d.off_status_image
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def update_job_card(job_card, method, **kwargs):
|
||||||
|
if isinstance(kwargs, dict):
|
||||||
|
kwargs = frappe._dict(kwargs)
|
||||||
|
|
||||||
|
if kwargs.get("employees"):
|
||||||
|
kwargs.employees = frappe.parse_json(kwargs.employees)
|
||||||
|
|
||||||
|
if kwargs.qty and isinstance(kwargs.qty, str):
|
||||||
|
kwargs.qty = flt(kwargs.qty)
|
||||||
|
|
||||||
|
doc = frappe.get_doc("Job Card", job_card)
|
||||||
|
doc.run_method(method, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def validate_job_card(job_card, status):
|
||||||
|
job_card_details = frappe.db.get_value("Job Card", job_card, ["status", "for_quantity"], as_dict=1)
|
||||||
|
|
||||||
|
current_status = job_card_details.status
|
||||||
|
if current_status != status:
|
||||||
|
if status == "Open":
|
||||||
|
frappe.throw(
|
||||||
|
_("The job card {0} is in {1} state and you cannot start it again.").format(
|
||||||
|
job_card, current_status
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
frappe.throw(
|
||||||
|
_("The job card {0} is in {1} state and you cannot complete.").format(
|
||||||
|
job_card, current_status
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return job_card_details.for_quantity
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<style>
|
<style>
|
||||||
.job-card-link {
|
.job-card-link {
|
||||||
min-height: 100px;
|
min-height: 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section-head-job-card {
|
.section-head-job-card {
|
||||||
@@ -9,26 +9,31 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div style = "max-height: 400px; overflow-y: auto;">
|
<div>
|
||||||
|
|
||||||
|
<div class="form-dashboard-section qrcode-fields col-sm-12 section-body" style="padding-left: 0px;padding-right: 25px;"></div>
|
||||||
|
|
||||||
{% $.each(data, (idx, d) => { %}
|
{% $.each(data, (idx, d) => { %}
|
||||||
<div class="row form-dashboard-section job-card-link form-links border-gray-200" data-name="{{d.name}}">
|
<div class="row form-dashboard-section job-card-link form-links border-gray-200" data-name="{{d.name}}">
|
||||||
<div class="section-head section-head-job-card">
|
<div class="row form-section" style="width:100%;margin-top:10px">
|
||||||
{{ d.operation }} - {{ d.production_item }}
|
<div class="form-column col-sm-2">
|
||||||
<span class="ml-2 collapse-indicator-job mb-1" style="">
|
<div class="frappe-control bold" data-doctype="Job Card" data-name="{{d.name}}" title="{{__('Job Card ID')}}">
|
||||||
{{frappe.utils.icon("es-line-down", "sm", "mb-1")}}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div class="row form-section" style="width:100%;margin-bottom:10px">
|
|
||||||
<div class="form-column col-sm-3">
|
|
||||||
<div class="frappe-control" title="{{__('Job Card')}}" style="text-decoration:underline">
|
|
||||||
{{ d.job_card_link }}
|
{{ d.job_card_link }}
|
||||||
</div>
|
</div>
|
||||||
<div class="frappe-control" title="{{__('Work Order')}}" style="text-decoration:underline">
|
|
||||||
{{ d.work_order_link }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-column col-sm-2">
|
<div class="form-column col-sm-2">
|
||||||
<div class="frappe-control timer" title="{{__('Timer')}}" style="text-align:center;font-size:14px;" data-job-card = {{escape(d.name)}}>
|
<div class="frappe-control" title="{{__('Item')}}">{{ d.finished_good || d.production_item }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-column col-sm-1">
|
||||||
|
<div class="frappe-control" title="{{__('Qty')}}">{{ d.for_quantity }} {{ d.fg_uom }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-column col-sm-2 ellipsis">
|
||||||
|
<div class="frappe-control" title="{{__('Operation')}}">
|
||||||
|
{{ d.operation_link }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-column col-sm-2">
|
||||||
|
<div class="frappe-control timer" title="{{__('Timer')}}" style="font-size:14px;" data-job-card = {{escape(d.name)}}>
|
||||||
<span class="hours">00</span>
|
<span class="hours">00</span>
|
||||||
<span class="colon">:</span>
|
<span class="colon">:</span>
|
||||||
<span class="minutes">00</span>
|
<span class="minutes">00</span>
|
||||||
@@ -36,7 +41,7 @@
|
|||||||
<span class="seconds">00</span>
|
<span class="seconds">00</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if(d.status === "Open") { %}
|
<!-- {% if(d.status === "Open") { %}
|
||||||
<div class="frappe-control" title="{{__('Expected Start Date')}}" style="text-align:center;font-size:11px;padding-top: 4px;">
|
<div class="frappe-control" title="{{__('Expected Start Date')}}" style="text-align:center;font-size:11px;padding-top: 4px;">
|
||||||
{{ frappe.format(d.expected_start_date, { fieldtype: 'Datetime' }) }}
|
{{ frappe.format(d.expected_start_date, { fieldtype: 'Datetime' }) }}
|
||||||
</div>
|
</div>
|
||||||
@@ -44,82 +49,60 @@
|
|||||||
<div class="frappe-control" title="{{__('Expected End Date')}}" style="text-align:center;font-size:11px;padding-top: 4px;">
|
<div class="frappe-control" title="{{__('Expected End Date')}}" style="text-align:center;font-size:11px;padding-top: 4px;">
|
||||||
{{ frappe.format(d.expected_end_date, { fieldtype: 'Datetime' }) }}
|
{{ frappe.format(d.expected_end_date, { fieldtype: 'Datetime' }) }}
|
||||||
</div>
|
</div>
|
||||||
{% } %}
|
{% } %} -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-column col-sm-2">
|
<div class="form-column col-sm-2">
|
||||||
<div class="frappe-control job-card-status" title="{{__('Status')}}" style="background:{{d.status_color}};text-align:center;border-radius:var(--border-radius-full)">
|
<div class="frappe-control indicator-pill no-indicator-dot whitespace-nowrap job-card-status {{d.status_color}}" title="{{__('Status')}}">
|
||||||
{{ d.status }}
|
{% if(d.status === "Open") { %}
|
||||||
|
{{__("Not Started")}}
|
||||||
|
{% } else { %}
|
||||||
|
{{ __(d.status) }}
|
||||||
|
{% } %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-column col-sm-2">
|
<div class="form-column col-sm-1">
|
||||||
<div class="frappe-control" title="{{__('Qty to Manufacture')}}">
|
<div class="menu-btn-group">
|
||||||
<div class="progress" title = "{{d.progress_title}}">
|
<button type="button" class="btn btn-default icon-btn" data-toggle="dropdown" aria-expanded="false" aria-label="{{ __("Menu") }}">
|
||||||
<div class="progress-bar progress-bar-success" style="width: {{d.progress_percent}}%">
|
<span>
|
||||||
</div>
|
<span class="menu-btn-group-label">
|
||||||
</div>
|
<svg class="icon icon-sm">
|
||||||
|
<use href="#icon-dot-vertical">
|
||||||
|
</use>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu dropdown-menu-right menu-actions" role="menu" data-job-card="{{d.name}}">
|
||||||
|
<li>
|
||||||
|
<a class="grey-link dropdown-item btn-start" href="#" onclick="return false;">
|
||||||
|
<span class="menu-item-label" data-label="Start">{{ __('Start') }}</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a class="grey-link dropdown-item btn-resume" href="#" onclick="return false;">
|
||||||
|
<span class="menu-item-label" data-label="Resume">{{ __('Resume') }}</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a class="grey-link dropdown-item btn-pause" href="#" onclick="return false;">
|
||||||
|
<span class="menu-item-label" data-label="Pause">{{ __('Pause') }}</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a class="grey-link dropdown-item btn-complete" href="#" onclick="return false;" data-qty="{{d.for_quantity}}">
|
||||||
|
<span class="menu-item-label" data-label="Complete">{{ __('Complete') }}</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a class="grey-link dropdown-item btn-transfer-materials" href="#" onclick="return false;">
|
||||||
|
<span class="menu-item-label" data-label="Transfer Materials">{{ __('Transfer Materials') }}</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="frappe-control" style="text-align: center; font-size: 10px;">
|
|
||||||
{{ d.for_quantity }} / {{ d.total_completed_qty }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-column col-sm-2 text-center">
|
|
||||||
<button style="width: 85px;" class="btn btn-default btn-start {% if(d.status !== "Open") { %} hide {% } %}" job-card="{{d.name}}"> {{__("Start")}} </button>
|
|
||||||
<button style="width: 85px;" class="btn btn-default btn-complete {% if(d.status === "Open") { %} hide {% } %}" job-card="{{d.name}}" pending-qty="{{d.for_quantity - d.transferred_qty}}"> {{__("Complete")}} </button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="section-body section-body-job-card form-section hide">
|
|
||||||
<hr>
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-column col-sm-2">
|
|
||||||
{{ __("Raw Materials") }}
|
|
||||||
</div>
|
|
||||||
{% if(d.make_material_request) { %}
|
|
||||||
<div class="form-column col-sm-10 text-right">
|
|
||||||
<button class="btn btn-default btn-xs make-material-request" job-card="{{d.name}}">{{ __("Material Request") }}</button>
|
|
||||||
</div>
|
|
||||||
{% } %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if(d.raw_materials) { %}
|
|
||||||
<table class="table table-bordered table-condensed">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="width: 5%" class="table-sr">Sr</th>
|
|
||||||
|
|
||||||
<th style="width: 15%">{{ __("Item") }}</th>
|
|
||||||
<th style="width: 15%">{{ __("Warehouse") }}</th>
|
|
||||||
<th style="width: 10%">{{__("UOM")}}</th>
|
|
||||||
<th style="width: 15%">{{__("Item Group")}}</th>
|
|
||||||
<th style="width: 20%" >{{__("Required Qty")}}</th>
|
|
||||||
<th style="width: 20%" >{{__("Transferred Qty")}}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
{% $.each(d.raw_materials, (row_index, child_row) => { %}
|
|
||||||
<tr>
|
|
||||||
<td class="table-sr">{{ row_index+1 }}</td>
|
|
||||||
{% if(child_row.item_code === child_row.item_name) { %}
|
|
||||||
<td>{{ child_row.item_code }}</td>
|
|
||||||
{% } else { %}
|
|
||||||
<td>{{ child_row.item_code }}: {{child_row.item_name}}</td>
|
|
||||||
{% } %}
|
|
||||||
<td>{{ child_row.source_warehouse }}</td>
|
|
||||||
<td>{{ child_row.uom }}</td>
|
|
||||||
<td>{{ child_row.item_group }}</td>
|
|
||||||
<td>{{ child_row.required_qty }}</td>
|
|
||||||
<td>{{ child_row.transferred_qty }}</td>
|
|
||||||
</tr>
|
|
||||||
{% }); %}
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
{% } %}
|
|
||||||
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% }); %}
|
{% }); %}
|
||||||
</div>
|
</div>
|
||||||
@@ -368,3 +368,4 @@ erpnext.patches.v15_0.fix_debit_credit_in_transaction_currency
|
|||||||
erpnext.patches.v15_0.rename_purchase_receipt_amount_to_purchase_amount
|
erpnext.patches.v15_0.rename_purchase_receipt_amount_to_purchase_amount
|
||||||
erpnext.patches.v14_0.enable_set_priority_for_pricing_rules #1
|
erpnext.patches.v14_0.enable_set_priority_for_pricing_rules #1
|
||||||
erpnext.patches.v15_0.rename_number_of_depreciations_booked_to_opening_booked_depreciations
|
erpnext.patches.v15_0.rename_number_of_depreciations_booked_to_opening_booked_depreciations
|
||||||
|
erpnext.patches.v15_0.add_default_operations
|
||||||
|
|||||||
5
erpnext/patches/v15_0/add_default_operations.py
Normal file
5
erpnext/patches/v15_0/add_default_operations.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from erpnext.setup.install import make_default_operations
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
make_default_operations()
|
||||||
@@ -33,10 +33,11 @@ class BOMConfigurator {
|
|||||||
frm: this.frm,
|
frm: this.frm,
|
||||||
add_item: this.add_item,
|
add_item: this.add_item,
|
||||||
add_sub_assembly: this.add_sub_assembly,
|
add_sub_assembly: this.add_sub_assembly,
|
||||||
|
set_query_for_workstation: this.set_query_for_workstation,
|
||||||
get_sub_assembly_modal_fields: this.get_sub_assembly_modal_fields,
|
get_sub_assembly_modal_fields: this.get_sub_assembly_modal_fields,
|
||||||
convert_to_sub_assembly: this.convert_to_sub_assembly,
|
convert_to_sub_assembly: this.convert_to_sub_assembly,
|
||||||
delete_node: this.delete_node,
|
delete_node: this.delete_node,
|
||||||
edit_qty: this.edit_qty,
|
edit_bom: this.edit_bom,
|
||||||
load_tree: this.load_tree,
|
load_tree: this.load_tree,
|
||||||
set_default_qty: this.set_default_qty,
|
set_default_qty: this.set_default_qty,
|
||||||
};
|
};
|
||||||
@@ -107,15 +108,15 @@ class BOMConfigurator {
|
|||||||
this.frm?.doc.docstatus === 0
|
this.frm?.doc.docstatus === 0
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
label: `${frappe.utils.icon("edit", "sm")} ${__("Qty")}`,
|
label: __(frappe.utils.icon("edit", "sm") + " BOM"),
|
||||||
click: function (node) {
|
click: function (node) {
|
||||||
let view = frappe.views.trees["BOM Configurator"];
|
let view = frappe.views.trees["BOM Configurator"];
|
||||||
view.events.edit_qty(node, view);
|
view.events.edit_bom(node, view);
|
||||||
},
|
},
|
||||||
btnClass: "hidden-xs",
|
btnClass: "hidden-xs",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: `${frappe.utils.icon("add", "sm")} ${__("Raw Material")}`,
|
label: __(frappe.utils.icon("add", "sm") + " Raw Material"),
|
||||||
click: function (node) {
|
click: function (node) {
|
||||||
let view = frappe.views.trees["BOM Configurator"];
|
let view = frappe.views.trees["BOM Configurator"];
|
||||||
view.events.add_item(node, view);
|
view.events.add_item(node, view);
|
||||||
@@ -126,7 +127,7 @@ class BOMConfigurator {
|
|||||||
btnClass: "hidden-xs",
|
btnClass: "hidden-xs",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: `${frappe.utils.icon("add", "sm")} ${__("Sub Assembly")}`,
|
label: __(frappe.utils.icon("add", "sm") + " Sub Assembly"),
|
||||||
click: function (node) {
|
click: function (node) {
|
||||||
let view = frappe.views.trees["BOM Configurator"];
|
let view = frappe.views.trees["BOM Configurator"];
|
||||||
view.events.add_sub_assembly(node, view);
|
view.events.add_sub_assembly(node, view);
|
||||||
@@ -156,7 +157,7 @@ class BOMConfigurator {
|
|||||||
btnClass: "hidden-xs expand-all-btn",
|
btnClass: "hidden-xs expand-all-btn",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: `${frappe.utils.icon("move", "sm")} ${__("Sub Assembly")}`,
|
label: __(frappe.utils.icon("move", "sm") + " Sub Assembly"),
|
||||||
click: function (node) {
|
click: function (node) {
|
||||||
let view = frappe.views.trees["BOM Configurator"];
|
let view = frappe.views.trees["BOM Configurator"];
|
||||||
view.events.convert_to_sub_assembly(node, view);
|
view.events.convert_to_sub_assembly(node, view);
|
||||||
@@ -167,7 +168,7 @@ class BOMConfigurator {
|
|||||||
btnClass: "hidden-xs",
|
btnClass: "hidden-xs",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: `${frappe.utils.icon("delete", "sm")} ${__("Item")}`,
|
label: __(frappe.utils.icon("delete", "sm") + " Item"),
|
||||||
click: function (node) {
|
click: function (node) {
|
||||||
let view = frappe.views.trees["BOM Configurator"];
|
let view = frappe.views.trees["BOM Configurator"];
|
||||||
view.events.delete_node(node, view);
|
view.events.delete_node(node, view);
|
||||||
@@ -232,18 +233,38 @@ class BOMConfigurator {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_query_for_workstation(dialog) {
|
||||||
|
let workstation = dialog.fields.filter((field) => field.fieldname === "workstation");
|
||||||
|
if (workstation.length) {
|
||||||
|
workstation[0].get_query = function () {
|
||||||
|
let workstation_type = dialog.get_value("workstation_type");
|
||||||
|
|
||||||
|
if (workstation_type) {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
workstation_type: dialog.get_value("workstation_type"),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
add_sub_assembly(node, view) {
|
add_sub_assembly(node, view) {
|
||||||
let dialog = new frappe.ui.Dialog({
|
let dialog = new frappe.ui.Dialog({
|
||||||
fields: view.events.get_sub_assembly_modal_fields(),
|
fields: view.events.get_sub_assembly_modal_fields(view, node.is_root),
|
||||||
title: __("Add Sub Assembly"),
|
title: __("Add Sub Assembly"),
|
||||||
});
|
});
|
||||||
|
view.events.set_query_for_workstation(dialog);
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
view.events.set_default_qty(dialog);
|
|
||||||
|
|
||||||
dialog.set_primary_action(__("Add"), () => {
|
dialog.set_primary_action(__("Add"), () => {
|
||||||
let bom_item = dialog.get_values();
|
let bom_item = dialog.get_values();
|
||||||
|
|
||||||
|
if (dialog.operation && !dialog.workstation_type && !dialog.workstation) {
|
||||||
|
frappe.throw(__("Either Workstation or Workstation Type is mandatory"));
|
||||||
|
}
|
||||||
|
|
||||||
if (!node.data?.parent_id) {
|
if (!node.data?.parent_id) {
|
||||||
node.data.parent_id = this.frm.doc.name;
|
node.data.parent_id = this.frm.doc.name;
|
||||||
}
|
}
|
||||||
@@ -255,6 +276,9 @@ class BOMConfigurator {
|
|||||||
fg_item: node.data.value,
|
fg_item: node.data.value,
|
||||||
fg_reference_id: node.data.name || this.frm.doc.name,
|
fg_reference_id: node.data.name || this.frm.doc.name,
|
||||||
bom_item: bom_item,
|
bom_item: bom_item,
|
||||||
|
operation: node.data.operation,
|
||||||
|
workstation_type: node.data.workstation_type,
|
||||||
|
operation_time: node.data.operation_time,
|
||||||
},
|
},
|
||||||
callback: (r) => {
|
callback: (r) => {
|
||||||
view.events.load_tree(r, node);
|
view.events.load_tree(r, node);
|
||||||
@@ -265,8 +289,8 @@ class BOMConfigurator {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get_sub_assembly_modal_fields(read_only = false) {
|
get_sub_assembly_modal_fields(view, is_root = false, read_only = false, show_operations_fields = false) {
|
||||||
return [
|
let fields = [
|
||||||
{
|
{
|
||||||
label: __("Sub Assembly Item"),
|
label: __("Sub Assembly Item"),
|
||||||
fieldname: "item_code",
|
fieldname: "item_code",
|
||||||
@@ -284,37 +308,150 @@ class BOMConfigurator {
|
|||||||
reqd: 1,
|
reqd: 1,
|
||||||
read_only: read_only,
|
read_only: read_only,
|
||||||
},
|
},
|
||||||
{ fieldtype: "Section Break" },
|
|
||||||
{
|
|
||||||
label: __("Raw Materials"),
|
|
||||||
fieldname: "items",
|
|
||||||
fieldtype: "Table",
|
|
||||||
reqd: 1,
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
label: __("Item"),
|
|
||||||
fieldname: "item_code",
|
|
||||||
fieldtype: "Link",
|
|
||||||
options: "Item",
|
|
||||||
reqd: 1,
|
|
||||||
in_list_view: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: __("Qty"),
|
|
||||||
fieldname: "qty",
|
|
||||||
default: 1.0,
|
|
||||||
fieldtype: "Float",
|
|
||||||
reqd: 1,
|
|
||||||
in_list_view: 1,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (this.frm.doc.track_operations && (is_root || show_operations_fields)) {
|
||||||
|
fields.push(
|
||||||
|
...[
|
||||||
|
{ fieldtype: "Section Break" },
|
||||||
|
{
|
||||||
|
label: __("Operation"),
|
||||||
|
fieldname: "operation",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Operation",
|
||||||
|
reqd: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Operation Time"),
|
||||||
|
fieldname: "operation_time",
|
||||||
|
fieldtype: "Int",
|
||||||
|
reqd: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Is Subcontracted"),
|
||||||
|
fieldname: "is_subcontracted",
|
||||||
|
fieldtype: "Check",
|
||||||
|
},
|
||||||
|
{ fieldtype: "Column Break" },
|
||||||
|
{
|
||||||
|
label: __("Workstation Type"),
|
||||||
|
fieldname: "workstation_type",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Workstation Type",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Workstation"),
|
||||||
|
fieldname: "workstation",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Workstation",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.frm.doc.track_semi_finished_goods) {
|
||||||
|
fields.push(
|
||||||
|
...[
|
||||||
|
{ label: __("Default Warehouse"), fieldtype: "Section Break", collapsible: 1 },
|
||||||
|
{
|
||||||
|
label: __("Skip Material Transfer"),
|
||||||
|
fieldname: "skip_material_transfer",
|
||||||
|
fieldtype: "Check",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Backflush Materials From WIP"),
|
||||||
|
fieldname: "backflush_from_wip_warehouse",
|
||||||
|
fieldtype: "Check",
|
||||||
|
depends_on: "eval:doc.skip_material_transfer",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Source Warehouse"),
|
||||||
|
fieldname: "source_warehouse",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Warehouse",
|
||||||
|
depends_on: "eval:!doc.backflush_from_wip_warehouse",
|
||||||
|
get_query() {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
company: view.events.frm.doc.company,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ fieldtype: "Column Break" },
|
||||||
|
{
|
||||||
|
label: __("Work In Progress Warehouse"),
|
||||||
|
fieldname: "wip_warehouse",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Warehouse",
|
||||||
|
depends_on:
|
||||||
|
"eval:!doc.skip_material_transfer || doc.backflush_from_wip_warehouse",
|
||||||
|
get_query() {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
company: view.events.frm.doc.company,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Finished Good Warehouse"),
|
||||||
|
fieldname: "fg_warehouse",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Warehouse",
|
||||||
|
get_query() {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
company: view.events.frm.doc.company,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fields.push(
|
||||||
|
...[
|
||||||
|
{ fieldtype: "Section Break" },
|
||||||
|
{
|
||||||
|
label: __("Raw Materials"),
|
||||||
|
fieldname: "items",
|
||||||
|
fieldtype: "Table",
|
||||||
|
reqd: 1,
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
label: __("Item"),
|
||||||
|
fieldname: "item_code",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Item",
|
||||||
|
reqd: 1,
|
||||||
|
in_list_view: 1,
|
||||||
|
change() {
|
||||||
|
let doc = this.doc;
|
||||||
|
doc.qty = 1.0;
|
||||||
|
this.grid.set_value("qty", 1.0, doc);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Qty"),
|
||||||
|
fieldname: "qty",
|
||||||
|
default: 1.0,
|
||||||
|
fieldtype: "Float",
|
||||||
|
reqd: 1,
|
||||||
|
in_list_view: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_to_sub_assembly(node, view) {
|
convert_to_sub_assembly(node, view) {
|
||||||
let dialog = new frappe.ui.Dialog({
|
let dialog = new frappe.ui.Dialog({
|
||||||
fields: view.events.get_sub_assembly_modal_fields(true),
|
fields: view.events.get_sub_assembly_modal_fields(view, node.is_root, true, true),
|
||||||
title: __("Add Sub Assembly"),
|
title: __("Add Sub Assembly"),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -324,11 +461,13 @@ class BOMConfigurator {
|
|||||||
});
|
});
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
view.events.set_default_qty(dialog);
|
|
||||||
|
|
||||||
dialog.set_primary_action(__("Add"), () => {
|
dialog.set_primary_action(__("Add"), () => {
|
||||||
let bom_item = dialog.get_values();
|
let bom_item = dialog.get_values();
|
||||||
|
|
||||||
|
if (dialog.operation && !dialog.workstation_type && !dialog.workstation) {
|
||||||
|
frappe.throw(__("Either Workstation or Workstation Type is mandatory"));
|
||||||
|
}
|
||||||
|
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.manufacturing.doctype.bom_creator.bom_creator.add_sub_assembly",
|
method: "erpnext.manufacturing.doctype.bom_creator.bom_creator.add_sub_assembly",
|
||||||
args: {
|
args: {
|
||||||
@@ -337,10 +476,14 @@ class BOMConfigurator {
|
|||||||
bom_item: bom_item,
|
bom_item: bom_item,
|
||||||
fg_reference_id: node.data.name || this.frm.doc.name,
|
fg_reference_id: node.data.name || this.frm.doc.name,
|
||||||
convert_to_sub_assembly: true,
|
convert_to_sub_assembly: true,
|
||||||
|
operation: node.data.operation,
|
||||||
|
workstation_type: node.data.workstation_type,
|
||||||
|
operation_time: node.data.operation_time,
|
||||||
|
workstation: node.data.workstation,
|
||||||
},
|
},
|
||||||
callback: (r) => {
|
callback: (r) => {
|
||||||
node.expandable = true;
|
node.expandable = true;
|
||||||
view.events.load_tree(r, node);
|
view.events.load_tree(r, node.parent_node);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -376,24 +519,146 @@ class BOMConfigurator {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
edit_qty(node, view) {
|
edit_bom(node, view) {
|
||||||
|
let me = this;
|
||||||
let qty = node.data.qty || this.frm.doc.qty;
|
let qty = node.data.qty || this.frm.doc.qty;
|
||||||
frappe.prompt(
|
let fields = [{ label: __("Qty"), fieldname: "qty", default: qty, fieldtype: "Float", reqd: 1 }];
|
||||||
[{ label: __("Qty"), fieldname: "qty", default: qty, fieldtype: "Float", reqd: 1 }],
|
|
||||||
|
if (node.expandable && this.frm.doc.track_operations) {
|
||||||
|
let data = node.data.operation ? node.data : this.frm.doc;
|
||||||
|
|
||||||
|
fields = [
|
||||||
|
...fields,
|
||||||
|
...[
|
||||||
|
{ fieldtype: "Section Break" },
|
||||||
|
{
|
||||||
|
label: __("Operation"),
|
||||||
|
fieldname: "operation",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Operation",
|
||||||
|
default: data.operation,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Operation Time"),
|
||||||
|
fieldname: "operation_time",
|
||||||
|
fieldtype: "Float",
|
||||||
|
default: data.operation_time,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Is Subcontracted"),
|
||||||
|
fieldname: "is_subcontracted",
|
||||||
|
fieldtype: "Check",
|
||||||
|
default: data.is_subcontracted,
|
||||||
|
},
|
||||||
|
{ fieldtype: "Column Break" },
|
||||||
|
{
|
||||||
|
label: __("Workstation Type"),
|
||||||
|
fieldname: "workstation_type",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Workstation Type",
|
||||||
|
default: data.workstation_type,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Workstation"),
|
||||||
|
fieldname: "workstation",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Workstation",
|
||||||
|
default: data.workstation,
|
||||||
|
get_query() {
|
||||||
|
let dialog = me.frm.edit_bom_dialog;
|
||||||
|
let workstation_type = dialog.get_value("workstation_type");
|
||||||
|
|
||||||
|
if (workstation_type) {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
workstation_type: dialog.get_value("workstation_type"),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ fieldtype: "Section Break" },
|
||||||
|
{
|
||||||
|
label: __("Skip Material Transfer"),
|
||||||
|
fieldname: "skip_material_transfer",
|
||||||
|
fieldtype: "Check",
|
||||||
|
default: data.skip_material_transfer,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Backflush Materials From WIP"),
|
||||||
|
fieldname: "backflush_from_wip_warehouse",
|
||||||
|
fieldtype: "Check",
|
||||||
|
depends_on: "eval:doc.skip_material_transfer",
|
||||||
|
default: data.backflush_from_wip_warehouse,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Source Warehouse"),
|
||||||
|
fieldname: "source_warehouse",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Warehouse",
|
||||||
|
default: data.source_warehouse,
|
||||||
|
depends_on: "eval:!doc.backflush_from_wip_warehouse",
|
||||||
|
get_query() {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
company: me.frm.doc.company,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ fieldtype: "Column Break" },
|
||||||
|
{
|
||||||
|
label: __("Work In Progress Warehouse"),
|
||||||
|
fieldname: "wip_warehouse",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Warehouse",
|
||||||
|
default: data.wip_warehouse,
|
||||||
|
depends_on: "eval:!doc.skip_material_transfer || doc.backflush_from_wip_warehouse",
|
||||||
|
get_query() {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
company: me.frm.doc.company,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Finished Good Warehouse"),
|
||||||
|
fieldname: "fg_warehouse",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Warehouse",
|
||||||
|
default: data.fg_warehouse,
|
||||||
|
get_query() {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
company: me.frm.doc.company,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.frm.edit_bom_dialog = frappe.prompt(
|
||||||
|
fields,
|
||||||
(data) => {
|
(data) => {
|
||||||
let doctype = node.data.doctype || this.frm.doc.doctype;
|
let doctype = node.data.doctype || this.frm.doc.doctype;
|
||||||
let docname = node.data.name || this.frm.doc.name;
|
let docname = node.data.name || this.frm.doc.name;
|
||||||
|
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.manufacturing.doctype.bom_creator.bom_creator.edit_qty",
|
method: "erpnext.manufacturing.doctype.bom_creator.bom_creator.edit_bom_creator",
|
||||||
args: {
|
args: {
|
||||||
doctype: doctype,
|
doctype: doctype,
|
||||||
docname: docname,
|
docname: docname,
|
||||||
qty: data.qty,
|
data: data,
|
||||||
parent: node.data.parent_id,
|
parent: node.data.parent_id || this.frm.doc.name,
|
||||||
},
|
},
|
||||||
callback: (r) => {
|
callback: (r) => {
|
||||||
node.data.qty = data.qty;
|
for (let key in data) {
|
||||||
|
node.data[key] = data[key];
|
||||||
|
}
|
||||||
|
|
||||||
let uom = node.data.uom || this.frm.doc.uom;
|
let uom = node.data.uom || this.frm.doc.uom;
|
||||||
$(node.parent.get(0))
|
$(node.parent.get(0))
|
||||||
.find(`[data-bom-qty-docname='${docname}']`)
|
.find(`[data-bom-qty-docname='${docname}']`)
|
||||||
@@ -402,7 +667,7 @@ class BOMConfigurator {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
__("Edit Qty"),
|
__("Edit BOM"),
|
||||||
__("Update")
|
__("Update")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
{% $.each(workstations, (idx, row) => { %}
|
{% $.each(workstations, (idx, row) => { %}
|
||||||
<div class="workstation-wrapper">
|
<div class="workstation-wrapper">
|
||||||
|
<div class="workstation-status text-right">
|
||||||
|
<span class="indicator-pill no-indicator-dot whitespace-nowrap {{row.color}}" style="margin: 3px 4px 0px 0px;"><span style="font-size:13px">{{row.status}}</span></span>
|
||||||
|
</div>
|
||||||
<div class="workstation-image">
|
<div class="workstation-image">
|
||||||
<div class="flex items-center justify-center h-32 border-b-grey text-6xl text-grey-100">
|
<div class="flex items-center justify-center h-32 border-b-grey text-6xl text-grey-100">
|
||||||
<a class="workstation-image-link" href="{{row.workstation_link}}">
|
<a class="workstation-image-link" href="{{row.workstation_link}}">
|
||||||
@@ -11,9 +14,10 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="workstation-card text-center">
|
<div class="workstation-card" style="display: grid;">
|
||||||
<p style="background-color:{{row.background_color}};color:#fff">{{row.status}}</p>
|
<span class="ellipsis" title="{{row.name}}">
|
||||||
<div>{{row.workstation_name}}</div>
|
{{row.workstation_name}}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% }); %}
|
{% }); %}
|
||||||
@@ -511,6 +511,10 @@ body[data-route="pos"] {
|
|||||||
padding-bottom: 25px;
|
padding-bottom: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.workstation-image-cls {
|
||||||
|
height: 9rem;
|
||||||
|
}
|
||||||
|
|
||||||
.plant-floor-filter {
|
.plant-floor-filter {
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -519,8 +523,8 @@ body[data-route="pos"] {
|
|||||||
|
|
||||||
.plant-floor-container {
|
.plant-floor-container {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||||
gap: var(--margin-xl);
|
gap: var(--margin-lg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 620px) {
|
@media screen and (max-width: 620px) {
|
||||||
@@ -536,7 +540,7 @@ body[data-route="pos"] {
|
|||||||
.plant-floor-container .workstation-image-link {
|
.plant-floor-container .workstation-image-link {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
font-size: 50px;
|
font-size: 50px;
|
||||||
margin: var(--margin-sm);
|
margin: var(--margin-xs);
|
||||||
min-height: 9rem;
|
min-height: 9rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ def after_install():
|
|||||||
add_standard_navbar_items()
|
add_standard_navbar_items()
|
||||||
add_app_name()
|
add_app_name()
|
||||||
update_roles()
|
update_roles()
|
||||||
|
make_default_operations()
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
|
|
||||||
@@ -42,6 +43,14 @@ You can reinstall this site (after saving your data) using: bench --site [sitena
|
|||||||
frappe.throw(message) # nosemgrep
|
frappe.throw(message) # nosemgrep
|
||||||
|
|
||||||
|
|
||||||
|
def make_default_operations():
|
||||||
|
for operation in ["Assembly"]:
|
||||||
|
if not frappe.db.exists("Operation", operation):
|
||||||
|
doc = frappe.get_doc({"doctype": "Operation", "name": operation})
|
||||||
|
doc.flags.ignore_mandatory = True
|
||||||
|
doc.insert(ignore_permissions=True)
|
||||||
|
|
||||||
|
|
||||||
def set_single_defaults():
|
def set_single_defaults():
|
||||||
for dt in (
|
for dt in (
|
||||||
"Accounts Settings",
|
"Accounts Settings",
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
"purpose",
|
"purpose",
|
||||||
"add_to_transit",
|
"add_to_transit",
|
||||||
"work_order",
|
"work_order",
|
||||||
|
"job_card",
|
||||||
"purchase_order",
|
"purchase_order",
|
||||||
"subcontracting_order",
|
"subcontracting_order",
|
||||||
"delivery_note_no",
|
"delivery_note_no",
|
||||||
@@ -79,7 +80,6 @@
|
|||||||
"col5",
|
"col5",
|
||||||
"per_transferred",
|
"per_transferred",
|
||||||
"total_amount",
|
"total_amount",
|
||||||
"job_card",
|
|
||||||
"amended_from",
|
"amended_from",
|
||||||
"credit_note",
|
"credit_note",
|
||||||
"is_return"
|
"is_return"
|
||||||
|
|||||||
@@ -211,7 +211,10 @@ class StockEntry(StockController):
|
|||||||
|
|
||||||
if self.purpose in ("Manufacture", "Repack"):
|
if self.purpose in ("Manufacture", "Repack"):
|
||||||
self.mark_finished_and_scrap_items()
|
self.mark_finished_and_scrap_items()
|
||||||
self.validate_finished_goods()
|
if not self.job_card:
|
||||||
|
self.validate_finished_goods()
|
||||||
|
else:
|
||||||
|
self.validate_job_card_fg_item()
|
||||||
|
|
||||||
self.validate_with_material_request()
|
self.validate_with_material_request()
|
||||||
self.validate_batch()
|
self.validate_batch()
|
||||||
@@ -303,10 +306,24 @@ class StockEntry(StockController):
|
|||||||
self.from_bom = 1
|
self.from_bom = 1
|
||||||
self.bom_no = data.bom_no
|
self.bom_no = data.bom_no
|
||||||
|
|
||||||
def validate_job_card_item(self):
|
def validate_job_card_fg_item(self):
|
||||||
if not self.job_card:
|
if not self.job_card:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
job_card = frappe.db.get_value(
|
||||||
|
"Job Card", self.job_card, ["finished_good", "manufactured_qty"], as_dict=1
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in self.items:
|
||||||
|
if row.is_finished_item and row.item_code != job_card.finished_good:
|
||||||
|
frappe.throw(
|
||||||
|
_("Row #{0}: Finished Good must be {1}").format(row.idx, job_card.fininshed_good)
|
||||||
|
)
|
||||||
|
|
||||||
|
def validate_job_card_item(self):
|
||||||
|
if not self.job_card or self.purpose == "Manufacture":
|
||||||
|
return
|
||||||
|
|
||||||
if cint(frappe.db.get_single_value("Manufacturing Settings", "job_card_excess_transfer")):
|
if cint(frappe.db.get_single_value("Manufacturing Settings", "job_card_excess_transfer")):
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -341,13 +358,6 @@ class StockEntry(StockController):
|
|||||||
if self.purpose not in valid_purposes:
|
if self.purpose not in valid_purposes:
|
||||||
frappe.throw(_("Purpose must be one of {0}").format(comma_or(valid_purposes)))
|
frappe.throw(_("Purpose must be one of {0}").format(comma_or(valid_purposes)))
|
||||||
|
|
||||||
if self.job_card and self.purpose not in ["Material Transfer for Manufacture", "Repack"]:
|
|
||||||
frappe.throw(
|
|
||||||
_(
|
|
||||||
"For job card {0}, you can only make the 'Material Transfer for Manufacture' type stock entry"
|
|
||||||
).format(self.job_card)
|
|
||||||
)
|
|
||||||
|
|
||||||
def delete_linked_stock_entry(self):
|
def delete_linked_stock_entry(self):
|
||||||
if self.purpose == "Send to Warehouse":
|
if self.purpose == "Send to Warehouse":
|
||||||
for d in frappe.get_all(
|
for d in frappe.get_all(
|
||||||
@@ -624,8 +634,10 @@ class StockEntry(StockController):
|
|||||||
# check if work order is entered
|
# check if work order is entered
|
||||||
|
|
||||||
if (
|
if (
|
||||||
self.purpose == "Manufacture" or self.purpose == "Material Consumption for Manufacture"
|
(self.purpose == "Manufacture" or self.purpose == "Material Consumption for Manufacture")
|
||||||
) and self.work_order:
|
and self.work_order
|
||||||
|
and frappe.get_cached_value("Work Order", self.work_order, "track_semi_finished_goods") != 1
|
||||||
|
):
|
||||||
if not self.fg_completed_qty:
|
if not self.fg_completed_qty:
|
||||||
frappe.throw(_("For Quantity (Manufactured Qty) is mandatory"))
|
frappe.throw(_("For Quantity (Manufactured Qty) is mandatory"))
|
||||||
self.check_if_operations_completed()
|
self.check_if_operations_completed()
|
||||||
@@ -1575,8 +1587,14 @@ class StockEntry(StockController):
|
|||||||
|
|
||||||
if self.job_card:
|
if self.job_card:
|
||||||
job_doc = frappe.get_doc("Job Card", self.job_card)
|
job_doc = frappe.get_doc("Job Card", self.job_card)
|
||||||
job_doc.set_transferred_qty(update_status=True)
|
if self.purpose != "Manufacture":
|
||||||
job_doc.set_transferred_qty_in_job_card_item(self)
|
job_doc.set_transferred_qty(update_status=True)
|
||||||
|
job_doc.set_transferred_qty_in_job_card_item(self)
|
||||||
|
else:
|
||||||
|
job_doc.set_manufactured_qty()
|
||||||
|
|
||||||
|
if self.job_card and frappe.get_cached_value("Job Card", self.job_card, "finished_good"):
|
||||||
|
return
|
||||||
|
|
||||||
if self.work_order:
|
if self.work_order:
|
||||||
pro_doc = frappe.get_doc("Work Order", self.work_order)
|
pro_doc = frappe.get_doc("Work Order", self.work_order)
|
||||||
|
|||||||
@@ -2,8 +2,11 @@
|
|||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
|
||||||
# import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from frappe.utils import flt
|
||||||
|
|
||||||
|
from erpnext.manufacturing.doctype.bom.bom import get_bom_items_as_dict
|
||||||
|
|
||||||
|
|
||||||
class StockEntryType(Document):
|
class StockEntryType(Document):
|
||||||
@@ -32,3 +35,118 @@ class StockEntryType(Document):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
if self.add_to_transit and self.purpose != "Material Transfer":
|
if self.add_to_transit and self.purpose != "Material Transfer":
|
||||||
self.add_to_transit = 0
|
self.add_to_transit = 0
|
||||||
|
|
||||||
|
|
||||||
|
class ManufactureEntry:
|
||||||
|
def __init__(self, kwargs) -> None:
|
||||||
|
for key, value in kwargs.items():
|
||||||
|
setattr(self, key, value)
|
||||||
|
|
||||||
|
def make_stock_entry(self):
|
||||||
|
self.stock_entry = frappe.new_doc("Stock Entry")
|
||||||
|
self.stock_entry.purpose = self.purpose
|
||||||
|
self.stock_entry.company = self.company
|
||||||
|
self.stock_entry.from_bom = 1
|
||||||
|
self.stock_entry.bom_no = self.bom_no
|
||||||
|
self.stock_entry.use_multi_level_bom = 1
|
||||||
|
self.stock_entry.fg_completed_qty = self.for_quantity
|
||||||
|
self.stock_entry.project = self.project
|
||||||
|
self.stock_entry.job_card = self.job_card
|
||||||
|
self.stock_entry.work_order = self.work_order
|
||||||
|
self.stock_entry.set_stock_entry_type()
|
||||||
|
|
||||||
|
self.prepare_source_warehouse()
|
||||||
|
self.add_raw_materials()
|
||||||
|
self.add_finished_good()
|
||||||
|
|
||||||
|
def prepare_source_warehouse(self):
|
||||||
|
self.source_wh = {}
|
||||||
|
if self.skip_material_transfer:
|
||||||
|
if not self.backflush_from_wip_warehouse:
|
||||||
|
self.source_wh = frappe._dict(
|
||||||
|
frappe.get_all(
|
||||||
|
"Job Card Item",
|
||||||
|
filters={"parent": self.job_card},
|
||||||
|
fields=["item_code", "source_warehouse"],
|
||||||
|
as_list=1,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def add_raw_materials(self):
|
||||||
|
if self.job_card:
|
||||||
|
item_dict = {}
|
||||||
|
# if self.bom_no:
|
||||||
|
# item_dict = get_bom_items_as_dict(
|
||||||
|
# self.bom_no,
|
||||||
|
# self.company,
|
||||||
|
# qty=self.qty_to_manufacture,
|
||||||
|
# fetch_exploded=False,
|
||||||
|
# fetch_qty_in_stock_uom=False,
|
||||||
|
# )
|
||||||
|
|
||||||
|
if not item_dict:
|
||||||
|
item_dict = self.get_items_from_job_card()
|
||||||
|
|
||||||
|
for item_code, _dict in item_dict.items():
|
||||||
|
_dict.from_warehouse = self.source_wh.get(item_code) or self.wip_warehouse
|
||||||
|
_dict.to_warehouse = ""
|
||||||
|
|
||||||
|
self.stock_entry.add_to_stock_entry_detail(item_dict)
|
||||||
|
|
||||||
|
def get_items_from_job_card(self):
|
||||||
|
item_dict = {}
|
||||||
|
items = frappe.get_all(
|
||||||
|
"Job Card Item",
|
||||||
|
fields=[
|
||||||
|
"item_code",
|
||||||
|
"source_warehouse",
|
||||||
|
"required_qty as qty",
|
||||||
|
"item_name",
|
||||||
|
"uom",
|
||||||
|
"stock_uom",
|
||||||
|
"item_group",
|
||||||
|
"description",
|
||||||
|
],
|
||||||
|
filters={"parent": self.job_card},
|
||||||
|
)
|
||||||
|
|
||||||
|
for item in items:
|
||||||
|
key = item.item_code
|
||||||
|
|
||||||
|
if key in item_dict:
|
||||||
|
item_dict[key]["qty"] += flt(item.qty)
|
||||||
|
else:
|
||||||
|
item_dict[key] = item
|
||||||
|
|
||||||
|
for item, item_details in item_dict.items():
|
||||||
|
for d in [
|
||||||
|
["Account", "expense_account", "stock_adjustment_account"],
|
||||||
|
["Cost Center", "cost_center", "cost_center"],
|
||||||
|
["Warehouse", "default_warehouse", ""],
|
||||||
|
]:
|
||||||
|
company_in_record = frappe.db.get_value(d[0], item_details.get(d[1]), "company")
|
||||||
|
if not item_details.get(d[1]) or (company_in_record and self.company != company_in_record):
|
||||||
|
item_dict[item][d[1]] = (
|
||||||
|
frappe.get_cached_value("Company", self.company, d[2]) if d[2] else None
|
||||||
|
)
|
||||||
|
|
||||||
|
return item_dict
|
||||||
|
|
||||||
|
def add_finished_good(self):
|
||||||
|
from erpnext.stock.doctype.item.item import get_item_defaults
|
||||||
|
|
||||||
|
item = get_item_defaults(self.production_item, self.company)
|
||||||
|
|
||||||
|
args = {
|
||||||
|
"to_warehouse": self.fg_warehouse,
|
||||||
|
"from_warehouse": "",
|
||||||
|
"qty": self.for_quantity,
|
||||||
|
"item_name": item.item_name,
|
||||||
|
"description": item.description,
|
||||||
|
"stock_uom": item.stock_uom,
|
||||||
|
"expense_account": item.get("expense_account"),
|
||||||
|
"cost_center": item.get("buying_cost_center"),
|
||||||
|
"is_finished_item": 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
self.stock_entry.add_to_stock_entry_detail({self.production_item: args}, bom_no=self.bom_no)
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ def get_subcontracting_boms_for_finished_goods(fg_items: str | list) -> dict:
|
|||||||
else:
|
else:
|
||||||
return subcontracting_boms[0]
|
return subcontracting_boms[0]
|
||||||
|
|
||||||
return {}
|
return frappe._dict({})
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
|||||||
@@ -49,6 +49,9 @@
|
|||||||
"cost_center",
|
"cost_center",
|
||||||
"dimension_col_break",
|
"dimension_col_break",
|
||||||
"project",
|
"project",
|
||||||
|
"references_section",
|
||||||
|
"job_card",
|
||||||
|
"column_break_nfod",
|
||||||
"section_break_34",
|
"section_break_34",
|
||||||
"purchase_order_item",
|
"purchase_order_item",
|
||||||
"page_break"
|
"page_break"
|
||||||
@@ -378,13 +381,29 @@
|
|||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"search_index": 1
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "references_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "References"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "job_card",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Job Card",
|
||||||
|
"options": "Job Card",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_nfod",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-27 13:10:46.343298",
|
"modified": "2024-03-27 13:12:46.343298",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Subcontracting",
|
"module": "Subcontracting",
|
||||||
"name": "Subcontracting Order Item",
|
"name": "Subcontracting Order Item",
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
from frappe.query_builder.functions import Sum
|
||||||
from frappe.utils import cint, flt, get_link_to_form, getdate, nowdate
|
from frappe.utils import cint, flt, get_link_to_form, getdate, nowdate
|
||||||
|
|
||||||
import erpnext
|
import erpnext
|
||||||
@@ -155,6 +156,7 @@ class SubcontractingReceipt(SubcontractingController):
|
|||||||
self.repost_future_sle_and_gle()
|
self.repost_future_sle_and_gle()
|
||||||
self.update_status()
|
self.update_status()
|
||||||
self.auto_create_purchase_receipt()
|
self.auto_create_purchase_receipt()
|
||||||
|
self.update_job_card()
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
for table_field in ["items", "supplied_items"]:
|
for table_field in ["items", "supplied_items"]:
|
||||||
@@ -178,6 +180,7 @@ class SubcontractingReceipt(SubcontractingController):
|
|||||||
self.repost_future_sle_and_gle()
|
self.repost_future_sle_and_gle()
|
||||||
self.update_status()
|
self.update_status()
|
||||||
self.delete_auto_created_batches()
|
self.delete_auto_created_batches()
|
||||||
|
self.update_job_card()
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def reset_raw_materials(self):
|
def reset_raw_materials(self):
|
||||||
@@ -189,6 +192,23 @@ class SubcontractingReceipt(SubcontractingController):
|
|||||||
if item.subcontracting_order:
|
if item.subcontracting_order:
|
||||||
check_on_hold_or_closed_status("Subcontracting Order", item.subcontracting_order)
|
check_on_hold_or_closed_status("Subcontracting Order", item.subcontracting_order)
|
||||||
|
|
||||||
|
def update_job_card(self):
|
||||||
|
for row in self.get("items"):
|
||||||
|
if row.job_card:
|
||||||
|
doc = frappe.get_doc("Job Card", row.job_card)
|
||||||
|
doc.set_manufactured_qty()
|
||||||
|
|
||||||
|
def get_manufactured_qty(self, job_card):
|
||||||
|
table = frappe.qb.DocType("Subcontracting Receipt Item")
|
||||||
|
query = (
|
||||||
|
frappe.qb.from_(table)
|
||||||
|
.select(Sum(table.qty))
|
||||||
|
.where((table.job_card == job_card) & (table.docstatus == 1))
|
||||||
|
)
|
||||||
|
|
||||||
|
qty = query.run()[0][0] or 0.0
|
||||||
|
return flt(qty)
|
||||||
|
|
||||||
def validate_items_qty(self):
|
def validate_items_qty(self):
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
if not (item.qty or item.rejected_qty):
|
if not (item.qty or item.rejected_qty):
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
"subcontracting_order",
|
"subcontracting_order",
|
||||||
"subcontracting_order_item",
|
"subcontracting_order_item",
|
||||||
"subcontracting_receipt_item",
|
"subcontracting_receipt_item",
|
||||||
|
"job_card",
|
||||||
"column_break_40",
|
"column_break_40",
|
||||||
"rejected_warehouse",
|
"rejected_warehouse",
|
||||||
"bom",
|
"bom",
|
||||||
@@ -577,12 +578,20 @@
|
|||||||
"fieldname": "add_serial_batch_for_rejected_qty",
|
"fieldname": "add_serial_batch_for_rejected_qty",
|
||||||
"fieldtype": "Button",
|
"fieldtype": "Button",
|
||||||
"label": "Add Serial / Batch No (Rejected Qty)"
|
"label": "Add Serial / Batch No (Rejected Qty)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "job_card",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Job Card",
|
||||||
|
"options": "Job Card",
|
||||||
|
"read_only": 1,
|
||||||
|
"search_index": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-29 15:42:43.425544",
|
"modified": "2024-03-29 15:43:43.425544",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Subcontracting",
|
"module": "Subcontracting",
|
||||||
"name": "Subcontracting Receipt Item",
|
"name": "Subcontracting Receipt Item",
|
||||||
|
|||||||
Reference in New Issue
Block a user