fix: consistency in display reserved_stock checkbox on Sales Order Item according global settings and item.is_stock_item (#38322)
* fix: consistency in display reserved_stock checkbox on Sales Order Item according global settings and item.is_stock_item * fix: evaluate depends_on for fdata visibility in grid * fix: evaluate depends_on for fdata visibility in grid * chore: change after review * chore: change for review
This commit is contained in:
parent
ca9413bc64
commit
af80d253db
@ -94,6 +94,9 @@ frappe.ui.form.on("Sales Order", {
|
|||||||
frm.set_value("reserve_stock", 0);
|
frm.set_value("reserve_stock", 0);
|
||||||
frm.set_df_property("reserve_stock", "read_only", 1);
|
frm.set_df_property("reserve_stock", "read_only", 1);
|
||||||
frm.set_df_property("reserve_stock", "hidden", 1);
|
frm.set_df_property("reserve_stock", "hidden", 1);
|
||||||
|
frm.fields_dict.items.grid.update_docfield_property('reserve_stock', 'hidden', 1);
|
||||||
|
frm.fields_dict.items.grid.update_docfield_property('reserve_stock', 'default', 0);
|
||||||
|
frm.fields_dict.items.grid.update_docfield_property('reserve_stock', 'read_only', 1);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -200,6 +200,7 @@ class SalesOrder(SellingController):
|
|||||||
self.validate_for_items()
|
self.validate_for_items()
|
||||||
self.validate_warehouse()
|
self.validate_warehouse()
|
||||||
self.validate_drop_ship()
|
self.validate_drop_ship()
|
||||||
|
self.validate_reserved_stock()
|
||||||
self.validate_serial_no_based_delivery()
|
self.validate_serial_no_based_delivery()
|
||||||
validate_against_blanket_order(self)
|
validate_against_blanket_order(self)
|
||||||
validate_inter_company_party(
|
validate_inter_company_party(
|
||||||
@ -660,6 +661,17 @@ class SalesOrder(SellingController):
|
|||||||
).format(item.item_code)
|
).format(item.item_code)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def validate_reserved_stock(self):
|
||||||
|
"""Clean reserved stock flag for non-stock Item"""
|
||||||
|
|
||||||
|
enable_stock_reservation = frappe.db.get_single_value(
|
||||||
|
"Stock Settings", "enable_stock_reservation"
|
||||||
|
)
|
||||||
|
|
||||||
|
for item in self.items:
|
||||||
|
if item.reserve_stock and (not enable_stock_reservation or not cint(item.is_stock_item)):
|
||||||
|
item.reserve_stock = 0
|
||||||
|
|
||||||
def has_unreserved_stock(self) -> bool:
|
def has_unreserved_stock(self) -> bool:
|
||||||
"""Returns True if there is any unreserved item in the Sales Order."""
|
"""Returns True if there is any unreserved item in the Sales Order."""
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
"item_code",
|
"item_code",
|
||||||
"customer_item_code",
|
"customer_item_code",
|
||||||
"ensure_delivery_based_on_produced_serial_no",
|
"ensure_delivery_based_on_produced_serial_no",
|
||||||
|
"is_stock_item",
|
||||||
"reserve_stock",
|
"reserve_stock",
|
||||||
"col_break1",
|
"col_break1",
|
||||||
"delivery_date",
|
"delivery_date",
|
||||||
@ -867,6 +868,7 @@
|
|||||||
{
|
{
|
||||||
"allow_on_submit": 1,
|
"allow_on_submit": 1,
|
||||||
"default": "1",
|
"default": "1",
|
||||||
|
"depends_on": "eval:doc.is_stock_item",
|
||||||
"fieldname": "reserve_stock",
|
"fieldname": "reserve_stock",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Reserve Stock",
|
"label": "Reserve Stock",
|
||||||
@ -891,6 +893,16 @@
|
|||||||
"label": "Production Plan Qty",
|
"label": "Production Plan Qty",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fetch_from": "item_code.is_stock_item",
|
||||||
|
"fieldname": "is_stock_item",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Is Stock Item",
|
||||||
|
"print_hide": 1,
|
||||||
|
"report_hide": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user