Merge pull request #3223 from expsa/younes_dev_odex25_purchase

Change direct manager for purchase request
This commit is contained in:
kchyounes19 2025-05-18 15:26:00 +01:00 committed by GitHub
commit 56a5360d81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -148,8 +148,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().department_id.manager_id
if direct_manager and direct_manager.user_id and self.env.user.id != direct_manager.user_id.id:
employee_direct_manager = self.sudo().employee_id.parent_id
if employee_direct_manager and employee_direct_manager.user_id and self.env.user.id != employee_direct_manager.user_id.id:
raise ValidationError(_("only %s Direct Manager can approve the order" % self.sudo().employee_id.name))
if any(self.line_ids.filtered(lambda line: line.product_id.type == "product" or line.product_id.asset_ok)):
self.write({'state': 'warehouse'})