feat: added checkbox 'Update Consumed Material Cost In Project' in work order to don't update the consumed material cost in the project for the subassembely work orders (#18533)

This commit is contained in:
rohitwaghchaure 2019-08-05 10:40:23 +05:30 committed by Nabin Hait
parent 08df6bda41
commit 9601b6c601
3 changed files with 509 additions and 484 deletions

View File

@ -320,7 +320,8 @@ class ProductionPlan(Document):
'qty': data.get("stock_qty") * item.get("qty"), 'qty': data.get("stock_qty") * item.get("qty"),
'production_plan': self.name, 'production_plan': self.name,
'company': self.company, 'company': self.company,
'fg_warehouse': item.get("fg_warehouse") 'fg_warehouse': item.get("fg_warehouse"),
'update_consumed_material_cost_in_project': 0
}) })
work_order = self.create_work_order(data) work_order = self.create_work_order(data)

View File

@ -1,484 +1,504 @@
{ {
"allow_import": 1, "allow_import": 1,
"autoname": "naming_series:", "autoname": "naming_series:",
"creation": "2013-01-10 16:34:16", "creation": "2013-01-10 16:34:16",
"doctype": "DocType", "doctype": "DocType",
"document_type": "Setup", "document_type": "Setup",
"field_order": [ "engine": "InnoDB",
"item", "field_order": [
"naming_series", "item",
"status", "naming_series",
"production_item", "status",
"item_name", "production_item",
"image", "item_name",
"bom_no", "image",
"allow_alternative_item", "bom_no",
"use_multi_level_bom", "column_break1",
"skip_transfer", "company",
"column_break1", "qty",
"company", "material_transferred_for_manufacturing",
"qty", "produced_qty",
"material_transferred_for_manufacturing", "sales_order",
"produced_qty", "project",
"sales_order", "settings_section",
"project", "allow_alternative_item",
"from_wip_warehouse", "use_multi_level_bom",
"warehouses", "column_break_18",
"wip_warehouse", "skip_transfer",
"fg_warehouse", "from_wip_warehouse",
"column_break_12", "update_consumed_material_cost_in_project",
"scrap_warehouse", "warehouses",
"required_items_section", "wip_warehouse",
"required_items", "fg_warehouse",
"time", "column_break_12",
"planned_start_date", "scrap_warehouse",
"actual_start_date", "required_items_section",
"column_break_13", "required_items",
"planned_end_date", "time",
"actual_end_date", "planned_start_date",
"expected_delivery_date", "actual_start_date",
"operations_section", "column_break_13",
"transfer_material_against", "planned_end_date",
"operations", "actual_end_date",
"section_break_22", "expected_delivery_date",
"planned_operating_cost", "operations_section",
"actual_operating_cost", "transfer_material_against",
"additional_operating_cost", "operations",
"column_break_24", "section_break_22",
"total_operating_cost", "planned_operating_cost",
"more_info", "actual_operating_cost",
"description", "additional_operating_cost",
"stock_uom", "column_break_24",
"column_break2", "total_operating_cost",
"material_request", "more_info",
"material_request_item", "description",
"sales_order_item", "stock_uom",
"production_plan", "column_break2",
"production_plan_item", "material_request",
"product_bundle_item", "material_request_item",
"amended_from" "sales_order_item",
], "production_plan",
"fields": [ "production_plan_item",
{ "product_bundle_item",
"fieldname": "item", "amended_from"
"fieldtype": "Section Break", ],
"options": "fa fa-gift" "fields": [
}, {
{ "fieldname": "item",
"fieldname": "naming_series", "fieldtype": "Section Break",
"fieldtype": "Select", "options": "fa fa-gift"
"label": "Series", },
"options": "MFG-WO-.YYYY.-", {
"print_hide": 1, "fieldname": "naming_series",
"reqd": 1, "fieldtype": "Select",
"set_only_once": 1 "label": "Series",
}, "options": "MFG-WO-.YYYY.-",
{ "print_hide": 1,
"default": "Draft", "reqd": 1,
"depends_on": "eval:!doc.__islocal", "set_only_once": 1
"fieldname": "status", },
"fieldtype": "Select", {
"label": "Status", "default": "Draft",
"no_copy": 1, "depends_on": "eval:!doc.__islocal",
"oldfieldname": "status", "fieldname": "status",
"oldfieldtype": "Select", "fieldtype": "Select",
"options": "\nDraft\nSubmitted\nNot Started\nIn Process\nCompleted\nStopped\nCancelled", "label": "Status",
"read_only": 1, "no_copy": 1,
"reqd": 1, "oldfieldname": "status",
"search_index": 1 "oldfieldtype": "Select",
}, "options": "\nDraft\nSubmitted\nNot Started\nIn Process\nCompleted\nStopped\nCancelled",
{ "read_only": 1,
"fieldname": "production_item", "reqd": 1,
"fieldtype": "Link", "search_index": 1
"in_global_search": 1, },
"in_list_view": 1, {
"in_standard_filter": 1, "fieldname": "production_item",
"label": "Item To Manufacture", "fieldtype": "Link",
"oldfieldname": "production_item", "in_global_search": 1,
"oldfieldtype": "Link", "in_list_view": 1,
"options": "Item", "in_standard_filter": 1,
"reqd": 1 "label": "Item To Manufacture",
}, "oldfieldname": "production_item",
{ "oldfieldtype": "Link",
"depends_on": "eval:doc.production_item", "options": "Item",
"fieldname": "item_name", "reqd": 1
"fieldtype": "Data", },
"label": "Item Name", {
"read_only": 1 "depends_on": "eval:doc.production_item",
}, "fieldname": "item_name",
{ "fieldtype": "Data",
"fetch_from": "production_item.image", "label": "Item Name",
"fieldname": "image", "read_only": 1
"fieldtype": "Attach Image", },
"hidden": 1, {
"label": "Image", "fetch_from": "production_item.image",
"options": "image", "fieldname": "image",
"print_hide": 1, "fieldtype": "Attach Image",
"read_only": 1 "hidden": 1,
}, "label": "Image",
{ "options": "image",
"fieldname": "bom_no", "print_hide": 1,
"fieldtype": "Link", "read_only": 1
"label": "BOM No", },
"oldfieldname": "bom_no", {
"oldfieldtype": "Link", "fieldname": "bom_no",
"options": "BOM", "fieldtype": "Link",
"reqd": 1 "label": "BOM No",
}, "oldfieldname": "bom_no",
{ "oldfieldtype": "Link",
"default": "0", "options": "BOM",
"fieldname": "allow_alternative_item", "reqd": 1
"fieldtype": "Check", },
"label": "Allow Alternative Item" {
}, "default": "0",
{ "fieldname": "allow_alternative_item",
"default": "1", "fieldtype": "Check",
"description": "Plan material for sub-assemblies", "label": "Allow Alternative Item"
"fieldname": "use_multi_level_bom", },
"fieldtype": "Check", {
"label": "Use Multi-Level BOM", "default": "1",
"print_hide": 1 "description": "Plan material for sub-assemblies",
}, "fieldname": "use_multi_level_bom",
{ "fieldtype": "Check",
"default": "0", "label": "Use Multi-Level BOM",
"description": "Check if material transfer entry is not required", "print_hide": 1
"fieldname": "skip_transfer", },
"fieldtype": "Check", {
"label": "Skip Material Transfer to WIP Warehouse" "default": "0",
}, "description": "Check if material transfer entry is not required",
{ "fieldname": "skip_transfer",
"fieldname": "column_break1", "fieldtype": "Check",
"fieldtype": "Column Break", "label": "Skip Material Transfer to WIP Warehouse"
"oldfieldtype": "Column Break", },
"width": "50%" {
}, "fieldname": "column_break1",
{ "fieldtype": "Column Break",
"fieldname": "company", "oldfieldtype": "Column Break",
"fieldtype": "Link", "width": "50%"
"label": "Company", },
"oldfieldname": "company", {
"oldfieldtype": "Link", "fieldname": "company",
"options": "Company", "fieldtype": "Link",
"remember_last_selected_value": 1, "label": "Company",
"reqd": 1 "oldfieldname": "company",
}, "oldfieldtype": "Link",
{ "options": "Company",
"fieldname": "qty", "remember_last_selected_value": 1,
"fieldtype": "Float", "reqd": 1
"label": "Qty To Manufacture", },
"oldfieldname": "qty", {
"oldfieldtype": "Currency", "fieldname": "qty",
"reqd": 1 "fieldtype": "Float",
}, "label": "Qty To Manufacture",
{ "oldfieldname": "qty",
"default": "0", "oldfieldtype": "Currency",
"depends_on": "eval:doc.docstatus==1 && doc.skip_transfer==0", "reqd": 1
"fieldname": "material_transferred_for_manufacturing", },
"fieldtype": "Float", {
"label": "Material Transferred for Manufacturing", "default": "0",
"no_copy": 1, "depends_on": "eval:doc.docstatus==1 && doc.skip_transfer==0",
"read_only": 1 "fieldname": "material_transferred_for_manufacturing",
}, "fieldtype": "Float",
{ "label": "Material Transferred for Manufacturing",
"default": "0", "no_copy": 1,
"depends_on": "eval:doc.docstatus==1", "read_only": 1
"fieldname": "produced_qty", },
"fieldtype": "Float", {
"label": "Manufactured Qty", "default": "0",
"no_copy": 1, "depends_on": "eval:doc.docstatus==1",
"oldfieldname": "produced_qty", "fieldname": "produced_qty",
"oldfieldtype": "Currency", "fieldtype": "Float",
"read_only": 1 "label": "Manufactured Qty",
}, "no_copy": 1,
{ "oldfieldname": "produced_qty",
"allow_on_submit": 1, "oldfieldtype": "Currency",
"fieldname": "sales_order", "read_only": 1
"fieldtype": "Link", },
"in_global_search": 1, {
"label": "Sales Order", "allow_on_submit": 1,
"options": "Sales Order" "fieldname": "sales_order",
}, "fieldtype": "Link",
{ "in_global_search": 1,
"fieldname": "project", "label": "Sales Order",
"fieldtype": "Link", "options": "Sales Order"
"label": "Project", },
"oldfieldname": "project", {
"oldfieldtype": "Link", "fieldname": "project",
"options": "Project" "fieldtype": "Link",
}, "label": "Project",
{ "oldfieldname": "project",
"default": "0", "oldfieldtype": "Link",
"depends_on": "skip_transfer", "options": "Project"
"fieldname": "from_wip_warehouse", },
"fieldtype": "Check", {
"label": "Backflush Raw Materials From Work-in-Progress Warehouse" "default": "0",
}, "depends_on": "skip_transfer",
{ "fieldname": "from_wip_warehouse",
"fieldname": "warehouses", "fieldtype": "Check",
"fieldtype": "Section Break", "label": "Backflush Raw Materials From Work-in-Progress Warehouse"
"label": "Warehouses", },
"options": "fa fa-building" {
}, "fieldname": "warehouses",
{ "fieldtype": "Section Break",
"fieldname": "wip_warehouse", "label": "Warehouses",
"fieldtype": "Link", "options": "fa fa-building"
"label": "Work-in-Progress Warehouse", },
"options": "Warehouse" {
}, "fieldname": "wip_warehouse",
{ "fieldtype": "Link",
"fieldname": "fg_warehouse", "label": "Work-in-Progress Warehouse",
"fieldtype": "Link", "options": "Warehouse"
"label": "Target Warehouse", },
"options": "Warehouse" {
}, "fieldname": "fg_warehouse",
{ "fieldtype": "Link",
"fieldname": "column_break_12", "label": "Target Warehouse",
"fieldtype": "Column Break" "options": "Warehouse"
}, },
{ {
"fieldname": "scrap_warehouse", "fieldname": "column_break_12",
"fieldtype": "Link", "fieldtype": "Column Break"
"label": "Scrap Warehouse", },
"options": "Warehouse" {
}, "fieldname": "scrap_warehouse",
{ "fieldtype": "Link",
"fieldname": "required_items_section", "label": "Scrap Warehouse",
"fieldtype": "Section Break", "options": "Warehouse"
"label": "Required Items" },
}, {
{ "fieldname": "required_items_section",
"fieldname": "required_items", "fieldtype": "Section Break",
"fieldtype": "Table", "label": "Required Items"
"label": "Required Items", },
"no_copy": 1, {
"options": "Work Order Item", "fieldname": "required_items",
"print_hide": 1 "fieldtype": "Table",
}, "label": "Required Items",
{ "no_copy": 1,
"fieldname": "time", "options": "Work Order Item",
"fieldtype": "Section Break", "print_hide": 1
"label": "Time", },
"options": "fa fa-time" {
}, "fieldname": "time",
{ "fieldtype": "Section Break",
"allow_on_submit": 1, "label": "Time",
"default": "now", "options": "fa fa-time"
"fieldname": "planned_start_date", },
"fieldtype": "Datetime", {
"label": "Planned Start Date", "allow_on_submit": 1,
"reqd": 1 "default": "now",
}, "fieldname": "planned_start_date",
{ "fieldtype": "Datetime",
"fieldname": "actual_start_date", "label": "Planned Start Date",
"fieldtype": "Datetime", "reqd": 1
"label": "Actual Start Date", },
"read_only": 1 {
}, "fieldname": "actual_start_date",
{ "fieldtype": "Datetime",
"fieldname": "column_break_13", "label": "Actual Start Date",
"fieldtype": "Column Break" "read_only": 1
}, },
{ {
"fieldname": "planned_end_date", "fieldname": "column_break_13",
"fieldtype": "Datetime", "fieldtype": "Column Break"
"label": "Planned End Date", },
"no_copy": 1, {
"read_only": 1 "fieldname": "planned_end_date",
}, "fieldtype": "Datetime",
{ "label": "Planned End Date",
"fieldname": "actual_end_date", "no_copy": 1,
"fieldtype": "Datetime", "read_only": 1
"label": "Actual End Date", },
"read_only": 1 {
}, "fieldname": "actual_end_date",
{ "fieldtype": "Datetime",
"allow_on_submit": 1, "label": "Actual End Date",
"fieldname": "expected_delivery_date", "read_only": 1
"fieldtype": "Date", },
"label": "Expected Delivery Date" {
}, "allow_on_submit": 1,
{ "fieldname": "expected_delivery_date",
"fieldname": "operations_section", "fieldtype": "Date",
"fieldtype": "Section Break", "label": "Expected Delivery Date"
"label": "Operations", },
"options": "fa fa-wrench" {
}, "fieldname": "operations_section",
{ "fieldtype": "Section Break",
"default": "Work Order", "label": "Operations",
"depends_on": "operations", "options": "fa fa-wrench"
"fieldname": "transfer_material_against", },
"fieldtype": "Select", {
"label": "Transfer Material Against", "default": "Work Order",
"options": "\nWork Order\nJob Card" "depends_on": "operations",
}, "fieldname": "transfer_material_against",
{ "fieldtype": "Select",
"fieldname": "operations", "label": "Transfer Material Against",
"fieldtype": "Table", "options": "\nWork Order\nJob Card"
"label": "Operations", },
"options": "Work Order Operation", {
"read_only": 1 "fieldname": "operations",
}, "fieldtype": "Table",
{ "label": "Operations",
"depends_on": "operations", "options": "Work Order Operation",
"fieldname": "section_break_22", "read_only": 1
"fieldtype": "Section Break", },
"label": "Operation Cost" {
}, "depends_on": "operations",
{ "fieldname": "section_break_22",
"fieldname": "planned_operating_cost", "fieldtype": "Section Break",
"fieldtype": "Currency", "label": "Operation Cost"
"label": "Planned Operating Cost", },
"options": "Company:company:default_currency", {
"read_only": 1 "fieldname": "planned_operating_cost",
}, "fieldtype": "Currency",
{ "label": "Planned Operating Cost",
"fieldname": "actual_operating_cost", "options": "Company:company:default_currency",
"fieldtype": "Currency", "read_only": 1
"label": "Actual Operating Cost", },
"no_copy": 1, {
"options": "Company:company:default_currency", "fieldname": "actual_operating_cost",
"read_only": 1 "fieldtype": "Currency",
}, "label": "Actual Operating Cost",
{ "no_copy": 1,
"fieldname": "additional_operating_cost", "options": "Company:company:default_currency",
"fieldtype": "Currency", "read_only": 1
"label": "Additional Operating Cost", },
"no_copy": 1, {
"options": "Company:company:default_currency" "fieldname": "additional_operating_cost",
}, "fieldtype": "Currency",
{ "label": "Additional Operating Cost",
"fieldname": "column_break_24", "no_copy": 1,
"fieldtype": "Column Break" "options": "Company:company:default_currency"
}, },
{ {
"fieldname": "total_operating_cost", "fieldname": "column_break_24",
"fieldtype": "Currency", "fieldtype": "Column Break"
"label": "Total Operating Cost", },
"no_copy": 1, {
"options": "Company:company:default_currency", "fieldname": "total_operating_cost",
"read_only": 1 "fieldtype": "Currency",
}, "label": "Total Operating Cost",
{ "no_copy": 1,
"collapsible": 1, "options": "Company:company:default_currency",
"fieldname": "more_info", "read_only": 1
"fieldtype": "Section Break", },
"label": "More Information", {
"options": "fa fa-file-text" "collapsible": 1,
}, "fieldname": "more_info",
{ "fieldtype": "Section Break",
"fieldname": "description", "label": "More Information",
"fieldtype": "Small Text", "options": "fa fa-file-text"
"label": "Item Description", },
"read_only": 1 {
}, "fieldname": "description",
{ "fieldtype": "Small Text",
"fieldname": "stock_uom", "label": "Item Description",
"fieldtype": "Link", "read_only": 1
"label": "Stock UOM", },
"oldfieldname": "stock_uom", {
"oldfieldtype": "Data", "fieldname": "stock_uom",
"options": "UOM", "fieldtype": "Link",
"read_only": 1 "label": "Stock UOM",
}, "oldfieldname": "stock_uom",
{ "oldfieldtype": "Data",
"fieldname": "column_break2", "options": "UOM",
"fieldtype": "Column Break", "read_only": 1
"width": "50%" },
}, {
{ "fieldname": "column_break2",
"description": "Manufacture against Material Request", "fieldtype": "Column Break",
"fieldname": "material_request", "width": "50%"
"fieldtype": "Link", },
"label": "Material Request", {
"options": "Material Request" "description": "Manufacture against Material Request",
}, "fieldname": "material_request",
{ "fieldtype": "Link",
"fieldname": "material_request_item", "label": "Material Request",
"fieldtype": "Data", "options": "Material Request"
"hidden": 1, },
"label": "Material Request Item", {
"read_only": 1 "fieldname": "material_request_item",
}, "fieldtype": "Data",
{ "hidden": 1,
"fieldname": "sales_order_item", "label": "Material Request Item",
"fieldtype": "Data", "read_only": 1
"hidden": 1, },
"label": "Sales Order Item", {
"read_only": 1 "fieldname": "sales_order_item",
}, "fieldtype": "Data",
{ "hidden": 1,
"fieldname": "production_plan", "label": "Sales Order Item",
"fieldtype": "Link", "read_only": 1
"label": "Production Plan", },
"no_copy": 1, {
"options": "Production Plan", "fieldname": "production_plan",
"print_hide": 1, "fieldtype": "Link",
"read_only": 1 "label": "Production Plan",
}, "no_copy": 1,
{ "options": "Production Plan",
"fieldname": "production_plan_item", "print_hide": 1,
"fieldtype": "Data", "read_only": 1
"label": "Production Plan Item", },
"no_copy": 1, {
"print_hide": 1, "fieldname": "production_plan_item",
"read_only": 1 "fieldtype": "Data",
}, "label": "Production Plan Item",
{ "no_copy": 1,
"fieldname": "product_bundle_item", "print_hide": 1,
"fieldtype": "Link", "read_only": 1
"label": "Product Bundle Item", },
"no_copy": 1, {
"options": "Item", "fieldname": "product_bundle_item",
"print_hide": 1, "fieldtype": "Link",
"read_only": 1 "label": "Product Bundle Item",
}, "no_copy": 1,
{ "options": "Item",
"fieldname": "amended_from", "print_hide": 1,
"fieldtype": "Link", "read_only": 1
"ignore_user_permissions": 1, },
"label": "Amended From", {
"no_copy": 1, "fieldname": "amended_from",
"oldfieldname": "amended_from", "fieldtype": "Link",
"oldfieldtype": "Data", "ignore_user_permissions": 1,
"options": "Work Order", "label": "Amended From",
"read_only": 1 "no_copy": 1,
} "oldfieldname": "amended_from",
], "oldfieldtype": "Data",
"icon": "fa fa-cogs", "options": "Work Order",
"idx": 1, "read_only": 1
"image_field": "image", },
"is_submittable": 1, {
"modified": "2019-05-27 09:36:16.707719", "fieldname": "settings_section",
"modified_by": "Administrator", "fieldtype": "Section Break",
"module": "Manufacturing", "label": "Settings"
"name": "Work Order", },
"owner": "Administrator", {
"permissions": [ "fieldname": "column_break_18",
{ "fieldtype": "Column Break"
"amend": 1, },
"cancel": 1, {
"create": 1, "default": "1",
"delete": 1, "fieldname": "update_consumed_material_cost_in_project",
"email": 1, "fieldtype": "Check",
"export": 1, "label": "Update Consumed Material Cost In Project"
"import": 1, }
"print": 1, ],
"read": 1, "icon": "fa fa-cogs",
"report": 1, "idx": 1,
"role": "Manufacturing User", "image_field": "image",
"set_user_permissions": 1, "is_submittable": 1,
"share": 1, "modified": "2019-07-31 00:13:38.218277",
"submit": 1, "modified_by": "Administrator",
"write": 1 "module": "Manufacturing",
}, "name": "Work Order",
{ "owner": "Administrator",
"read": 1, "permissions": [
"report": 1, {
"role": "Stock User" "amend": 1,
} "cancel": 1,
], "create": 1,
"sort_order": "ASC", "delete": 1,
"title_field": "production_item", "email": 1,
"track_changes": 1, "export": 1,
"track_seen": 1 "import": 1,
} "print": 1,
"read": 1,
"report": 1,
"role": "Manufacturing User",
"set_user_permissions": 1,
"share": 1,
"submit": 1,
"write": 1
},
{
"read": 1,
"report": 1,
"role": "Stock User"
}
],
"sort_field": "modified",
"sort_order": "ASC",
"title_field": "production_item",
"track_changes": 1,
"track_seen": 1
}

View File

@ -145,6 +145,10 @@ class StockEntry(StockController):
self.precision("transfer_qty", item)) self.precision("transfer_qty", item))
def update_cost_in_project(self): def update_cost_in_project(self):
if (self.work_order and not frappe.db.get_value("Work Order",
self.work_order, "update_consumed_material_cost_in_project")):
return
if self.project: if self.project:
amount = frappe.db.sql(""" select ifnull(sum(sed.amount), 0) amount = frappe.db.sql(""" select ifnull(sum(sed.amount), 0)
from from