Merge pull request #382 from expsa/purchase_req_chgs

Purchase req chgs
This commit is contained in:
eslam 2024-07-24 19:16:42 +03:00 committed by GitHub
commit c6522e4b64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -42,8 +42,8 @@ class PurchaseRequest(models.Model):
raise ValidationError(_("Can't Confirm Request With No Item!"))
if not self.department_id:
raise ValidationError(_("Please Select department for employee"))
direct_manager = self.sudo().employee_id.department_id.manager_id
if direct_manager and self.env.user.id != direct_manager.id:
direct_manager = self.sudo().department_id.manager_id
if direct_manager and direct_manager.user_id and self.env.user.id != direct_manager.user_id.id:
raise ValidationError(_("You should be The Direct Manager"))
if any(self.line_ids.filtered(lambda line: line.product_id.type == "product")):
self.write({'state': 'warehouse'})