alloed man
This commit is contained in:
parent
eaed5933f6
commit
3b29b669d3
|
|
@ -353,10 +353,17 @@ class PurchaseCoC(models.Model):
|
|||
for rec in self:
|
||||
request = rec.po_id.request_id
|
||||
if request:
|
||||
if request.employee_id.parent_id.user_id.id != user.id:
|
||||
raise ValidationError(_('Sorry You are not allowed to Confirm this CoC.'))
|
||||
if request.employee_id.user_id.id != user.id:
|
||||
allowed_name = request.employee_id.name
|
||||
raise ValidationError(
|
||||
_('Sorry, you are not allowed to Confirm this CoC.\nAllowed user: %s') % allowed_name
|
||||
)
|
||||
else:
|
||||
pass
|
||||
if rec.po_id.department_id.manager_id.user_id.id != user.id:
|
||||
allowed_name = rec.po_id.department_id.manager_id.name
|
||||
raise ValidationError(
|
||||
_('Sorry, you are not allowed to Confirm this CoC.\nAllowed user: %s') % allowed_name
|
||||
)
|
||||
|
||||
if not any(line.qty_to_receive > 0 for line in rec.coc_line_ids):
|
||||
raise ValidationError(_('You must receive at least one product before confirmation.'))
|
||||
|
|
@ -397,6 +404,21 @@ class PurchaseCoC(models.Model):
|
|||
po = self.po_id.sudo()
|
||||
request = po.request_id
|
||||
|
||||
if request:
|
||||
coach_user = request.employee_id.sudo().coach_id.user_id
|
||||
allowed_name = coach_user.name
|
||||
if coach_user.id != user.id:
|
||||
raise ValidationError(
|
||||
_('Sorry, you are not allowed to Confirm this CoC.\nAllowed user: %s') % allowed_name
|
||||
)
|
||||
else:
|
||||
dept_manager = self.po_id.department_id.manager_id.sudo()
|
||||
coach_user = dept_manager.coach_id.user_id
|
||||
allowed_name = coach_user.name
|
||||
if coach_user.id != user.id:
|
||||
raise ValidationError(
|
||||
_('Sorry, you are not allowed to Confirm this CoC.\nAllowed user: %s') % allowed_name
|
||||
)
|
||||
|
||||
if not any(line.qty_to_receive > 0 for line in self.coc_line_ids):
|
||||
raise ValidationError(_('You must receive at least one product before approval.'))
|
||||
|
|
|
|||
Loading…
Reference in New Issue