Updated report code

This commit is contained in:
projectsodoo 2021-02-23 06:58:02 +05:30
parent efbf53ce4c
commit ef73c8f3b4
2 changed files with 26 additions and 22 deletions

View File

@ -30,7 +30,7 @@ class BudgetHrsAnalysis(models.Model):
('hours_in_consultant', 'Hours are budgeted according to a consultant'),
('hours_no_limit', 'Total hours are budgeted without division to consultant'),
], string="Project Type", readonly=True)
timesheet_date = fields.Date(string='Timesheet Date', readonly=True)
#timesheet_date = fields.Date(string='Timesheet Date', readonly=True)
#budgeted_hours = fields.Float("Budgeted Hours", digits=(16, 2), readonly=True, group_operator="sum")
#actual_hours = fields.Float("Actual Hours", digits=(16, 2), readonly=True, group_operator="sum")
@ -52,11 +52,6 @@ class BudgetHrsAnalysis(models.Model):
parent_project,
startdate as start_date,
enddate as end_date,
--is_sub_project,
--sub_project,
--date_start AS start_date,
--date AS end_date,
timesheet_date,
pricing_type as pricing_type,
project_type as project_type,
partner_id,
@ -70,7 +65,6 @@ class BudgetHrsAnalysis(models.Model):
date_start AS startdate,
date AS enddate,
'Budgeted Hours' as hours_type,
null::date AS timesheet_date,
pro_emp.budgeted_qty as hours,
pro.*
FROM
@ -87,7 +81,6 @@ class BudgetHrsAnalysis(models.Model):
date_start AS startdate,
date AS enddate,
'Budgeted Hours' as hours_type,
null::date AS timesheet_date,
pro.budgeted_hours2 as hours,
pro.*
FROM
@ -101,10 +94,9 @@ class BudgetHrsAnalysis(models.Model):
pro.id AS project_id,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parent_project,
AAL.employee_id AS employee_id,
start_datetime AS startdate,
end_datetime AS enddate,
coalesce(pro.date_start, (select min(al.start_datetime::date) from account_analytic_line as al where pro.id=al.project_id)) AS startdate,
(select max(al.end_datetime::date) from account_analytic_line as al) as enddate,
'Actual Hours' as hours_type,
AAL.date AS timesheet_date,
unit_amount as hours,
pro.*
FROM project_project PRO
@ -112,28 +104,40 @@ class BudgetHrsAnalysis(models.Model):
LEFT JOIN account_analytic_account AA ON PRO.analytic_account_id = AA.id
LEFT JOIN account_analytic_line AAL ON AAL.account_id = AA.id and AAL.project_id = PRO.id and AAL.employee_id = pro_emp.employee_id
Where
PRO.active = 't' and PRO.pricing_type = 'employee_rate'
--and PRO.project_type = 'hours_in_consultant'
PRO.active = 't'
and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_in_consultant' and AAL.employee_id is not null
Union all
SELECT
pro.id AS project_id,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parent_project,
AAL.employee_id AS employee_id,
start_datetime::DATE AS startdate,
end_datetime::DATE AS enddate,
coalesce(pro.date_start, (select min(al.start_datetime::date) from account_analytic_line as al where pro.id=al.project_id)) AS startdate,
(select max(al.end_datetime::date) from account_analytic_line as al) as enddate,
'Actual Hours' as hours_type,
unit_amount as hours,
pro.*
FROM project_project PRO
LEFT JOIN account_analytic_account AA ON PRO.analytic_account_id = AA.id
LEFT JOIN account_analytic_line AAL ON AAL.account_id = AA.id and AAL.project_id = PRO.id
Where
PRO.active = 't'
and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_no_limit' and AAL.employee_id is not null
Union all
SELECT
pro.id AS project_id,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parent_project,
AAL.employee_id AS employee_id,
pro.date_start AS startdate,
(select max(al.end_datetime::date) from account_analytic_line as al) as enddate,
'Actual Hours' as hours_type,
AAL.date AS timesheet_date,
unit_amount as hours,
pro.*
FROM project_project PRO
--Left JOIN project_sale_line_employee_map pro_emp ON pro_emp.project_id = pro.id
LEFT JOIN account_analytic_account AA ON PRO.analytic_account_id = AA.id
LEFT JOIN account_analytic_line AAL ON AAL.account_id = AA.id and AAL.project_id = PRO.id
--and AAL.employee_id = pro_emp.employee_id
Where
PRO.active = 't'
and PRO.pricing_type = 'fixed_rate'
--and PRO.project_type = 'hours_in_consultant'
) as res
order by
project_id desc,

View File

@ -34,7 +34,7 @@
<field name="start_date"/>
<field name="end_date"/>
<field name="employee_id"/>
<field name="timesheet_date" optional="hide"/>
<!--<field name="timesheet_date" optional="hide"/>-->
<field name="hours_type"/>
<field name="hours"/>
<field name="parent_project" optional="hide"/>
@ -53,7 +53,7 @@
<field name="employee_id"/>
<field name="start_date"/>
<field name="end_date"/>
<field name="timesheet_date"/>
<!--<field name="timesheet_date"/>-->
<filter string="Fixed rate" name="fixed" domain="[('pricing_type','=','fixed_rate')]"/>
<filter string="Hours are budgeted according to a consultant" name="cons" domain="[('project_type','=','hours_in_consultant')]"/>
<filter string="Total hours are budgeted without division to consultant" name="limit" domain="[('project_type','=','hours_no_limit')]"/>
@ -64,7 +64,7 @@
<filter string="Consultant" name="group_by_employee_id" context="{'group_by':'employee_id'}"/>
<filter string="Start Date" name="sdate" domain="[]" context="{'group_by':'start_date:day'}"/>
<filter string="End Date" name="edate" domain="[]" context="{'group_by':'end_date:day'}"/>
<filter string="Timesheet Date" name="tdate" domain="[]" context="{'group_by':'timesheet_date:day'}"/>
<!--<filter string="Timesheet Date" name="tdate" domain="[]" context="{'group_by':'timesheet_date:day'}"/>-->
<filter string="Hours type" name="group_by_hours_type" context="{'group_by':'hours_type'}"/>
</group>
</search>