Merge branch 'pawan_branch' into 'development'

update code

See merge request prakash.jain/cor-odoo!76
This commit is contained in:
pawan.sharma 2021-01-13 02:28:07 -08:00
commit 9bdefb7f67
1 changed files with 9 additions and 4 deletions

View File

@ -65,7 +65,7 @@ class Project(models.Model):
manager_hour = fields.Float(string='Manager Hour')
employee_hour = fields.Float(string='Employee Hour')
consultant_timesheet_hrs = fields.One2many('consultant.timesheet.hrs', 'project_id', "Timesheet Hrs",
consultant_timesheet_hrs = fields.One2many('consultant.timesheet.hrs', 'project_id', "Timesheet Hrs", store=True,
copy=False, compute='_compute_consultant_timesheet_hour',
help="Consultant timesheet hours")
@ -134,25 +134,30 @@ class Project(models.Model):
record.cost = cost
record.budgeted_hour_week = budgeted_hour_week
@api.depends('pricing_type')
def _compute_consultant_timesheet_hour(self):
for val in self:
val.consultant_timesheet_hrs = False
if val._origin.id:
print('SSSSSSSSSSSSSSSSSSSS', 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()
print('TTTTTTTTTTTTTT', res)
if res:
val.consultant_timesheet_hrs.create({'project_id': res[0],
create_timesheet = val.consultant_timesheet_hrs.create({'project_id': res[0],
'employee_id': res[1],
'timesheet_hour': res[2]})
print('RRRRRRRRRRRRRRRRRRR', create_timesheet)
else:
val.consultant_timesheet_hrs = False
val.consultant_timesheet_hrs = False
#val.consultant_timesheet_hrs = False
class ProjectConsultantTimesheetHrs(models.Model):
_name = 'consultant.timesheet.hrs'
_description = 'Project Consultant Timesheet Hrs'
project_id = fields.Many2one('project.project', "Project", required=True)
project_id = fields.Many2one('project.project', "Project")
employee_id = fields.Many2one('hr.employee')
employee_price = fields.Float(string="Consultant Price", compute='_compute_consultant_timesheet_cost', default=0.0)
timesheet_hour = fields.Float("Timesheet Hour", default=0.0)