Merge pull request #996 from expsa/fix-ur

hotfix
This commit is contained in:
eslam 2024-09-04 10:15:54 +03:00 committed by GitHub
commit a9b35b46b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -67,13 +67,13 @@ class PurchaseRequest(models.Model):
def create_requisition(self):
"""inherit for take in considiration available qty """
self.is_requisition = True
if not self.employee_id.department_id:
if not self.sudo().employee_id.department_id:
raise ValidationError(_("Choose A Department For this Employee!"))
line_ids = []
for line in self.line_ids.filtered(lambda line: line.qty_purchased > 0):
line_ids.append((0, 6, {
'product_id': line.product_id.id,
'department_id': line.request_id.department_id.id or False,
'department_id': line.request_id.sudo().department_id.id or False,
'product_qty': line.qty_purchased,
'name': line.product_id.name,
'account_analytic_id': line.account_id.id,