forked from OCA/business-requirement
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.0][ADD] BI report for the business requirements (OCA#86)
* [ADD] BI report for the business requirements * [FIX] pylint * [IMP] Added Access rights * [FIX] travis * [FIX] made requested changes * [FIX] Fixed travis * [IMP] Added Br report file and improved code * [IMP] Changed as per comments. * [IMP] Improved code. * [IMP]Improved SQL readabilityby submethods. * [IMP]Improved Indentation.
- Loading branch information
1 parent
4d5db29
commit d865548
Showing
8 changed files
with
244 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Elico Corp (www.elico-corp.com). | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from . import br_deliverable_report | ||
from . import br_deliverable_sale_report |
81 changes: 81 additions & 0 deletions
81
business_requirement_deliverable/report/br_deliverable_report.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Elico Corp (https://www.elico-corp.com). | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openerp import tools | ||
from openerp import fields, models | ||
|
||
|
||
class BusinessRequirementDeliverableReport(models.Model): | ||
_name = "business.requirement.deliverable.report" | ||
_description = "Deliverable Report" | ||
_auto = False | ||
|
||
name = fields.Char('Name', readonly=True) | ||
description = fields.Char('Description', readonly=True) | ||
partner_id = fields.Many2one('res.partner', 'Customer', | ||
readonly=True) | ||
project_id = fields.Many2one('project.project', 'Master Project', | ||
readonly=True) | ||
change_request = fields.Boolean('Change Request?', readonly=True) | ||
priority = fields.Selection([('0', 'Low'), ('1', 'Normal'), | ||
('2', 'High')], | ||
'Priority', readonly=True) | ||
dlv_description = fields.Text('Deliverable Description', readonly=True) | ||
dlv_product = fields.Many2one('product.product', 'Dlv Product', | ||
readonly=True) | ||
res_description = fields.Text('Resource Description', readonly=True) | ||
res_product = fields.Many2one('product.product', 'Res Product', | ||
readonly=True) | ||
br_count = fields.Integer('BR Count', readonly=True) | ||
dlv_count = fields.Integer('Deliverable Count', readonly=True) | ||
res_count = fields.Integer('Resource Count', readonly=True) | ||
dlv_qty = fields.Float('Deliverable Qty', readonly=True) | ||
res_qty = fields.Float('Resource Qty', readonly=True) | ||
|
||
def _select(self): | ||
select_str = """ | ||
SELECT | ||
br.id, | ||
br.name, | ||
br.description, | ||
br.partner_id, | ||
br.project_id, | ||
br.change_request, | ||
br.priority, | ||
dlv.product_id as dlv_product, | ||
dlv.name as dlv_description, | ||
res.product_id as res_product, | ||
res.name as res_description, | ||
count(distinct br.id) as br_count, | ||
count(distinct dlv.id) as dlv_count, | ||
count(distinct res.id) as res_count, | ||
res.qty as res_qty, | ||
dlv.qty as dlv_qty | ||
""" | ||
return select_str | ||
|
||
def _from(self): | ||
from_str = """ | ||
business_requirement br | ||
FULL OUTER JOIN business_requirement_deliverable dlv | ||
ON br.id = dlv.business_requirement_id | ||
FULL OUTER JOIN business_requirement_resource res | ||
ON res.business_requirement_deliverable_id = dlv.id | ||
""" | ||
return from_str | ||
|
||
def _group_by(self): | ||
group_by_str = """ | ||
GROUP BY | ||
dlv.id, br.id, res.id | ||
""" | ||
return group_by_str | ||
|
||
def init(self, cr): | ||
tools.drop_view_if_exists(cr, self._table) | ||
cr.execute("""CREATE or REPLACE VIEW %s as ( | ||
%s | ||
FROM ( %s ) | ||
%s | ||
)""" % (self._table, self._select(), self._from(), | ||
self._group_by())) |
32 changes: 32 additions & 0 deletions
32
business_requirement_deliverable/report/br_deliverable_report_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
|
||
<record id="view_deliverable_graph" model="ir.ui.view"> | ||
<field name="name">Deliverable Report</field> | ||
<field name="model">business.requirement.deliverable.report</field> | ||
<field name="arch" type="xml"> | ||
<graph string="Deliverable Analysis" type="pivot" stacked="True"> | ||
<field name="name" type="row"/> | ||
<field name="br_count" type="measure"/> | ||
<field name="dlv_count" type="measure"/> | ||
<field name="res_count" type="measure"/> | ||
<field name="res_qty" type="measure"/> | ||
<field name="dlv_qty" type="measure"/> | ||
</graph> | ||
</field> | ||
</record> | ||
|
||
<record id="action_deliverable_report" model="ir.actions.act_window"> | ||
<field name="name">Deliverable Analysis</field> | ||
<field name="res_model">business.requirement.deliverable.report</field> | ||
<field name="view_type">form</field> | ||
<field name="view_mode">graph</field> | ||
<field name="view_id" ref="view_deliverable_graph"/> | ||
</record> | ||
|
||
<menuitem action="action_deliverable_report" id="menu_action_deliverable_report" | ||
parent="base.menu_project_report"/> | ||
|
||
</data> | ||
</openerp> |
83 changes: 83 additions & 0 deletions
83
business_requirement_deliverable/report/br_deliverable_sale_report.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Elico Corp (https://www.elico-corp.com). | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openerp import tools | ||
from openerp import fields, models | ||
|
||
|
||
class BusinessRequirementDeliverableSaleReport(models.Model): | ||
_name = "business.requirement.deliverable.sale.report" | ||
_description = "Deliverable Sales Report" | ||
_auto = False | ||
|
||
name = fields.Char('Name', readonly=True) | ||
description = fields.Char('Description', readonly=True) | ||
partner_id = fields.Many2one('res.partner', 'Customer', readonly=True) | ||
project_id = fields.Many2one('project.project', 'Master Project', | ||
readonly=True) | ||
change_request = fields.Boolean('Change Request?', readonly=True) | ||
priority = fields.Selection([('0', 'Low'), ('1', 'Normal'), ('2', 'High')], | ||
'Priority', readonly=True) | ||
dlv_description = fields.Text('Deliverable Description', readonly=True) | ||
dlv_product = fields.Many2one('product.product', 'Dlv Product', | ||
readonly=True) | ||
res_description = fields.Text('Resource Description', readonly=True) | ||
res_product = fields.Many2one('product.product', 'Res Product', | ||
readonly=True) | ||
br_count = fields.Integer('BR Count', readonly=True) | ||
dlv_count = fields.Integer('Deliverable Count', readonly=True) | ||
res_count = fields.Integer('Resource Count', readonly=True) | ||
dlv_qty = fields.Float('Deliverable Qty', readonly=True) | ||
res_qty = fields.Float('Resource Qty', readonly=True) | ||
sale_price = fields.Float('Sale Price', readonly=True) | ||
total_revenue = fields.Float('Total Revenue', readonly=True) | ||
|
||
def _select(self): | ||
select_str = """ | ||
SELECT | ||
br.id, | ||
br.name, | ||
br.description, | ||
br.partner_id, | ||
br.project_id, | ||
br.change_request, | ||
br.priority, | ||
dlv.product_id as dlv_product, | ||
dlv.name as dlv_description, | ||
res.product_id as res_product, | ||
res.name as res_description, | ||
count(distinct br.id) as br_count, | ||
count(distinct dlv.id) as dlv_count, | ||
count(distinct res.id) as res_count, | ||
res.qty as res_qty, | ||
dlv.qty as dlv_qty, | ||
dlv.unit_price as sale_price, | ||
(dlv.unit_price * dlv.qty) as total_revenue | ||
""" | ||
return select_str | ||
|
||
def _from(self): | ||
from_str = """ | ||
business_requirement br | ||
FULL OUTER JOIN business_requirement_deliverable dlv | ||
ON br.id = dlv.business_requirement_id | ||
FULL OUTER JOIN business_requirement_resource res | ||
ON res.business_requirement_deliverable_id = dlv.id | ||
""" | ||
return from_str | ||
|
||
def _group_by(self): | ||
group_by_str = """ | ||
GROUP BY | ||
dlv.id, br.id, res.id | ||
""" | ||
return group_by_str | ||
|
||
def init(self, cr): | ||
tools.drop_view_if_exists(cr, self._table) | ||
cr.execute("""CREATE or REPLACE VIEW %s as ( | ||
%s | ||
FROM ( %s ) | ||
%s | ||
)""" % (self._table, self._select(), self._from(), | ||
self._group_by())) |
36 changes: 36 additions & 0 deletions
36
business_requirement_deliverable/report/br_deliverable_sale_report_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
|
||
<record id="view_deliverable_sale_graph" model="ir.ui.view"> | ||
<field name="name">Deliverable Sale Report</field> | ||
<field name="model">business.requirement.deliverable.sale.report</field> | ||
<field name="arch" type="xml"> | ||
<graph string="Sales Analysis" type="pivot" stacked="True"> | ||
<field name="name" type="row"/> | ||
<field name="br_count" type="measure"/> | ||
<field name="dlv_count" type="measure"/> | ||
<field name="res_count" type="measure"/> | ||
<field name="res_qty" type="measure"/> | ||
<field name="dlv_qty" type="measure"/> | ||
<field name="sale_price" type="measure"/> | ||
<field name="total_revenue" type="measure"/> | ||
</graph> | ||
</field> | ||
</record> | ||
|
||
<record id="action_deliverable_sale_report" model="ir.actions.act_window"> | ||
<field name="name">Deliverable Sale Analysis</field> | ||
<field name="res_model">business.requirement.deliverable.sale.report</field> | ||
<field name="view_type">form</field> | ||
<field name="view_mode">graph</field> | ||
<field name="view_id" ref="view_deliverable_sale_graph"/> | ||
</record> | ||
|
||
<menuitem action="action_deliverable_sale_report" | ||
id="menu_action_deliverable_sale_report" | ||
parent="base.menu_project_report" | ||
groups="business_requirement_deliverable.group_business_requirement_estimation"/> | ||
|
||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters