bzr revid: hmo@tinyerp.com-20100303093005-8xc6oin909l1vp87
This commit is contained in:
Harry (Open ERP) 2010-03-03 15:00:05 +05:30
commit 6244d2f561
9 changed files with 77 additions and 263 deletions

View File

@ -1,12 +1,14 @@
from osv import fields,osv
import tools
class report_crm_project_bug_user(osv.osv):
_name = "report.crm.project.bug.user"
class report_crm_project_bug(osv.osv):
_name = "report.crm.project.bug"
_description = "Project Bug by user and section"
_auto = False
_inherit = "report.crm.case.user"
_inherit = "report.crm.case"
_columns = {
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.project.bug')]"),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('object_id.model', '=', 'crm.project.bug')]"),
'probability': fields.float('Avg. Probability', readonly=True),
'amount_revenue': fields.float('Est.Revenue', readonly=True),
'amount_costs': fields.float('Est.Cost', readonly=True),
@ -14,9 +16,9 @@ class report_crm_project_bug_user(osv.osv):
'delay_close': fields.char('Delay to close', size=20, readonly=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_crm_project_bug_user')
tools.drop_view_if_exists(cr, 'report_crm_project_bug')
cr.execute("""
create or replace view report_crm_project_bug_user as (
create or replace view report_crm_project_bug as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
@ -24,43 +26,8 @@ class report_crm_project_bug_user(osv.osv):
c.state,
c.user_id,
c.section_id,
count(*) as nbr,
sum(planned_revenue) as amount_revenue,
sum(planned_cost) as amount_costs,
sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
avg(probability)::decimal(16,2) as probability,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_project_bug c
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state, c.user_id,c.section_id
)""")
report_crm_project_bug_user()
class report_crm_project_bug_categ(osv.osv):
_name = "report.crm.project.bug.categ"
_description = "Project Bug by section and category"
_auto = False
_inherit = "report.crm.case.categ"
_columns = {
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.project.bug')]"),
'amount_revenue': fields.float('Est.Revenue', readonly=True),
'amount_costs': fields.float('Est.Cost', readonly=True),
'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
'probability': fields.float('Avg. Probability', readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_crm_project_bug_categ')
cr.execute("""
create or replace view report_crm_project_bug_categ as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.categ_id,
c.state,
c.section_id,
c.stage_id,
count(*) as nbr,
sum(planned_revenue) as amount_revenue,
sum(planned_cost) as amount_costs,
@ -69,63 +36,9 @@ class report_crm_project_bug_categ(osv.osv):
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_project_bug c
group by c.categ_id,to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state,c.section_id
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state, c.user_id,c.section_id,c.categ_id,c.stage_id
)""")
report_crm_project_bug_categ()
report_crm_project_bug()
class report_crm_project_bug_section(osv.osv):
_name = "report.crm.project.bug.section"
_description = "Project bug by Section"
_auto = False
_inherit = "report.crm.case.section"
def _get_data(self, cr, uid, ids, field_name, arg, context={}):
res = {}
state_perc = 0.0
avg_ans = 0.0
for case in self.browse(cr, uid, ids, context):
if field_name != 'avg_answers':
state = field_name[5:]
cr.execute("select count(*) from crm_project_bug where section_id =%s and state='%s'"%(case.section_id.id,state))
state_cases = cr.fetchone()[0]
perc_state = (state_cases / float(case.nbr_cases) ) * 100
res[case.id] = perc_state
else:
cr.execute('select count(*) from crm_case_log l where l.section_id=%s'%(case.section_id.id))
logs = cr.fetchone()[0]
avg_ans = logs / case.nbr_cases
res[case.id] = avg_ans
return res
_columns = {
'avg_answers': fields.function(_get_data,string='Avg. Answers', method=True,type="integer"),
'perc_done': fields.function(_get_data,string='%Done', method=True,type="float"),
'perc_cancel': fields.function(_get_data,string='%Cancel', method=True,type="float"),
'delay_close': fields.char('Delay to close', size=20, readonly=True),
}
_order = 'name desc, section_id'
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_crm_project_bug_section')
cr.execute("""
create or replace view report_crm_project_bug_section as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
to_char(c.create_date, 'MM') as month,
count(*) as nbr_cases,
c.section_id as section_id,
0 as avg_answers,
0.0 as perc_done,
0.0 as perc_cancel,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_project_bug c
group by to_char(c.create_date, 'YYYY'),to_char(c.create_date, 'MM'),c.section_id
)""")
report_crm_project_bug_section()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -2,28 +2,32 @@
<openerp>
<data>
<!--
Project Bug by user and section
Project Bug
-->
<record id="view_crm_project_bug_user_tree" model="ir.ui.view">
<field name="name">report.crm.project.bug.user.tree</field>
<field name="model">report.crm.project.bug.user</field>
<field name="inherit_id" ref="report_crm.view_crm_case_user_tree"/>
<record id="view_crm_project_bug_tree" model="ir.ui.view">
<field name="name">report.crm.project.bug.tree</field>
<field name="model">report.crm.project.bug</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
<field name="delay_close"/>
<tree string="Project Bug">
<field name="name" />
<field name="month"/>
<field name="nbr" string="#Project Bug"/>
<field name="amount_revenue"/>
<field name="amount_costs"/>
<field name="amount_revenue_prob"/>
<field name="probability"/>
</field>
<field name="delay_close"/>
<field name="state"/>
<field name="user_id" invisible="1"/>
<field name="stage_id" invisible="1"/>
<field name="categ_id" invisible="1"/>
</tree>
</field>
</record>
<record id="view_crm_project_bug_user_form" model="ir.ui.view">
<field name="name">report.crm.project.bug.user.form</field>
<field name="model">report.crm.project.bug.user</field>
<field name="inherit_id" ref="report_crm.view_crm_case_user_form"/>
<record id="view_crm_project_bug_form" model="ir.ui.view">
<field name="name">report.crm.project.bug.form</field>
<field name="model">report.crm.project.bug</field>
<field name="inherit_id" ref="report_crm.view_crm_case_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
@ -36,12 +40,12 @@
</field>
</record>
<record id="view_crm_project_bug_user_graph" model="ir.ui.view">
<field name="name">report.crm.project.bug.user.graph</field>
<field name="model">report.crm.project.bug.user</field>
<record id="view_crm_project_bug_graph" model="ir.ui.view">
<field name="name">report.crm.project.bug.graph</field>
<field name="model">report.crm.project.bug</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Project Bug by User and Section" type="bar">
<graph orientation="horizontal" string="Project Bug" type="bar">
<field name="state"/>
<field name="nbr" operator="+"/>
<field group="True" name="user_id"/>
@ -49,10 +53,10 @@
</field>
</record>
<record id="view_crm_project_bug_user_filter" model="ir.ui.view">
<field name="name">report.crm.project.bug.user.select</field>
<field name="model">report.crm.project.bug.user</field>
<field name="inherit_id" ref="report_crm.view_crm_case_user_filter"/>
<record id="view_crm_project_bug_filter" model="ir.ui.view">
<field name="name">report.crm.project.bug.select</field>
<field name="model">report.crm.project.bug</field>
<field name="inherit_id" ref="report_crm.view_crm_case_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="state" position="before">
@ -60,134 +64,30 @@
</field>
</record>
<record id="action_report_crm_project_bug_user_tree" model="ir.actions.act_window">
<field name="name">Project Bug by User and Section</field>
<field name="res_model">report.crm.project.bug.user</field>
<record id="action_report_crm_project_bug" model="ir.actions.act_window">
<field name="name">Project Bug</field>
<field name="res_model">report.crm.project.bug</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_crm_project_bug_user_graph"/>
<field name="search_view_id" ref="view_crm_project_bug_user_filter"/>
<field name="view_id" ref="view_crm_project_bug_graph"/>
<field name="search_view_id" ref="view_crm_project_bug_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_report_project_bug_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_project_bug_tree"/>
<field name="act_window_id" ref="action_report_crm_project_bug"/>
</record>
<record model="ir.actions.act_window.view" id="action_report_project_bug_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_project_bug_graph"/>
<field name="act_window_id" ref="action_report_crm_project_bug"/>
</record>
<menuitem icon="terp-project" id="base.menu_main_pm" name="Project Management" sequence="1"/>
<menuitem id="base.menu_project_report" name="Reporting" parent="base.menu_main_pm" sequence="50"/>
<menuitem name="Project Bug" id="menu_crm_project_bug_tree" parent="base.menu_project_report" sequence="1"/>
<menuitem action="action_report_crm_project_bug_user_tree" id="menu_crm_project_bug_user_tree" parent="menu_crm_project_bug_tree"/>
<!-- # Project Bug by section and category of case -->
<record id="view_crm_project_bug_categ_tree" model="ir.ui.view">
<field name="name">report.crm.project.bug.categ.tree</field>
<field name="model">report.crm.project.bug.categ</field>
<field name="inherit_id" ref="report_crm.view_crm_case_categ_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
<field name="delay_close"/>
<field name="amount_revenue"/>
<field name="amount_costs"/>
<field name="amount_revenue_prob"/>
<field name="probability"/>
</field>
</field>
</record>
<record id="view_crm_project_bug_categ_form" model="ir.ui.view">
<field name="name">report.crm.project.bug.categ.form</field>
<field name="model">report.crm.project.bug.categ</field>
<field name="inherit_id" ref="report_crm.view_crm_case_categ_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
<field name="delay_close"/>
<field name="amount_revenue"/>
<field name="amount_costs"/>
<field name="amount_revenue_prob"/>
<field name="probability"/>
</field>
</field>
</record>
<record id="view_crm_project_bug_categ_graph" model="ir.ui.view">
<field name="name">report.crm.project.bug.categ.graph</field>
<field name="model">report.crm.project.bug.categ</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="project_bugs by Section and Categories" type="bar">
<field name="state"/>
<field name="nbr" operator="+"/>
<field group="True" name="categ_id"/>
</graph>
</field>
</record>
<record id="view_crm_project_bug_categ_filter" model="ir.ui.view">
<field name="name">report.crm.project.bug.categ.select</field>
<field name="model">report.crm.project.bug.categ</field>
<field name="inherit_id" ref="report_crm.view_crm_case_categ_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="state" position="before">
</field>
</field>
</record>
<record id="action_report_crm_project_bug_categ_tree" model="ir.actions.act_window">
<field name="name">Project Bugs by Categories and Section</field>
<field name="res_model">report.crm.project.bug.categ</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_crm_project_bug_categ_graph"/>
<field name="search_view_id" ref="view_crm_project_bug_categ_filter"/>
</record>
<menuitem action="action_report_crm_project_bug_categ_tree" id="menu_crm_project_bug_categ_tree" parent="menu_crm_project_bug_tree"/>
<!-- Project Bug by Section -->
<record id="view_report_crm_project_bug_section_tree" model="ir.ui.view">
<field name="name">report.crm.project.bug.section.tree</field>
<field name="model">report.crm.project.bug.section</field>
<field name="inherit_id" ref="report_crm.view_report_crm_case_section_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="nbr_cases" position="after">
<field name="avg_answers"/>
<field name="perc_done" select="2"/>
<field name="perc_cancel" select="2"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record id="view_report_crm_project_bug_section_graph" model="ir.ui.view">
<field name="name">report.crm.project.bug.section.graph</field>
<field name="model">report.crm.project.bug.section</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="project_bugs by Section" type="bar">
<field name="name"/>
<field name="nbr_cases" operator="+"/>
</graph>
</field>
</record>
<record id="view_report_crm_project_bug_section_filter" model="ir.ui.view">
<field name="name">report.crm.project.bug.section.select</field>
<field name="model">report.crm.project.bug.section</field>
<field name="inherit_id" ref="report_crm.view_report_crm_case_section_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="nbr_cases" position="before">
</field>
</field>
</record>
<record id="action_report_crm_project_bug_section_tree" model="ir.actions.act_window">
<field name="name">Project Bugs by Section</field>
<field name="res_model">report.crm.project.bug.section</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_report_crm_project_bug_section_graph"/>
<field name="search_view_id" ref="view_report_crm_project_bug_section_filter"/>
</record>
<menuitem action="action_report_crm_project_bug_section_tree" id="menu_crm_project_bug_section_tree" parent="menu_crm_project_bug_tree"/>
<menuitem id="base.menu_project_report" name="Reporting" parent="base.menu_main_pm" sequence="50"/>
<menuitem action="action_report_crm_project_bug" id="menu_crm_project_bug_user_tree" parent="base.menu_project_report"/>
</data>
</openerp>

View File

@ -1,5 +1,3 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_crm_project_bug","crm.project.bug","model_crm_project_bug","crm.group_crm_manager",1,1,1,1
"access_report_crm_project_bug_user","report.crm.project.bug.user","model_report_crm_project_bug_user","crm.group_crm_manager",1,0,0,0
"access_report_crm_project_bug_categ","report.crm.project.bug.categ","model_report_crm_project_bug_categ","crm.group_crm_manager",1,0,0,0
"access_repor_crm_project_bug_section","report.crm.project.bug.section","model_report_crm_project_bug_section","crm.group_crm_manager",1,0,0,0
"access_report_crm_project_bug","report.crm.project.bug","model_report_crm_project_bug","crm.group_crm_manager",1,0,0,0

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_crm_project_bug crm.project.bug model_crm_project_bug crm.group_crm_manager 1 1 1 1
3 access_report_crm_project_bug_user access_report_crm_project_bug report.crm.project.bug.user report.crm.project.bug model_report_crm_project_bug_user model_report_crm_project_bug crm.group_crm_manager 1 0 0 0
access_report_crm_project_bug_categ report.crm.project.bug.categ model_report_crm_project_bug_categ crm.group_crm_manager 1 0 0 0
access_repor_crm_project_bug_section report.crm.project.bug.section model_report_crm_project_bug_section crm.group_crm_manager 1 0 0 0

View File

@ -11,10 +11,11 @@
<field name="name" />
<field name="month"/>
<field name="nbr" string="#Claim"/>
<field name="delay_close"/>
<field name="amount_revenue"/>
<field name="amount_revenue_prob"/>
<field name="probability"/>
<field name="amount_revenue_prob"/>
<field name="delay_close"/>
<field name="section_id" invisible="1"/>
<field name="stage_id" invisible="1"/>
<field name="categ_id" invisible="1"/>
</tree>
@ -86,7 +87,7 @@
</record>
<menuitem name="Claim" id="menu_crm_claim_tree" action="action_report_crm_claim" parent="crm.next_id_52"/>
<menuitem name="Claims" id="menu_crm_claim_tree" action="action_report_crm_claim" parent="base.next_id_64"/>
</data>

View File

@ -89,7 +89,7 @@
<field name="view_id" ref="view_crm_fundraising_graph"/>
<field name="act_window_id" ref="action_report_crm_fundraising"/>
</record>
<menuitem name="Fundraising" action="action_report_crm_fundraising" id="menu_crm_fundraising_tree" parent="crm.next_id_52"/>
<menuitem name="Fundraising" action="action_report_crm_fundraising" id="menu_crm_fundraising_tree" parent="base.next_id_64"/>
</data>
</openerp>

View File

@ -55,9 +55,7 @@
<field name="inherit_id" ref="view_crm_case_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search">
<field name="state" position="before"/>
</search>
</field>
</record>
@ -69,6 +67,7 @@
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_crm_lead_graph"/>
<field name="search_view_id" ref="view_crm_lead_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_report_crm_lead_tree">
@ -84,6 +83,7 @@
<field name="view_id" ref="view_crm_lead_graph"/>
<field name="act_window_id" ref="action_report_crm_lead"/>
</record>
<menuitem name="Leads" id="menu_crm_leads_tree" parent="crm.next_id_52" action="action_report_crm_lead"/>
<menuitem name="Leads" id="menu_crm_leads_tree" parent="base.next_id_64" action="action_report_crm_lead"/>
</data>
</openerp>

View File

@ -14,11 +14,12 @@
<field name="name" />
<field name="month"/>
<field name="nbr" string="#Opportunities"/>
<field name="delay_close"/>
<field name="amount_revenue"/>
<field name="amount_revenue_prob"/>
<field name="probability"/>
<field name="state"/>
<field name="amount_revenue_prob"/>
<field name="delay_close"/>
<field name="state" invisible="1"/>
<field name="section_id" invisible="1"/>
<field name="user_id" invisible="1"/>
<field name="stage_id" invisible="1"/>
<field name="categ_id" invisible="1"/>
@ -66,7 +67,7 @@
</record>
<record id="action_report_crm_opportunity" model="ir.actions.act_window">
<field name="name">Opportunity</field>
<field name="name">Opportunities</field>
<field name="res_model">report.crm.opportunity</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
@ -85,6 +86,7 @@
<field name="view_id" ref="view_crm_opportunity_graph"/>
<field name="act_window_id" ref="action_report_crm_opportunity"/>
</record>
<menuitem name="Opportinities" action="action_report_crm_opportunity" id="menu_crm_opportunity_tree" parent="crm.next_id_52"/>
<menuitem name="Opportunities" action="action_report_crm_opportunity" id="menu_crm_opportunity_tree" parent="base.next_id_64"/>
</data>
</openerp>

View File

@ -82,7 +82,7 @@
</record>
<record id="action_report_crm_phonecall" model="ir.actions.act_window">
<field name="name">Phone calls</field>
<field name="name">Phone Calls</field>
<field name="res_model">report.crm.phonecall</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
@ -104,7 +104,7 @@
<field name="act_window_id" ref="action_report_crm_phonecall"/>
</record>
<menuitem name="Phone Calls" action="action_report_crm_phonecall" id="menu_crm_phonecalls_tree" parent="crm.next_id_52"/>
<menuitem name="Phone Calls" action="action_report_crm_phonecall" id="menu_crm_phonecalls_tree" parent="base.next_id_64"/>
</data>
</openerp>

View File

@ -57,6 +57,7 @@
<separator orientation="vertical"/>
<filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]"/>
<filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]"/>
<filter string="Current" icon="terp-hr" domain="[('state','=','draft')]"/>
<filter string="Won" icon="terp-hr" domain="[('state','=','done')]"/>
<filter string="Lost" icon="terp-hr" domain="[('state','=','cancel')]"/>
<separator orientation="vertical"/>
@ -81,8 +82,7 @@
</search>
</field>
</record>
<menuitem id="base.next_id_64" name="Reporting" parent="base.menu_base_partner" sequence="8"/>
<menuitem id="crm.next_id_52" name="Cases" parent="base.next_id_64" sequence="0"/>
<menuitem id="base.next_id_64" name="Reporting" parent="base.menu_base_partner" sequence="8"/>
<record id="action_report_crm_case_tree" model="ir.actions.act_window">