Added Employee Custody to Purchase Request
This commit is contained in:
parent
241127b848
commit
98a34b38ba
|
|
@ -99,19 +99,10 @@ class EmployeeCustodyLine(models.Model):
|
|||
return res
|
||||
|
||||
def unlink(self):
|
||||
asset_ids = self.mapped('asset_id').ids
|
||||
assets = self.mapped('asset_id')
|
||||
result = super(EmployeeCustodyLine, self).unlink()
|
||||
if result and asset_ids:
|
||||
Asset = self.env['account.asset']
|
||||
CustodyLine = self.env['asset.custody.line']
|
||||
|
||||
for asset_id in asset_ids:
|
||||
existing_custody = CustodyLine.search([('asset_id', '=', asset_id)], limit=1)
|
||||
if not existing_custody:
|
||||
asset = Asset.browse(asset_id)
|
||||
if asset.exists() and asset.status == 'reserved':
|
||||
asset.write({'status': 'available'})
|
||||
|
||||
if result and assets:
|
||||
assets.write({'status': 'available'})
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue