From 14847875e830c1edda6e55548b999d319f66fcad Mon Sep 17 00:00:00 2001 From: root Date: Fri, 30 Sep 2022 19:52:34 +0530 Subject: [PATCH] project sub project related issue fixed --- project_report/models/project.py | 21 +++++++++++++------ .../report/project_revenue_custom_report3.py | 11 ++++++---- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/project_report/models/project.py b/project_report/models/project.py index 4ffe15e..e4a46ae 100755 --- a/project_report/models/project.py +++ b/project_report/models/project.py @@ -9,12 +9,21 @@ class Project(models.Model): def action_view_allocation_custom_report3(self): action = self.env["ir.actions.actions"]._for_xml_id("project_report.project_revenue_custom_report3_action") - action['context'] = {'search_default_project_id': self.id, - 'search_default_project': 1, - 'search_default_group_employee': 1, - 'search_default_group_enddate': 1, - #'default_res_model': 'project.revenue.custom.report3' - } + if self.is_sub_project and self.parent_project: + action['context'] = {'search_default_project_id': self.parent_project.id, + 'search_default_group_sub_project': 1, + 'search_default_group_employee': 1, + 'search_default_group_enddate': 1, + # 'default_res_model': 'project.revenue.custom.report3' + } + else: + action['context'] = {'search_default_project_id': self.id, + 'search_default_project': 1, + 'search_default_group_employee': 1, + 'search_default_group_enddate': 1, + # 'default_res_model': 'project.revenue.custom.report3' + } + print(action['context']) return action diff --git a/project_report/report/project_revenue_custom_report3.py b/project_report/report/project_revenue_custom_report3.py index a6ff7c7..1e5c503 100644 --- a/project_report/report/project_revenue_custom_report3.py +++ b/project_report/report/project_revenue_custom_report3.py @@ -255,7 +255,8 @@ SELECT ((AAL.unit_amount * pro_data.pro_hourly_rate) - (AAL.amount * -1))/NULLIF((AAL.unit_amount * pro_data.pro_hourly_rate),0) AS profit_per FROM pro_data left join account_analytic_line AAL on AAL.project_id=pro_data.pproject_id - WHERE pro_data.pricing_type='employee_rate' and pro_data.project_type='hours_no_limit' and COALESCE(pro_data.is_sub_project, FALSE) = False + WHERE pro_data.pricing_type='employee_rate' and pro_data.project_type='hours_no_limit' + --and COALESCE(pro_data.is_sub_project, FALSE) = False group by pro_data.pro_sdate, pro_data.pro_edate, @@ -430,8 +431,10 @@ SELECT 0 as budgeted_hours, 0 as overall_hourly_rate, AAL.unit_amount as unit_amount, - 0 as pro_hourly_rate, - coalesce(((AAL.amount * -1)/NULLIF(AAL.unit_amount, 0)), cons_data1.cons_timesheet_cost) as timesheet_cost, + COALESCE(cons_data1.cons_hourly_cost, 0) as pro_hourly_rate, + case when cons_data1.cons_timesheet_cost is null then ((AAL.amount * -1)/NULLIF(AAL.unit_amount, 0)) else cons_data1.cons_timesheet_cost + end as timesheet_cost, + --coalesce(((AAL.amount * -1)/NULLIF(AAL.unit_amount, 0)), cons_data1.cons_timesheet_cost) as timesheet_cost, (AAL.unit_amount * COALESCE(cons_data1.cons_hourly_cost, 0)) as actual_revenue, case when cons_data1.cons_timesheet_cost is null then (AAL.amount * -1) else (AAL.unit_amount * cons_data1.cons_timesheet_cost) end as actual_cost, @@ -449,7 +452,7 @@ SELECT and AAL.end_datetime --at time zone 'utc' at time zone (select tz from res_partner where id=3) <= cons_data1.end_date::date + '23:59:59'::time AT TIME ZONE 'UTC' where pro_data.pricing_type='employee_rate' and pro_data.project_type='hours_in_consultant' - and COALESCE(pro_data.is_sub_project, FALSE) = False + --and COALESCE(pro_data.is_sub_project, FALSE) = False group by pro_data.pproject_id, AAL.employee_id,