Updated report
This commit is contained in:
parent
e4c9fedb3d
commit
ffb8d29ad2
|
@ -14,7 +14,7 @@ class BudgetAmtAnalysis(models.Model):
|
|||
#analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account', readonly=True)
|
||||
project_id = fields.Many2one('project.project', string='Project', readonly=True)
|
||||
partner_id = fields.Many2one('res.partner', string='Client', readonly=True)
|
||||
employee_id = fields.Many2one('hr.employee', string='Employee', readonly=True)
|
||||
#employee_id = fields.Many2one('hr.employee', string='Employee', 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")
|
||||
|
||||
|
@ -27,15 +27,14 @@ class BudgetAmtAnalysis(models.Model):
|
|||
row_number() OVER() AS id,
|
||||
PRO.id AS project_id,
|
||||
PRO.partner_id AS partner_id,
|
||||
AAL.employee_id AS employee_id,
|
||||
PRO.budgeted_revenue AS budgeted_revenue,
|
||||
SO.amount_total AS actual_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' AND PRO.allow_timesheets = 't'
|
||||
group by Pro.id, PRO.partner_id, AAL.employee_id, Pro.budgeted_revenue, so.amount_total
|
||||
WHERE PRO.active = 't'
|
||||
group by Pro.id, PRO.partner_id, Pro.budgeted_revenue, so.amount_total
|
||||
)""" % (self._table,))
|
||||
|
||||
|
||||
|
|
|
@ -33,11 +33,11 @@
|
|||
<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"/>-->
|
||||
<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="Consultant" name="group_by_employee_id" context="{'group_by':'employee_id'}"/>
|
||||
<!--<filter string="Consultant" name="group_by_employee_id" context="{'group_by':'employee_id'}"/>-->
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
|
|
|
@ -15,7 +15,8 @@ class BudgetHrsAnalysis(models.Model):
|
|||
project_id = fields.Many2one('project.project', string='Project', readonly=True)
|
||||
partner_id = fields.Many2one('res.partner', string='Client', readonly=True)
|
||||
employee_id = fields.Many2one('hr.employee', string='Employee', readonly=True)
|
||||
budgeted_hours = fields.Float("Budgeted Hours", digits=(16, 2), readonly=True, group_operator="sum")
|
||||
project_budgeted_hours = fields.Float("Project Budgeted Hours", digits=(16, 2), readonly=True, group_operator="sum")
|
||||
cons_budgeted_hours = fields.Float("Consultant Budgeted Hours", digits=(16, 2), readonly=True, group_operator="sum")
|
||||
actual_hours = fields.Float("Actual Hours", digits=(16, 2), readonly=True, group_operator="sum")
|
||||
|
||||
def init(self):
|
||||
|
@ -23,18 +24,20 @@ class BudgetHrsAnalysis(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,
|
||||
PRO.id AS project_id,
|
||||
PRO.partner_id AS partner_id,
|
||||
AAL.employee_id AS employee_id,
|
||||
PRO.budgeted_hours AS budgeted_hours,
|
||||
SELECT row_number() OVER() AS id,
|
||||
Pro.id AS project_id,
|
||||
Pro.partner_id AS partner_id,
|
||||
Pro_emp.budgeted_qty AS cons_budgeted_hours,
|
||||
Pro.budgeted_hours AS project_budgeted_hours,
|
||||
AAL.employee_id as employee_id,
|
||||
sum(AAL.unit_amount) AS actual_hours
|
||||
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 AAL.amount < 0.0 AND AAL.project_id IS NOT NULL AND
|
||||
Where PRO.active = 't' AND PRO.allow_timesheets = 't'
|
||||
group by Pro.id, PRO.partner_id, AAL.employee_id, AAL.unit_amount,PRO.budgeted_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'
|
||||
group by Pro.id, PRO.partner_id, AAL.employee_id, AAL.unit_amount, PRO.budgeted_hours, Pro_emp.budgeted_qty
|
||||
)""" % (self._table,))
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<field name="arch" type="xml">
|
||||
<pivot string="Budget Analysis" disable_linking="True" sample="1"> <!-- display_quantity="true" -->
|
||||
<field name="project_id" type="row"/>
|
||||
<field name="budgeted_hours" type="measure"/>
|
||||
<field name="project_budgeted_hours" type="measure"/>
|
||||
<field name="actual_hours" type="measure"/>
|
||||
</pivot>
|
||||
</field>
|
||||
|
@ -18,7 +18,7 @@
|
|||
<field name="model">project.budget.hrs.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Budget Analysis" type="bar" stacked="True" sample="1" disable_linking="1">
|
||||
<field name="budgeted_hours" type="row"/>
|
||||
<field name="project_budgeted_hours" type="row"/>
|
||||
<field name="project_id" type="row"/>
|
||||
<field name="actual_hours" type="measure"/>
|
||||
</graph>
|
||||
|
|
Loading…
Reference in New Issue