Merge branch 'cor_cr' into 'master'

Cor cr

See merge request prakash.jain/cor-odoo!255
This commit is contained in:
prakash.jain 2022-09-30 20:05:30 +05:30
commit 50c34c2c72
3 changed files with 39 additions and 17 deletions

View File

@ -374,9 +374,16 @@ class InheritProjectProductEmployeeMap(models.Model):
#e_datetime1 = timezone(tz).localize(e_datetime).astimezone(UTC)
date_clause += " and end_datetime at time zone 'utc' at time zone (select tz from res_partner where id=3) <= %s"
query_params.append(e_datetime)
query = """SELECT project_id, employee_id, SUM(unit_amount) FROM account_analytic_line
where project_id = %s and employee_id = %s {date_clause}
GROUP BY project_id, employee_id""".format(date_clause=date_clause)
#print('1111111111111', val.project_id)
#print('222222222222222', query_params)
if val.project_id.is_sub_project == False:
query = """SELECT project_id, employee_id, SUM(unit_amount) FROM account_analytic_line
where project_id = %s and employee_id = %s {date_clause}
GROUP BY project_id, employee_id""".format(date_clause=date_clause)
else:
query = """SELECT sub_project, employee_id, SUM(unit_amount) FROM account_analytic_line
where sub_project = %s and employee_id = %s {date_clause}
GROUP BY sub_project, employee_id""".format(date_clause=date_clause)
self.env.cr.execute(query, query_params)
#self._cr.execute('''SELECT project_id, employee_id, SUM(unit_amount) FROM account_analytic_line
#where project_id = %(project_id)s and employee_id = %(employee_id)s

View File

@ -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

View File

@ -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,
@ -472,7 +475,8 @@ data3_sub_project as (
SELECT
min(sub_pro_data.pro_sdate) as start_date,
max(sub_pro_data.pro_edate) as end_date,
sub_pro_data.parent_project as project_id,
--sub_pro_data.parent_project as project_id,
sub_pro_data.pproject_id as project_id,
sub_pro_data.project_active,
sub_pro_data.project_type,
sub_pro_data.pricing_type,
@ -500,7 +504,7 @@ SELECT
where sub_pro_data.pricing_type='employee_rate' and sub_pro_data.project_type='hours_in_consultant'
and sub_pro_data.is_sub_project = True
group by
sub_pro_data.parent_project,
sub_pro_data.pproject_id,
sub_pro_data.project_active,
sub_pro_data.project_type,
sub_pro_data.parent_project,
@ -515,7 +519,8 @@ UNION
SELECT
drange_data2.start_date,
drange_data2.end_date,
sub_pro_data.parent_project as project_id,
sub_pro_data.pproject_id as project_id,
--sub_pro_data.parent_project as project_id,
--drange_data2.project_id,
sub_pro_data.project_active,
sub_pro_data.project_type,
@ -552,7 +557,8 @@ SELECT
group by
drange_data2.start_date,
drange_data2.end_date,
sub_pro_data.parent_project,
sub_pro_data.pproject_id,
--sub_pro_data.parent_project,
drange_data2.employee_id,
sub_pro_data.project_active,
sub_pro_data.project_type,