Project budget report updated
This commit is contained in:
parent
42ab9e4c22
commit
8887ddca44
|
@ -32,6 +32,10 @@ class BudgetAmtAnalysis(models.Model):
|
|||
end_date = fields.Date(string='End Date', readonly=True)
|
||||
timesheet_date = fields.Date(string='Timesheet Date', readonly=True)
|
||||
timesheet_sdatetime = fields.Datetime(string='Timesheet Start Time', readonly=True)
|
||||
unit_amount = fields.Float('Timesheet Hours')
|
||||
timesheet_cost = fields.Float('Timesheet Cost')
|
||||
profit_per = fields.Float(string='Porfit Percentage', digits=(16, 2))
|
||||
profit_amt = fields.Float(string='Profit Amount', digits=(16, 2))
|
||||
#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")
|
||||
|
||||
|
@ -40,7 +44,9 @@ 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, parentproject as parent_project, start_date, end_date, timesheet_date, timesheet_sdatetime, partner_id, employee_id, amount_type, pricing_type, project_type, revenue from (
|
||||
SELECT ROW_NUMBER() OVER() as id, project_id, parentproject as parent_project,
|
||||
start_date, end_date, timesheet_date, timesheet_sdatetime, unit_amount, timesheet_cost, partner_id, employee_id, amount_type,
|
||||
profit_per, profit_amt, pricing_type, project_type, revenue from (
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parentproject,
|
||||
|
@ -49,10 +55,14 @@ class BudgetAmtAnalysis(models.Model):
|
|||
pro.partner_id AS partner_id,
|
||||
pro_emp.employee_id AS employee_id,
|
||||
'Budgeted Revenue' as amount_type,
|
||||
pro.profit_per,
|
||||
pro.profit_amt,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
null::date AS timesheet_date,
|
||||
null::timestamp AS timesheet_sdatetime,
|
||||
0.0 as unit_amount,
|
||||
0.0 as timesheet_cost,
|
||||
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
|
||||
|
@ -66,18 +76,23 @@ class BudgetAmtAnalysis(models.Model):
|
|||
pro.partner_id AS partner_id,
|
||||
AAL.employee_id AS employee_id,
|
||||
'Actual Cost' as amount_type,
|
||||
pro.profit_per,
|
||||
pro.profit_amt,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
AAL.date AS timesheet_date,
|
||||
AAL.start_datetime AS timesheet_sdatetime,
|
||||
(sum(AAL.unit_amount) * pro_emp.employee_price) AS revenue
|
||||
AAL.unit_amount as unit_amount,
|
||||
emp.timesheet_cost as timesheet_cost,
|
||||
(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
|
||||
LEFT JOIN hr_employee emp on AAL.employee_id = emp.id
|
||||
WHERE PRO.active = 't' and AAL.employee_id is not null and PRO.pricing_type = 'employee_rate'
|
||||
and PRO.project_type in ('hours_in_consultant', 'hours_no_limit')
|
||||
group by pro.id, aal.employee_id, aal.date, aal.start_datetime, pro_emp.employee_price
|
||||
--group by pro.id, aal.employee_id, aal.date, aal.start_datetime, pro_emp.employee_price, AAL.unit_amount
|
||||
union
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
|
@ -87,16 +102,21 @@ class BudgetAmtAnalysis(models.Model):
|
|||
pro.partner_id AS partner_id,
|
||||
AAL.employee_id AS employee_id,
|
||||
'Actual Revenue' as amount_type,
|
||||
pro.profit_per,
|
||||
pro.profit_amt,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
AAL.date AS timesheet_date,
|
||||
AAL.start_datetime AS timesheet_sdatetime,
|
||||
(sum(AAL.unit_amount) * pro.hourly_rate) AS revenue
|
||||
AAL.unit_amount as unit_amount,
|
||||
emp.timesheet_cost as timesheet_cost,
|
||||
(AAL.unit_amount * pro.hourly_rate) 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
|
||||
LEFT JOIN hr_employee emp on AAL.employee_id = emp.id
|
||||
WHERE PRO.active = 't' and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_no_limit'
|
||||
group by pro.id, aal.employee_id, aal.date, aal.unit_amount, aal.start_datetime
|
||||
--group by pro.id, aal.employee_id, aal.date, aal.unit_amount, aal.start_datetime, AAL.unit_amount
|
||||
union
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
|
@ -106,10 +126,14 @@ class BudgetAmtAnalysis(models.Model):
|
|||
pro.partner_id AS partner_id,
|
||||
null::int AS employee_id,
|
||||
'Budgeted Revenue' as amount_type,
|
||||
pro.profit_per,
|
||||
pro.profit_amt,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
null::date AS timesheet_date,
|
||||
null::timestamp AS timesheet_sdatetime,
|
||||
0.0 as unit_amount,
|
||||
0.0 as timesheet_cost,
|
||||
pro.budgeted_revenue AS revenue
|
||||
FROM project_project pro
|
||||
--Left JOIN project_sale_line_employee_map pro_emp ON pro_emp.project_id = pro.id
|
||||
|
@ -123,17 +147,22 @@ class BudgetAmtAnalysis(models.Model):
|
|||
pro.partner_id AS partner_id,
|
||||
AAL.employee_id AS employee_id,
|
||||
'Actual Revenue' as amount_type,
|
||||
pro.profit_per,
|
||||
pro.profit_amt,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
AAL.date AS timesheet_date,
|
||||
AAL.start_datetime AS timesheet_sdatetime,
|
||||
(sum(AAL.unit_amount) * pro_emp.price_unit) AS revenue
|
||||
AAL.unit_amount as unit_amount,
|
||||
emp.timesheet_cost as timesheet_cost,
|
||||
(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
|
||||
LEFT JOIN hr_employee emp on AAL.employee_id = emp.id
|
||||
WHERE PRO.active = 't' and AAL.employee_id is not null and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_in_consultant'
|
||||
group by pro.id, aal.employee_id, aal.date, aal.start_datetime, pro_emp.price_unit
|
||||
--group by pro.id, aal.employee_id, aal.date, aal.start_datetime, AAL.unit_amount, pro_emp.price_unit
|
||||
union
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
|
@ -143,14 +172,19 @@ class BudgetAmtAnalysis(models.Model):
|
|||
pro.partner_id AS partner_id,
|
||||
AAL.employee_id AS employee_id,
|
||||
'Actual Cost' as amount_type,
|
||||
pro.profit_per,
|
||||
pro.profit_amt,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
AAL.date AS timesheet_date,
|
||||
AAL.start_datetime AS timesheet_sdatetime,
|
||||
AAL.unit_amount as unit_amount,
|
||||
emp.timesheet_cost as timesheet_cost,
|
||||
(AAL.amount * -1) 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
|
||||
LEFT JOIN hr_employee emp on AAL.employee_id = emp.id
|
||||
--and AAL.employee_id = pro_emp.employee_id
|
||||
WHERE PRO.active = 't' and PRO.pricing_type = 'fixed_rate')
|
||||
as res
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
<field name="model">project.budget.amt.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<pivot string="Budget Analysis" disable_linking="True" sample="1"> <!-- display_quantity="true" -->
|
||||
<field name="project_id" type="col"/>
|
||||
<field name="amount_type" type="col"/>
|
||||
<field name="project_id" type="row"/>
|
||||
<field name="unit_amount" type="measure"/>
|
||||
<field name="timesheet_cost" type="measure"/>
|
||||
<field name="revenue" type="measure"/>
|
||||
</pivot>
|
||||
</field>
|
||||
|
@ -19,9 +20,7 @@
|
|||
<field name="arch" type="xml">
|
||||
<graph string="Budget Analysis" type="bar" stacked="False" sample="1" disable_linking="1">
|
||||
<field name="revenue" type="row"/>
|
||||
<field name="project_id" type="row"/>
|
||||
<field name="amount_type" type="row"/>
|
||||
<field name="revenue" type="measure"/>
|
||||
<field name="project_id" type="col"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -36,6 +35,7 @@
|
|||
<field name="end_date"/>
|
||||
<field name="employee_id"/>
|
||||
<field name="timesheet_date" optional="hide"/>
|
||||
<field name="unit_amount"/>
|
||||
<field name="amount_type"/>
|
||||
<field name="revenue"/>
|
||||
<field name="parent_project" optional="hide"/>
|
||||
|
@ -80,6 +80,7 @@
|
|||
<field name="res_model">project.budget.amt.report</field>
|
||||
<field name="view_mode">graph,tree,pivot</field>
|
||||
<field name="search_view_id" ref="project_budget_amt_report_view_search"/>
|
||||
<!--<field name="context">{'default_res_model': 'project.budget.amt.report'}</field>-->
|
||||
<field name="context">{'search_default_group_by_project': 1,'search_default_group_by_amount_type': 1, 'default_res_model': 'project.budget.amt.report', 'search_default_notfixed':1}</field>
|
||||
</record>
|
||||
|
||||
|
|
Loading…
Reference in New Issue