Report type updated
This commit is contained in:
parent
bf4c336206
commit
8d30c1246b
|
@ -24,7 +24,7 @@ class BudgetAmtAnalysis(models.Model):
|
|||
('fixed_rate', 'Fixed rate'),
|
||||
('employee_rate', 'Consultant rate')
|
||||
], string="Pricing", readonly=True)
|
||||
#employee_id = fields.Many2one('hr.employee', string='Employee', readonly=True)
|
||||
employee_id = fields.Many2one('hr.employee', string='Consultant', 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,38 +33,60 @@ 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, amount_type, pricing_type, project_type, revenue from (
|
||||
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,
|
||||
PRO.id AS project_id,
|
||||
PRO.create_date AS create_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,
|
||||
PRO.budgeted_revenue AS revenue
|
||||
FROM project_project PRO
|
||||
LEFT JOIN sale_order SO ON PRO.sale_order_id = SO.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
|
||||
WHERE PRO.active = 't'
|
||||
group by Pro.id, PRO.partner_id, Pro.budgeted_revenue, so.amount_total
|
||||
union
|
||||
SELECT
|
||||
row_number() OVER() AS id,
|
||||
WHERE PRO.active = 't' and (PRO.pricing_type = 'fixed_rate' OR PRO.project_type = 'hours_no_limit')
|
||||
union
|
||||
SELECT
|
||||
PRO.id AS project_id,
|
||||
PRO.create_date AS create_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,
|
||||
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
|
||||
SELECT
|
||||
PRO.id AS project_id,
|
||||
PRO.create_date AS create_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,
|
||||
(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
|
||||
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.create_date AS create_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,
|
||||
pro.total_expenses AS revenue
|
||||
FROM project_project PRO
|
||||
LEFT JOIN sale_order SO ON PRO.sale_order_id = SO.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
|
||||
WHERE PRO.active = 't'
|
||||
group by Pro.id, PRO.partner_id, Pro.budgeted_revenue, so.amount_total
|
||||
group by Pro.id, PRO.partner_id, Pro.budgeted_revenue
|
||||
order by create_date desc, project_id, amount_type desc) as res
|
||||
)""" % (self._table,))
|
||||
|
||||
|
|
|
@ -40,9 +40,9 @@
|
|||
<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="Customer" name="group_by_partner_id" context="{'group_by':'partner_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="Amount type" name="group_by_amount_type" context="{'group_by':'amount_type'}"/>
|
||||
<!--<filter string="Consultant" name="group_by_employee_id" context="{'group_by':'employee_id'}"/>-->
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
|
|
|
@ -35,7 +35,7 @@ class BudgetHrsAnalysis(models.Model):
|
|||
PRO.id AS project_id,
|
||||
PRO.create_date AS create_date,
|
||||
PRO.partner_id AS partner_id,
|
||||
null AS employee_id,
|
||||
null::int AS employee_id,
|
||||
'Budgeted Hours' as hours_type,
|
||||
PRO.project_type as project_type,
|
||||
PRO.budgeted_hours AS hours
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<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="Customer" name="group_by_partner_id" context="{'group_by':'partner_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="Hours type" name="group_by_hours_type" context="{'group_by':'hours_type'}"/>
|
||||
</group>
|
||||
|
|
Loading…
Reference in New Issue