[IMP,FIX]: crm_fundraising: Improvement in fundraising for inheriting python class crm case from crm + Improvement in reports, Added missing fields + Fixed demo data

bzr revid: rpa@tinyerp.com-20100506070927-3yaaon8bi5ncdc2s
This commit is contained in:
rpa (Open ERP) 2010-05-06 12:39:27 +05:30
parent a77041f56b
commit 15c36ff8a7
6 changed files with 225 additions and 42 deletions

View File

@ -21,28 +21,29 @@
{
'name': 'CRM Fundraising',
'version': '1.0',
'category': 'Generic Modules/CRM & SRM',
'description': """Fundraising""",
'author': 'Tiny',
'website': 'http://www.openerp.com',
'depends': ['crm'],
'name': 'CRM Fundraising',
'version': '1.0',
'category': 'Generic Modules/CRM & SRM',
'description': """Fundraising""",
'author': 'Tiny',
'website': 'http://www.openerp.com',
'depends': ['crm'],
'init_xml': [
'crm_fundraising_data.xml',
],
'crm_fundraising_data.xml',
],
'update_xml': [
'crm_fundraising_view.xml',
'crm_fundraising_menu.xml',
'security/ir.model.access.csv',
'report/crm_fundraising_report_view.xml',
],
'crm_fundraising_view.xml',
'crm_fundraising_menu.xml',
'security/ir.model.access.csv',
'report/crm_fundraising_report_view.xml',
],
'demo_xml': [
'crm_fundraising_demo.xml',
],
'installable': True,
'active': False,
'crm_fundraising_demo.xml',
],
'test': ['test/test_crm_fund.yml'],
'installable': True,
'active': False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -22,7 +22,7 @@
from osv import fields, osv, orm
from crm import crm
class crm_fundraising(osv.osv):
class crm_fundraising(osv.osv, crm.crm_case):
""" Fund Raising Cases """
_name = "crm.fundraising"
@ -31,6 +31,23 @@ class crm_fundraising(osv.osv):
_inherit ='mailgate.thread'
_columns = {
'name': fields.char('Name', size=128, required=True),
'description': fields.text('Description'),
'create_date': fields.datetime('Creation Date' , readonly=True),
'write_date': fields.datetime('Update Date' , readonly=True),
'date_deadline': fields.date('Deadline'),
'user_id': fields.many2one('res.users', 'Responsible'),
'section_id': fields.many2one('crm.case.section', 'Sales Team', \
select=True, help='Sales team to which Case belongs to.\
Define Responsible user and Email account for mail gateway.'),
'company_id': fields.many2one('res.company', 'Company'),
'partner_id': fields.many2one('res.partner', 'Partner'),
'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \
domain="[('partner_id','=',partner_id)]"),
'email_cc': fields.text('Watchers Emails', size=252 , help="These people\
will receive a copy of the future" \
" communication between partner and users by email"),
'email_from': fields.char('Email', size=128, help="These people will receive email."),
'date_closed': fields.datetime('Closed', readonly=True),
'date': fields.datetime('Date'),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
@ -63,13 +80,26 @@ class crm_fundraising(osv.osv):
"the partner mentality in relation to our services.The scale has" \
"to be created with a factor for each level from 0 \
(Very dissatisfied) to 10 (Extremely satisfied)."),
'state': fields.selection(crm.AVAILABLE_STATES, 'State', size=16, readonly=True,
help='The state is set to \'Draft\', when a case is created.\
\nIf the case is in progress the state is set to \'Open\'.\
\nWhen the case is over, the state is set to \'Done\'.\
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
}
_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,
}
'active': lambda *a: 1,
'user_id': crm.crm_case._get_default_user,
'partner_id': crm.crm_case._get_default_partner,
'partner_address_id': crm.crm_case._get_default_partner_address,
'email_from': crm.crm_case. _get_default_email,
'state': lambda *a: 'draft',
'section_id': crm.crm_case. _get_section,
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.case', context=c),
'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

@ -182,7 +182,7 @@
<group colspan="4">
<field colspan="4" name="email_cc" string="CC"/>
</group>
<field name="history_line" colspan="4" nolabel="1" mode="form,tree">
<field name="message_ids" colspan="4" nolabel="1" mode="form,tree">
<form string="Communication history">
<group col="7" colspan="4">
<field name="date"/>

View File

@ -22,16 +22,75 @@
from osv import fields,osv
import tools
AVAILABLE_STATES = [
('draft','Draft'),
('open','Open'),
('cancel', 'Cancelled'),
('done', 'Closed'),
('pending','Pending')
]
class crm_fundraising_report(osv.osv):
"""CRM Fundraising Report"""
_name = "crm.fundraising.report"
_auto = False
_inherit = "crm.case.report"
_description = "CRM Fundraising Report"
def _get_data(self, cr, uid, ids, field_name, arg, context={}):
""" @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of case and section Datas IDs
@param context: A standard dictionary for contextual values """
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_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)) * 100
res[case.id] = perc_state
else:
model_name = self._name.split('report.')
if len(model_name) < 2:
res[case.id] = 0.0
else:
model_name = model_name[1]
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
res[case.id] = avg_ans
return res
_columns = {
'name': fields.char('Year', size=64, required=False, readonly=True),
'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, '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"),
'month':fields.selection([('01', 'January'), ('02', 'February'), \
('03', 'March'), ('04', 'April'),\
('05', 'May'), ('06', 'June'), \
('07', 'July'), ('08', 'August'),\
('09', 'September'), ('10', 'October'),\
('11', 'November'), ('12', 'December')], 'Month', readonly=True),
'company_id': fields.many2one('res.company', 'Company', readonly=True),
'create_date': fields.datetime('Create Date', readonly=True),
'day': fields.char('Day', size=128, readonly=True),
'categ_id': fields.many2one('crm.case.categ', 'Category', \
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.fundraising')]"),

View File

@ -33,15 +33,20 @@
<record id="view_report_crm_fundraising_form" model="ir.ui.view">
<field name="name">crm.fundraising.report.form</field>
<field name="model">crm.fundraising.report</field>
<field name="inherit_id" ref="crm.view_crm_case_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
<form string="Cases">
<field name="name" select="1"/>
<field name="month" select="1"/>
<field name="user_id" select="1"/>
<field name="section_id" select="1"/>
<field name="nbr" select="1"/>
<field name="delay_close"/>
<field name="amount_revenue"/>
<field name="amount_revenue_prob"/>
<field name="probability"/>
</field>
<field name="state" select="1"/>
</form>
</field>
</record>
@ -62,20 +67,108 @@
<!-- Fundraising by user and section Search View-->
<record id="view_report_crm_fundraising_filter" model="ir.ui.view">
<field name="name">crm.fundraising.report.select</field>
<record id="view_report_crm_fundraising_filter" model="ir.ui.view">
<field name="name">crm.fundraising.report.selectt</field>
<field name="model">crm.fundraising.report</field>
<field name="inherit_id" ref="crm.view_crm_case_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<data>
<xpath expr='//search[@string="Search"]/group[@string="Extended options..."]/filter[@string="Cancel"]' position='after'>
<group>
<separator orientation="vertical"/>
<field name="categ_id" widget="selection" domain="[('object_id.model', '=', 'crm.fundraising')]"/>
</group>
</xpath>
</data>
<search string="Search">
<group col="16" colspan="8">
<!-- <filter string="This Year" name="This Year" icon="terp-hr"
domain="[('name','=',time.localtime()[0])]"/>-->
<filter string="This Year" icon="terp-hr"
domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')), ('create_date','&gt;',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]"/>
<!-- <filter string="This Month" name="This Year" icon="terp-hr"
domain="[('month','=',time.strftime('%%m'))]" />-->
<filter string="This Month" icon="terp-hr" name="This Month"
domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')), ('create_date','&gt;',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]"/>
<filter icon="gtk-media-rewind" string="7 Days" separator="1"
domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')), ('create_date','&gt;',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"/>
<separator orientation="vertical" />
<filter icon="terp-hr"
string="Draft"
domain="[('state','=','draft')]"/>
<filter icon="terp-hr"
string="Open"
domain="[('state','=','open')]"/>
<filter icon="terp-hr"
string="Pending"
domain="[('state','=','pending')]"/>
<separator orientation="vertical" />
<field name="section_id"
default="context.get('section_id', False)"
widget="selection"
context="{'invisible_section': False}">
<filter icon="terp-crm"
context="{'invisible_section': False}"
domain="[('section_id.user_id','=',uid)]"
help="My section" />
</field>
<field name="company_id" widget="selection">
<filter icon="terp-crm"
context="{'invisible_section': False}"
domain="[('section_id.user_id.company_id','=',uid)]"
help="My company"/>
</field>
<field name="user_id" select="1" widget="selection">
<filter icon="terp-crm" string="My Case" help="My Case" domain="[('user_id','=',uid)]" />
</field>
</group>
<newline/>
<group expand="0" string="Extended options..." colspan="10" col="12">
<filter icon="terp-sale"
string="Done"
domain="[('state','=','done')]"/>
<filter icon="terp-sale"
string="Cancel"
domain="[('state','=','cancel')]"/>
<group>
<separator orientation="vertical"/>
<field name="categ_id" widget="selection" domain="[('object_id.model', '=', 'crm.fundraising')]"/>
</group>
</group>
<newline/>
<group expand="1" string="Group By..." colspan="4" col="8">
<filter string="User" name="User" icon="terp-sale"
domain="[]" context="{'group_by':'user_id'}" />
<filter string="Company" icon="terp-sale"
domain="[]"
context="{'group_by':'company_id'}" />
<filter string="Section" icon="terp-sale"
domain="[]"
context="{'group_by':'section_id'}" />
<separator orientation="vertical" />
<filter string="State" icon="terp-sale"
domain="[]" context="{'group_by':'state'}" />
<filter string="Category" icon="terp-sale"
domain="[]" context="{'group_by':'categ_id'}" />
<separator orientation="vertical" />
<filter string="Day" icon="terp-sale"
domain="[]" context="{'group_by':'day'}"/>
<filter string="Month" icon="terp-sale"
domain="[]" context="{'group_by':'month'}" />
<filter string="Year" icon="terp-sale"
domain="[]" context="{'group_by':'name'}" />
</group>
</search>
</field>
</record>

View File

@ -7,14 +7,14 @@
I make payment by Cheque so I make sure that the mode on fund is selected as cheque
-
!record {model: crm.fundraising, id: crm_fundraising_donationforbookstopoorschoolchildren0}:
categ_id: crm.categ_fund2
categ_id: crm_fundraising.categ_fund2
email_from: info@balmerinc.be
name: Donation for books to poor school children
partner_address_id: base.res_partner_address_1
partner_id: base.res_partner_9
planned_cost: 500000.0
section_id: crm.section_sales_department
type_id: crm.type_fund2
type_id: crm_fundraising.type_fund2
- |
I check that the Funds is in 'draft' state.
-