remove error while project create

This commit is contained in:
Pawan Kumar 2021-01-13 11:20:50 +05:30
parent 6064c5864f
commit 2da45dd619
1 changed files with 10 additions and 9 deletions

View File

@ -136,15 +136,16 @@ class Project(models.Model):
def _compute_consultant_timesheet_hour(self):
for val in self:
self._cr.execute('''SELECT project_id, employee_id, SUM(unit_amount) FROM account_analytic_line where project_id = %(project_id)s
GROUP BY project_id, employee_id''', {'project_id': val._origin.id})
res = self._cr.fetchone()
if res:
val.consultant_timesheet_hrs.create({'project_id': res[0],
'employee_id': res[1],
'timesheet_hour': res[2]})
else:
val.consultant_timesheet_hrs = False
if val._origin.id:
self._cr.execute('''SELECT project_id, employee_id, SUM(unit_amount) FROM account_analytic_line where project_id = %(project_id)s
GROUP BY project_id, employee_id''', {'project_id': val._origin.id})
res = self._cr.fetchone()
if res:
val.consultant_timesheet_hrs.create({'project_id': res[0],
'employee_id': res[1],
'timesheet_hour': res[2]})
else:
val.consultant_timesheet_hrs = False
class ProjectConsultantTimesheetHrs(models.Model):