fix: allow both custodian and location while creating asset (backport #36263) (#36270)

fix: allow both custodian and location while creating asset (#36263)

(cherry picked from commit 2b47f5815e)

Co-authored-by: Anand Baburajan <anandbaburajan@gmail.com>
This commit is contained in:
mergify[bot]
2023-07-24 16:25:23 +05:30
committed by GitHub
parent 4854c2e7f7
commit e4f28e8a5b

View File

@@ -63,20 +63,21 @@ class AssetMovement(Document):
frappe.throw(_("Source and Target Location cannot be same")) frappe.throw(_("Source and Target Location cannot be same"))
if self.purpose == "Receipt": if self.purpose == "Receipt":
if not (d.source_location or d.from_employee) and not (d.target_location or d.to_employee): if not (d.source_location) and not (d.target_location or d.to_employee):
frappe.throw( frappe.throw(
_("Target Location or To Employee is required while receiving Asset {0}").format(d.asset) _("Target Location or To Employee is required while receiving Asset {0}").format(d.asset)
) )
elif d.from_employee and not d.target_location: elif d.source_location:
frappe.throw( if d.from_employee and not d.target_location:
_("Target Location is required while receiving Asset {0} from an employee").format(d.asset) frappe.throw(
) _("Target Location is required while receiving Asset {0} from an employee").format(d.asset)
elif d.to_employee and d.target_location: )
frappe.throw( elif d.to_employee and d.target_location:
_( frappe.throw(
"Asset {0} cannot be received at a location and given to an employee in a single movement" _(
).format(d.asset) "Asset {0} cannot be received at a location and given to an employee in a single movement"
) ).format(d.asset)
)
def validate_employee(self): def validate_employee(self):
for d in self.assets: for d in self.assets: