bzr revid: hmo@tinyerp.com-20100304132844-patzedhk0a71d5av
This commit is contained in:
Harry (Open ERP) 2010-03-04 18:58:44 +05:30
commit c8c3ba54dc
14 changed files with 66 additions and 34 deletions

View File

@ -53,6 +53,10 @@ class crm_fundraising(osv.osv):
_defaults = {
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
'probability':lambda *a:0.0,
'planned_cost':lambda *a:0.0,
'planned_revenue':lambda *a:0.0,
}
crm_fundraising()

View File

@ -73,7 +73,7 @@
<field name="user_id" />
<label string="Resolution: " align="1.0"/>
<group colspan="1" col="3">
<field name="stage_id" select="1" nolabel="1"/>
<field name="stage_id" select="1" nolabel="1" on_change="onchange_stage_id(stage_id)" domain="[('object_id.model', '=', 'crm.project.bug')]"/>
<button icon="gtk-go-back" string="" name="stage_previous" type="object"/>
<button icon="gtk-go-forward" string="" name="stage_next" type="object"/>
</group>

View File

@ -88,8 +88,20 @@ class crm_project_bug(osv.osv):
def convert_to_bug(self, cr, uid, ids, context=None):
return self._convert(cr, uid, ids, 'bug_categ', context=context)
def onchange_stage_id(self, cr, uid, ids, stage_id, context={}):
if not stage_id:
return {'value':{}}
stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context)
if not stage.on_change:
return {'value':{}}
return {'value':{'probability':stage.probability}}
_defaults = {
'project_id':_get_project,
'project_id':_get_project,
'probability':lambda *a:0.0,
'planned_cost':lambda *a:0.0,
'planned_revenue':lambda *a:0.0,
}
crm_project_bug()

View File

@ -16,8 +16,10 @@
<field name="nbr" string="#Project Bug"/>
<field name="amount_revenue"/>
<field name="probability"/>
<field name="amount_revenue_prob"/>
<field name="delay_close"/>
<field name="state"/>
<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"/>
@ -59,8 +61,9 @@
<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">
</field>
<xpath expr='//search[@string="Search"]/group[@string="Group By..."]/filter[@string="State"]' position='after'>
<filter string="Stage" icon="terp-sale" domain="[]" context="{'group_by':'stage_id'}"/>
</xpath>
</field>
</record>

View File

@ -45,7 +45,7 @@ class report_crm_case(osv.osv):
state = field_name[5:]
cr.execute("select count(*) from crm_opportunity 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
perc_state = (state_cases / float(case.nbr) ) * 100
res[case.id] = perc_state
else:
@ -58,7 +58,7 @@ class report_crm_case(osv.osv):
cr.execute("select count(*) from crm_case_log l, ir_model m where l.model_id=m.id and m.model = '%s'" , model_name)
logs = cr.fetchone()[0]
avg_ans = logs / case.nbr_cases
avg_ans = logs / case.nbr
res[case.id] = avg_ans
return res
@ -68,7 +68,7 @@ class report_crm_case(osv.osv):
'user_id':fields.many2one('res.users', 'User', readonly=True),
'section_id':fields.many2one('crm.case.section', 'Section', readonly=True),
'nbr': fields.integer('# of Cases', readonly=True),
'state': fields.selection(AVAILABLE_STATES, 'Status', size=16, readonly=True),
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
'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"),

View File

@ -55,8 +55,9 @@
<field name="inherit_id" ref="view_crm_case_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="user_id" position="before">
</field>
<xpath expr='//search[@string="Search"]/group[@string="Group By..."]/filter[@string="State"]' position='after'>
<filter string="Stage" icon="terp-sale" domain="[]" context="{'group_by':'stage_id'}"/>
</xpath>
</field>
</record>

View File

@ -7,10 +7,8 @@ class report_crm_fundraising(osv.osv):
_inherit = "report.crm.case"
_columns = {
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]"),
'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]", readonly=True),
'probability': fields.float('Avg. Probability', readonly=True),
'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),
'delay_close': fields.char('Delay to close', size=20, readonly=True),
}
@ -26,7 +24,6 @@ class report_crm_fundraising(osv.osv):
c.user_id,
c.section_id,
c.categ_id,
c.stage_id,
count(*) as nbr,
0 as avg_answers,
0.0 as perc_done,
@ -37,7 +34,7 @@ class report_crm_fundraising(osv.osv):
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_fundraising c
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
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
)""")
report_crm_fundraising()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -21,7 +21,6 @@
<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"/>
</tree>
</field>
@ -36,7 +35,6 @@
<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>

View File

@ -55,7 +55,9 @@
<field name="inherit_id" ref="view_crm_case_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="user_id" position="before"/>
<xpath expr='//search[@string="Search"]/group[@string="Group By..."]/filter[@string="State"]' position='after'>
<filter string="Stage" icon="terp-sale" domain="[]" context="{'group_by':'stage_id'}"/>
</xpath>
</field>
</record>

View File

@ -61,8 +61,9 @@
<field name="inherit_id" ref="view_crm_case_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="user_id" position="before">
</field>
<xpath expr='//search[@string="Search"]/group[@string="Group By..."]/filter[@string="State"]' position='after'>
<filter string="Stage" icon="terp-sale" domain="[]" context="{'group_by':'stage_id'}"/>
</xpath>
</field>
</record>

View File

@ -49,14 +49,13 @@
</graph>
</field>
</record>
<record id="view_crm_phonecall_filter" model="ir.ui.view">
<field name="name">report.crm.phonecall.select</field>
<field name="model">report.crm.phonecall</field>
<field name="inherit_id" ref="view_crm_case_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="user_id" position="before">
<field name="user_id" position="before">
</field>
</field>
</record>

View File

@ -79,7 +79,6 @@
<filter string="User" icon="terp-sale" domain="[]" context="{'group_by':'user_id'}"/>
<filter string="Section" icon="terp-sale" domain="[]" context="{'group_by':'section_id'}"/>
<filter string="State" icon="terp-sale" domain="[]" context="{'group_by':'state'}"/>
<filter string="Stage" icon="terp-sale" domain="[]" context="{'group_by':'stage_id'}"/>
<filter string="Month" icon="terp-sale" domain="[]" context="{'group_by':'month'}"/>
<filter string="Year" icon="terp-sale" domain="[]" context="{'group_by':'name'}"/>
<filter string="Category" icon="terp-sale" domain="[]" context="{'group_by':'categ_id'}"/>

View File

@ -9,7 +9,8 @@
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="arch" type="xml">
<xpath expr="/form[@string='Opportunities']/group/button[@string='Schedule Call']" position="after">
<button string="Quotation" icon="terp-sale" name="%(sale_crm_wizard)d" type="action"/>
<button string="Convert to Quote" icon="terp-sale" name="%(sale_crm_wizard)d" type="action"/>
<label colspan="6" string=""/>
</xpath>
</field>
</record>
@ -20,7 +21,7 @@
<field name="type">form</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="/form/notebook/page[@string='Other data']/field[@name='company_id']" position="after">
<xpath expr="/form/notebook/page/field['company_id']" position="after">
<field name="section_id" widget='selection'/>
</xpath>
</field>

View File

@ -130,16 +130,31 @@ class make_sale(wizard.interface):
if data['form']['close']:
case_obj.case_close(cr, uid, data['ids'])
value = {
'domain': str([('id', 'in', new_ids)]),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'sale.order',
'view_id': False,
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
if not new_ids:
return {}
if len(new_ids)<=1:
value = {
'domain': str([('id', 'in', new_ids)]),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'sale.order',
'view_id': False,
'type': 'ir.actions.act_window',
'res_id': new_ids and new_ids[0]
}
else:
value = {
'domain': str([('id', 'in', new_ids)]),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'sale.order',
'view_id': False,
'type': 'ir.actions.act_window',
'res_id':new_ids
}
return value
states = {