fix(stock): clear source warehouse on non-transfer material requests

Switching a Material Request from Material Transfer to another purpose
left the hidden row Source Warehouse set, so saving failed when it
matched the target warehouse.

(cherry picked from commit 372155864e)
This commit is contained in:
Mihir Kandoi
2026-10-24 12:13:27 +00:00
committed by Mergify
parent 90921e5494
commit 632971f7ea
@@ -150,6 +150,7 @@ class MaterialRequest(BuyingController):
)
def validate(self):
self.clear_source_warehouse()
super().validate()
self.validate_schedule_date()
@@ -240,6 +241,14 @@ class MaterialRequest(BuyingController):
def before_update_after_submit(self):
self.validate_schedule_date()
def clear_source_warehouse(self):
"""Source Warehouse is only used by Material Transfer, so it stays hidden and stale otherwise."""
if self.material_request_type == "Material Transfer":
return
for item in self.items:
item.from_warehouse = None
def validate_material_request_type(self):
"""Validate fields in accordance with selected type"""