mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 08:54:45 +00:00
fix: validation to check company in Sales Forecast and MPS (#50545)
This commit is contained in:
@@ -6,6 +6,8 @@ frappe.ui.form.on("Master Production Schedule", {
|
|||||||
frm.trigger("set_query_filters");
|
frm.trigger("set_query_filters");
|
||||||
|
|
||||||
frm.set_df_property("items", "cannot_add_rows", true);
|
frm.set_df_property("items", "cannot_add_rows", true);
|
||||||
|
frm.set_df_property("material_requests", "cannot_add_rows", true);
|
||||||
|
frm.set_df_property("sales_orders", "cannot_add_rows", true);
|
||||||
frm.fields_dict.items.$wrapper.find("[data-action='duplicate_rows']").css("display", "none");
|
frm.fields_dict.items.$wrapper.find("[data-action='duplicate_rows']").css("display", "none");
|
||||||
|
|
||||||
frm.trigger("set_custom_buttons");
|
frm.trigger("set_custom_buttons");
|
||||||
@@ -36,6 +38,14 @@ frappe.ui.form.on("Master Production Schedule", {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frm.set_query("sales_forecast", (doc) => {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
company: doc.company,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
get_actual_demand(frm) {
|
get_actual_demand(frm) {
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
"material_requests",
|
"material_requests",
|
||||||
"section_break_xtby",
|
"section_break_xtby",
|
||||||
"column_break_yhkr",
|
"column_break_yhkr",
|
||||||
"column_break_vvys",
|
|
||||||
"get_actual_demand",
|
"get_actual_demand",
|
||||||
|
"column_break_vvys",
|
||||||
"section_break_cmgo",
|
"section_break_cmgo",
|
||||||
"items",
|
"items",
|
||||||
"forecast_demand_section",
|
"forecast_demand_section",
|
||||||
@@ -60,7 +60,6 @@
|
|||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 1,
|
|
||||||
"fieldname": "items",
|
"fieldname": "items",
|
||||||
"fieldtype": "Table",
|
"fieldtype": "Table",
|
||||||
"label": "Items",
|
"label": "Items",
|
||||||
@@ -189,7 +188,7 @@
|
|||||||
"grid_page_length": 50,
|
"grid_page_length": 50,
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2025-09-02 19:33:28.244544",
|
"modified": "2025-11-13 19:15:36.090622",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Master Production Schedule",
|
"name": "Master Production Schedule",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import math
|
import math
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
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.functions import Sum
|
from frappe.query_builder.functions import Sum
|
||||||
@@ -64,6 +64,22 @@ class MasterProductionSchedule(Document):
|
|||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.set_to_date()
|
self.set_to_date()
|
||||||
|
self.validate_company()
|
||||||
|
|
||||||
|
def validate_company(self):
|
||||||
|
if self.sales_forecast:
|
||||||
|
sales_forecast_company = frappe.db.get_value("Sales Forecast", self.sales_forecast, "company")
|
||||||
|
if sales_forecast_company != self.company:
|
||||||
|
frappe.throw(
|
||||||
|
_(
|
||||||
|
"The Company {0} of Sales Forecast {1} does not match with the Company {2} of Master Production Schedule {3}."
|
||||||
|
).format(
|
||||||
|
bold(sales_forecast_company),
|
||||||
|
bold(self.sales_forecast),
|
||||||
|
bold(self.company),
|
||||||
|
bold(self.name),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def set_to_date(self):
|
def set_to_date(self):
|
||||||
self.to_date = None
|
self.to_date = None
|
||||||
|
|||||||
Reference in New Issue
Block a user