Bar chart Report updated
This commit is contained in:
parent
3779cb8b7e
commit
3519bc45ed
|
@ -25,6 +25,9 @@ class BudgetAmtAnalysis(models.Model):
|
|||
('employee_rate', 'Consultant rate')
|
||||
], string="Pricing", readonly=True)
|
||||
employee_id = fields.Many2one('hr.employee', string='Consultant', readonly=True)
|
||||
start_date = fields.Date(string='Start Date', readonly=True)
|
||||
end_date = fields.Date(string='End Date', readonly=True)
|
||||
timesheet_date = fields.Date(string='Timesheet Date', readonly=True)
|
||||
#budgeted_revenue = fields.Float("Budgeted Revenue", digits=(16, 2), readonly=True, group_operator="sum")
|
||||
#actual_revenue = fields.Float("Actual Revenue", digits=(16, 2), readonly=True, group_operator="sum")
|
||||
|
||||
|
@ -33,47 +36,109 @@ class BudgetAmtAnalysis(models.Model):
|
|||
tools.drop_view_if_exists(self._cr, self._table)
|
||||
self._cr.execute("""
|
||||
CREATE OR REPLACE VIEW %s AS (
|
||||
SELECT ROW_NUMBER() OVER() as id, project_id, partner_id, employee_id, amount_type, pricing_type, project_type, revenue from (
|
||||
SELECT ROW_NUMBER() OVER() as id, project_id, start_date, end_date, timesheet_date, partner_id, employee_id, amount_type, pricing_type, project_type, revenue from (
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
pro.date_start AS start_date,
|
||||
pro.date AS end_date,
|
||||
pro.partner_id AS partner_id,
|
||||
pro_emp.employee_id AS employee_id,
|
||||
'Budgeted Revenue' as amount_type,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
null::date AS timesheet_date,
|
||||
pro_emp.cost AS revenue
|
||||
FROM project_project pro
|
||||
Left JOIN project_sale_line_employee_map pro_emp ON pro_emp.project_id = pro.id
|
||||
WHERE PRO.active = 't' and pro.pricing_type = 'employee_rate' and pro.project_type = 'hours_in_consultant'
|
||||
union
|
||||
union
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
pro.date_start AS start_date,
|
||||
pro.date AS end_date,
|
||||
pro.partner_id AS partner_id,
|
||||
AAL.employee_id AS employee_id,
|
||||
'Actual Revenue' as amount_type,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
null::date AS timesheet_date,
|
||||
(AAL.unit_amount * pro_emp.price_unit) AS revenue
|
||||
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 = 'employee_rate' and PRO.project_type = 'hours_in_consultant'
|
||||
union
|
||||
union
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
pro.date_start AS start_date,
|
||||
pro.date AS end_date,
|
||||
pro.partner_id AS partner_id,
|
||||
null::int AS employee_id,
|
||||
'Budgeted Revenue' as amount_type,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
null::date AS timesheet_date,
|
||||
pro.budgeted_hours2 AS revenue
|
||||
FROM project_project pro
|
||||
--Left JOIN project_sale_line_employee_map pro_emp ON pro_emp.project_id = pro.id
|
||||
WHERE PRO.active = 't' and pro.pricing_type = 'employee_rate' and pro.project_type = 'hours_no_limit'
|
||||
union
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
pro.date_start AS start_date,
|
||||
pro.date AS end_date,
|
||||
pro.partner_id AS partner_id,
|
||||
null::int AS employee_id,
|
||||
'Actual Revenue' as amount_type,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
null::date AS timesheet_date,
|
||||
(AAL.unit_amount) AS revenue
|
||||
--(AAL.unit_amount * pro_emp.price_unit) AS revenue
|
||||
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 = 'employee_rate' and PRO.project_type = 'hours_no_limit'
|
||||
union
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
pro.date_start AS start_date,
|
||||
pro.date AS end_date,
|
||||
pro.partner_id AS partner_id,
|
||||
AAL.employee_id AS employee_id,
|
||||
'Actual Cost' as amount_type,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
AAL.date AS timesheet_date,
|
||||
(AAL.amount * -1) AS revenue
|
||||
--(AAL.unit_amount * pro_emp.employee_price) AS revenue
|
||||
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 = 'employee_rate' and PRO.project_type = 'hours_in_consultant')
|
||||
WHERE PRO.active = 't' and PRO.pricing_type = 'employee_rate'
|
||||
--and PRO.project_type = 'hours_in_consultant'
|
||||
union
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
pro.date_start AS start_date,
|
||||
pro.date AS end_date,
|
||||
pro.partner_id AS partner_id,
|
||||
AAL.employee_id AS employee_id,
|
||||
'Actual Cost' as amount_type,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
AAL.date AS timesheet_date,
|
||||
(AAL.amount * -1) AS revenue
|
||||
--(AAL.unit_amount * pro_emp.employee_price) AS revenue
|
||||
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
|
||||
--and AAL.employee_id = pro_emp.employee_id
|
||||
WHERE PRO.active = 't' and PRO.pricing_type = 'fixed_rate')
|
||||
as res
|
||||
order by
|
||||
project_id,
|
||||
|
|
|
@ -34,14 +34,20 @@
|
|||
<search string="Budget Analysis">
|
||||
<field name="project_id"/>
|
||||
<field name="partner_id" filter_domain="[('partner_id', 'child_of', self)]"/>
|
||||
<!--<field name="employee_id"/>-->
|
||||
<field name="employee_id"/>
|
||||
<field name="start_date"/>
|
||||
<field name="end_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="fixed" domain="[('project_type','=','hours_in_consultant')]"/>
|
||||
<filter string="Total hours are budgeted without division to consultant" name="limit" domain="[('project_type','=','hours_no_limit')]"/>
|
||||
<filter string="Fixed rate" name="fixed" domain="[('pricing_type','=','fixed_rate')]"/>
|
||||
<group expand="1" string="Group By">
|
||||
<filter string="Project" name="group_by_project" context="{'group_by':'project_id'}"/>
|
||||
<filter string="Client" name="group_by_partner_id" context="{'group_by':'partner_id'}"/>
|
||||
<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'}"/>
|
||||
<filter string="End Date" name="edate" domain="[]" context="{'group_by':'end_date'}"/>
|
||||
<filter string="Timesheet Date" name="tdate" domain="[]" context="{'group_by':'timesheet_date'}"/>
|
||||
<filter string="Amount type" name="group_by_amount_type" context="{'group_by':'amount_type'}"/>
|
||||
</group>
|
||||
</search>
|
||||
|
|
|
@ -23,39 +23,23 @@ 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)
|
||||
#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")
|
||||
|
||||
@api.model
|
||||
"""@api.model
|
||||
def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
|
||||
print("rrr>>>>>>>>>>>>>>>>>>>>>>>>>.", 'hours_type' not in groupby)
|
||||
if 'hours_type' not in groupby:
|
||||
groupby.append('hours_type')
|
||||
print("rrr>>>>>>>>>>>>>>>>>>>>>>>>>.", groupby, orderby)
|
||||
"""fields.remove('on_time_rate')
|
||||
if 'qty_total' not in fields:
|
||||
fields.append('qty_total')
|
||||
if 'qty_on_time' not in fields:
|
||||
fields.append('qty_on_time')
|
||||
res = super().read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)
|
||||
for group in res:
|
||||
if group['qty_total'] == 0:
|
||||
on_time_rate = 100
|
||||
else:
|
||||
on_time_rate = group['qty_on_time'] / group['qty_total'] * 100
|
||||
group.update({'on_time_rate': on_time_rate}"""
|
||||
print("rrr>>>>>>>>>>>>>>>>>>>>>>>>>.", groupby, orderby)
|
||||
res = super().read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)
|
||||
print("Res", res)
|
||||
return res
|
||||
return res"""
|
||||
|
||||
def init(self):
|
||||
'''Create the view'''
|
||||
tools.drop_view_if_exists(self._cr, self._table)
|
||||
self._cr.execute("""
|
||||
CREATE OR REPLACE VIEW %s AS (
|
||||
SELECT ROW_NUMBER() OVER() as id, project_id, start_date, end_date, pricing_type, project_type, partner_id, employee_id, hours_type,
|
||||
SELECT ROW_NUMBER() OVER() as id, project_id, start_date, end_date, timesheet_date, pricing_type, project_type, partner_id, employee_id, hours_type,
|
||||
hours from (
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
|
@ -66,13 +50,14 @@ class BudgetHrsAnalysis(models.Model):
|
|||
pro.partner_id AS partner_id,
|
||||
pro_emp.employee_id AS employee_id,
|
||||
'Budgeted Hours' as hours_type,
|
||||
null::date AS timesheet_date,
|
||||
pro_emp.budgeted_qty as hours
|
||||
FROM
|
||||
project_project PRO
|
||||
Left JOIN project_sale_line_employee_map pro_emp ON pro_emp.project_id = pro.id
|
||||
Where
|
||||
pro.active = 't'
|
||||
and PRO.pricing_type != 'fixed_rate'
|
||||
and PRO.pricing_type = 'employee_rate'
|
||||
Union
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
|
@ -83,15 +68,36 @@ class BudgetHrsAnalysis(models.Model):
|
|||
pro.partner_id AS partner_id,
|
||||
AAL.employee_id AS employee_id,
|
||||
'Actual Hours' as hours_type,
|
||||
AAL.date AS timesheet_date,
|
||||
unit_amount as hours
|
||||
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 = 'employee_rate'
|
||||
--and PRO.project_type = 'hours_in_consultant'
|
||||
Union
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
pro.date_start AS start_date,
|
||||
pro.date AS end_date,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
pro.partner_id AS partner_id,
|
||||
AAL.employee_id AS employee_id,
|
||||
'Actual Hours' as hours_type,
|
||||
AAL.date AS timesheet_date,
|
||||
unit_amount as hours
|
||||
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'
|
||||
and PRO.pricing_type = 'fixed_rate'
|
||||
--and PRO.project_type = 'hours_in_consultant'
|
||||
) as res
|
||||
order by
|
||||
project_id desc,
|
||||
|
|
|
@ -51,14 +51,17 @@
|
|||
<field name="employee_id"/>
|
||||
<field name="start_date"/>
|
||||
<field name="end_date"/>
|
||||
<!--<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')]"/>-->
|
||||
<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')]"/>
|
||||
<group expand="1" string="Group By">
|
||||
<filter string="Project" name="group_by_project" context="{'group_by':'project_id'}"/>
|
||||
<filter string="Client" name="group_by_partner_id" context="{'group_by':'partner_id'}"/>
|
||||
<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'}"/>
|
||||
<filter string="End Date" name="edate" domain="[]" context="{'group_by':'end_date'}"/>
|
||||
<filter string="Timesheet Date" name="tdate" domain="[]" context="{'group_by':'timesheet_date'}"/>
|
||||
<filter string="Hours type" name="group_by_hours_type" context="{'group_by':'hours_type'}"/>
|
||||
</group>
|
||||
</search>
|
||||
|
|
Loading…
Reference in New Issue