Merge branch 'version-14-hotfix' into mergify/bp/version-14-hotfix/pr-33022

This commit is contained in:
Deepesh Garg
2022-11-28 23:06:23 +05:30
committed by GitHub
7 changed files with 2628 additions and 207 deletions

View File

@@ -91,7 +91,7 @@
},
{
"default": "0",
"description": "Enabling ensure each Sales Invoice has a unique value in Supplier Invoice No. field",
"description": "Enabling ensure each Purchase Invoice has a unique value in Supplier Invoice No. field",
"fieldname": "check_supplier_invoice_uniqueness",
"fieldtype": "Check",
"label": "Check Supplier Invoice Number Uniqueness"
@@ -354,7 +354,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2022-07-11 13:37:50.605141",
"modified": "2022-11-27 21:49:52.538655",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounts Settings",

View File

@@ -120,7 +120,7 @@ def link_open_tasks(ref_doctype, ref_docname, doc):
todo_doc = frappe.get_doc("ToDo", todo.name)
todo_doc.reference_type = doc.doctype
todo_doc.reference_name = doc.name
todo_doc.db_update()
todo_doc.save()
def link_open_events(ref_doctype, ref_docname, doc):

View File

@@ -521,6 +521,9 @@ class ProductionPlan(Document):
subcontracted_po.setdefault(row.supplier, []).append(row)
continue
if row.type_of_manufacturing == "Material Request":
continue
work_order_data = {
"wip_warehouse": default_warehouses.get("wip_warehouse"),
"fg_warehouse": default_warehouses.get("fg_warehouse"),
@@ -1161,6 +1164,7 @@ def get_bin_details(row, company, for_warehouse=None, all_warehouse=False):
subquery = frappe.qb.from_(wh).select(wh.name).where(wh.company == company)
warehouse = ""
if not all_warehouse:
warehouse = for_warehouse or row.get("source_warehouse") or row.get("default_warehouse")
@@ -1226,6 +1230,21 @@ def get_items_for_material_requests(doc, warehouses=None, get_parent_warehouse_d
doc["mr_items"] = []
po_items = doc.get("po_items") if doc.get("po_items") else doc.get("items")
if doc.get("sub_assembly_items"):
for sa_row in doc.sub_assembly_items:
sa_row = frappe._dict(sa_row)
if sa_row.type_of_manufacturing == "Material Request":
po_items.append(
frappe._dict(
{
"item_code": sa_row.production_item,
"required_qty": sa_row.qty,
"include_exploded_items": 0,
}
)
)
# Check for empty table or empty rows
if not po_items or not [row.get("item_code") for row in po_items if row.get("item_code")]:
frappe.throw(

View File

@@ -840,6 +840,34 @@ class TestProductionPlan(FrappeTestCase):
self.assertEqual(row.uom, "Nos")
self.assertEqual(row.qty, 1)
def test_material_request_for_sub_assembly_items(self):
from erpnext.manufacturing.doctype.bom.test_bom import create_nested_bom
bom_tree = {
"Fininshed Goods1 For MR": {
"SubAssembly1 For MR": {"SubAssembly1-1 For MR": {"ChildPart1 For MR": {}}}
}
}
parent_bom = create_nested_bom(bom_tree, prefix="")
plan = create_production_plan(
item_code=parent_bom.item, planned_qty=10, ignore_existing_ordered_qty=1, do_not_submit=1
)
plan.get_sub_assembly_items()
mr_items = []
for row in plan.sub_assembly_items:
mr_items.append(row.production_item)
row.type_of_manufacturing = "Material Request"
plan.save()
items = get_items_for_material_requests(plan.as_dict())
validate_mr_items = [d.get("item_code") for d in items]
for item_code in mr_items:
self.assertTrue(item_code in validate_mr_items)
def create_production_plan(**args):
"""

View File

@@ -169,7 +169,7 @@
"fieldtype": "Select",
"in_list_view": 1,
"label": "Manufacturing Type",
"options": "In House\nSubcontract"
"options": "In House\nSubcontract\nMaterial Request"
},
{
"fieldname": "supplier",
@@ -188,7 +188,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2022-01-30 21:31:10.527559",
"modified": "2022-11-28 13:50:15.116082",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Production Plan Sub Assembly Item",

File diff suppressed because it is too large Load Diff

View File

@@ -263,8 +263,8 @@ def repost_future_sle(
def validate_item_warehouse(args):
for field in ["item_code", "warehouse", "posting_date", "posting_time"]:
if not args.get(field):
validation_msg = f"The field {frappe.unscrub(args.get(field))} is required for the reposting"
if args.get(field) in [None, ""]:
validation_msg = f"The field {frappe.unscrub(field)} is required for the reposting"
frappe.throw(_(validation_msg))