[Merge]: Merge with trunk addons

bzr revid: rpa@openerp.co.in-20100304051137-9s0e2d6p8t91naxp
This commit is contained in:
rpa (Open ERP)
2010-03-04 10:41:37 +05:30
66 changed files with 1373 additions and 4062 deletions
@@ -126,6 +126,10 @@ class base_action_rule(osv.osv):
obj.state = action.act_state
write['state'] = action.act_state
if hasattr(obj, 'categ_id') and action.act_categ_id:
obj.categ_id = action.act_categ_id
write['categ_id'] = action.act_categ_id.id
if hasattr(obj, 'priority') and action.act_priority:
obj.priority = action.act_priority
write['priority'] = action.act_priority
@@ -2,9 +2,9 @@
<openerp>
<data>
<menuitem id="menu_base_action_rule" name="Action Rule" parent="base.menu_base_config" sequence="0"/>
<!--
Action Rule
<!--
Action Rule
-->
<record id="view_base_action_rule_form" model="ir.ui.view">
<field name="name">base.action.rule.form</field>
@@ -12,27 +12,28 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Action Rule">
<field name="name"/>
<field name="name" select="1"/>
<field name="active"/>
<field name="max_level" />
<separator colspan="4" string="Rule lines"/>
<field name="rule_lines" colspan="4" nolabel="1"/>
<field name="rule_lines" colspan="4" nolabel="1"/>
</form>
</field>
</record>
<record id="view_base_action_rule_tree" model="ir.ui.view">
<field name="name">base.action.rule.tree</field>
<field name="model">base.action.rule</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Action Rule">
<field name="name"/>
<field name="max_level"/>
<field name="name" colspan="4"/>
<field name="max_level"/>
<field name="rule_lines" colspan="4" nolabel="1"/>
</tree>
</field>
</record>
<record id="base_action_rule_act" model="ir.actions.act_window">
<field name="name">Action Rules</field>
<field name="res_model">base.action.rule</field>
@@ -40,10 +41,11 @@
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_base_action_rule_tree"/>
</record>
<menuitem id="menu_base_action_rule_form" parent="menu_base_action_rule" action="base_action_rule_act"/>
<!--
Action Rule Lines
<!--
Action Rule Lines
-->
<record id="view_base_action_rule_line_form" model="ir.ui.view">
<field name="name">base.action.rule.line.form</field>
@@ -54,34 +56,44 @@
<field name="name" select="1"/>
<field name="active" select="2"/>
<notebook colspan="4">
<page string="Conditions">
<separator colspan="4" string="Conditions on Model Fields"/>
<field name="regex_name" string="Regex on Model Name" colspan="2"/>
<field name="trg_user_id" select="2"/>
<separator colspan="4" string="Conditions on Model Partner"/>
<field name="trg_partner_id"/>
<field name="trg_partner_categ_id"/>
<separator colspan="4" string="Conditions on States"/>
<field name="trg_state_from" select="2"/>
<field name="trg_state_to" select="2"/>
<separator colspan="4" string="Conditions on Priority Range"/>
<field name="trg_priority_from"/>
<field name="trg_priority_to"/>
<separator colspan="4" string="Conditions on Timing"/>
<field name="trg_date_type"/>
<label align="1.0" string="Delay After Trigger Date:"/>
<group col="2" colspan="1">
<field name="trg_date_range" nolabel="1"/>
<field name="trg_date_range_type" nolabel="1"/>
<page string="Conditions">
<group col="2" colspan="2" name="model">
<separator colspan="4" string="Conditions on Model Fields"/>
<field name="regex_name" string="Regex on Model Name" colspan="2"/>
<field name="trg_user_id" select="2"/>
</group>
<group col="2" colspan="2" name="partner">
<separator colspan="4" string="Conditions on Model Partner"/>
<field name="trg_partner_id"/>
<field name="trg_partner_categ_id"/>
</group>
<group col="2" colspan="2">
<separator colspan="4" string="Conditions on States"/>
<field name="trg_state_from" select="2"/>
<field name="trg_state_to" select="2"/>
</group>
<group col="2" colspan="2">
<separator colspan="4" string="Conditions on Priority Range"/>
<field name="trg_priority_from"/>
<field name="trg_priority_to"/>
</group>
<group col="2" colspan="2">
<separator colspan="4" string="Conditions on Timing"/>
<field name="trg_date_type"/>
<label align="1.0" string="Delay After Trigger Date:"/>
<group col="2" colspan="1">
<field name="trg_date_range" nolabel="1"/>
<field name="trg_date_range_type" nolabel="1"/>
</group>
</group>
<separator colspan="4" string="Note"/>
<label align="0.0" string="The rule use a AND operator. The model must match all non empty fields so that the rule execute the action described in the 'Actions' tab." colspan="4"/>
<label align="0.0" string="The rule use a AND operator. The model must match all non empty fields so that the rule execute the action described in the 'Actions' tab." colspan="4"/>
</page>
<page string="Actions">
<separator colspan="4" string="Fields to Change"/>
<field name="act_user_id"/>
<field name="act_user_id"/>
<field name="act_state"/>
<field name="act_priority"/>
<field name="act_priority"/>
<separator colspan="4" string="E-Mail Reminders (includes the content of the object)"/>
<field name="act_remind_partner"/>
<field name="act_remind_attach"/>
@@ -95,7 +107,7 @@
</page>
<page string="E-Mail Actions">
<separator colspan="4" string="Template of Email to Send"/>
<field name="act_mail_to_user"/>
<field name="act_mail_to_user"/>
<field name="act_mail_to_watchers"/>
<field colspan="4" name="act_mail_to_email"/>
<field colspan="4" name="act_mail_body" attrs="{'required':[('act_remind_user','=',True)]}"/>
@@ -103,7 +115,7 @@
<label align="0.0" string="%%(object_id)s = Object ID" colspan="2"/>
<label align="0.0" string="%%(object_subject)s = Object subject" colspan="2"/>
<label align="0.0" string="%%(object_description)s = Object description" colspan="2"/>
<label align="0.0" string="%%(object_date)s = Creation date" colspan="2"/>
<label align="0.0" string="%%(object_date)s = Creation date" colspan="2"/>
<label align="0.0" string="%%(partner)s = Partner name" colspan="2"/>
<label align="0.0" string="%%(partner_email)s = Partner email" colspan="2"/>
<label align="0.0" string="%%(object_user)s = Responsible name" colspan="2"/>
@@ -125,6 +137,15 @@
<field name="active"/>
</tree>
</field>
</record>
</record>
<act_window
domain="[('rule_id', '=', active_id)]"
id="act_rule_lines_open"
name="Open Rule Lines"
context="{'rule_id': active_id}"
res_model="base.action.rule.line"
src_model="base.action.rule"/>
</data>
</openerp>
+4 -2
View File
@@ -38,7 +38,7 @@ months = {
def get_recurrent_dates(rrulestring, exdate, startdate=None):
def todate(date):
val = parser.parse(''.join((re.compile('\d')).findall(date)) + 'Z')
val = parser.parse(''.join((re.compile('\d')).findall(date)))
return val
if not startdate:
startdate = datetime.now()
@@ -778,13 +778,15 @@ rule or repeating pattern for anexception to a recurrence set"),
def modify_this(self, cr, uid, ids, defaults, context=None, *args):
datas = self.read(cr, uid, ids[0], context=context)
date = datas.get('date')
defaults.update({
'recurrent_uid': base_calendar_id2real_id(datas['id']),
'recurrent_id': defaults.get('date'),
'rrule_type': 'none',
'rrule': ''
})
exdate = datas['exdate'] and datas['exdate'].split(',') or []
exdate.append(defaults.get('date'))
self.write(cr, uid, ids, {'exdate': ','.join(exdate)}, context=context)
new_id = self.copy(cr, uid, ids[0], default=defaults, context=context)
return new_id
+28 -13
View File
@@ -192,7 +192,12 @@ class CalDAV(object):
vals = alarm.import_cal(cr, uid, cal_data, context=ctx)
self.ical_set(cal_data.name.lower(), vals, 'value')
continue
if cal_data.name.lower() == 'exdate':
exval = map(lambda x: str(x), cal_data.value)
self.ical_set(cal_data.name.lower(), ','.join(exval), 'value')
continue
if cal_data.name.lower() in self.__attribute__:
if cal_data.params.get('X-VOBJ-ORIGINAL-TZID'):
self.ical_set('vtimezone', cal_data.params.get('X-VOBJ-ORIGINAL-TZID'), 'value')
self.ical_set(cal_data.name.lower(), cal_data.value, 'value')
@@ -248,15 +253,15 @@ class CalDAV(object):
data[map_field], ical, context=context)
elif data[map_field]:
if map_type in ("char", "text"):
vevent.add(field).value = tools.ustr(data[map_field])
elif map_type in ('datetime', 'date') and data[map_field]:
if field in ('exdate'):
vevent.add(field).value = [parser.parse(data[map_field])]
vevent.add(field).value = map(parser.parse, (data[map_field]).split(','))
else:
dtfield = vevent.add(field)
dtfield.value = parser.parse(data[map_field])
if tzval:
dtfield.params['TZID'] = [tzval.title()]
vevent.add(field).value = tools.ustr(data[map_field])
elif map_type in ('datetime', 'date') and data[map_field]:
dtfield = vevent.add(field)
dtfield.value = parser.parse(data[map_field])
if tzval:
dtfield.params['TZID'] = [tzval.title()]
elif map_type == "timedelta":
vevent.add(field).value = timedelta(hours=data[map_field])
elif map_type == "many2one":
@@ -275,11 +280,13 @@ class CalDAV(object):
def check_import(self, cr, uid, vals, context={}):
ids = []
model_obj = self.pool.get(context.get('model'))
recur_pool = {}
try:
for val in vals:
exists, r_id = uid2openobjectid(cr, val['id'], context.get('model'), \
val.get('recurrent_id'))
if val.has_key('create_date'): val.pop('create_date')
u_id = val.get('id', None)
val.pop('id')
if exists and r_id:
val.update({'recurrent_uid': exists})
@@ -289,8 +296,14 @@ class CalDAV(object):
model_obj.write(cr, uid, [exists], val)
ids.append(exists)
else:
event_id = model_obj.create(cr, uid, val)
ids.append(event_id)
if u_id in recur_pool and val.get('recurrent_id'):
val.update({'recurrent_uid': recur_pool[u_id]})
revent_id = model_obj.create(cr, uid, val)
ids.append(revent_id)
else:
event_id = model_obj.create(cr, uid, val)
recur_pool[u_id] = event_id
ids.append(event_id)
except Exception, e:
raise osv.except_osv(('Error !'), (str(e)))
return ids
@@ -369,6 +382,7 @@ class Calendar(CalDAV, osv.osv):
def import_cal(self, cr, uid, content, data_id=None, context=None):
if not context:
context = {}
vals = []
ical_data = base64.decodestring(content)
parsedCal = vobject.readOne(ical_data)
if not data_id:
@@ -385,11 +399,12 @@ class Calendar(CalDAV, osv.osv):
})
self.__attribute__ = get_attribute_mapping(cr, uid, child.name.lower(), context=context)
val = self.parse_ics(cr, uid, child, cal_children=cal_children, context=context)
vals.append(val)
obj = self.pool.get(cal_children[child.name.lower()])
if hasattr(obj, 'check_import'):
obj.check_import(cr, uid, [val], context=context)
else:
self.check_import(cr, uid, [val], context=context)
if hasattr(obj, 'check_import'):
obj.check_import(cr, uid, vals, context=context)
else:
self.check_import(cr, uid, vals, context=context)
return {}
Calendar()
+1 -1
View File
@@ -606,6 +606,6 @@ class users(osv.osv):
_inherit = 'res.users'
_description = "Users"
_columns = {
'context_section_id': fields.many2one('crm.case.section', 'Sales Section'),
'context_section_id': fields.many2one('crm.case.section', 'Sales Team'),
}
users()
+1
View File
@@ -188,6 +188,7 @@ class base_action_rule_line(osv.osv):
'trg_categ_id': fields.many2one('crm.case.categ', 'Category'),
'regex_history' : fields.char('Regular Expression on Case History', size=128),
'act_section_id': fields.many2one('crm.case.section', 'Set section to'),
'act_categ_id': fields.many2one('crm.case.categ', 'Set Category to'),
'act_mail_to_partner': fields.boolean('Mail to partner',help="Check this if you want the rule to send an email to the partner."),
}
+19 -13
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<data>
<!-- Case rules -->
<record id="view_base_action_rule_line_form1" model="ir.ui.view">
<field name="name">base.action.rule.line.form.inherit</field>
@@ -8,27 +8,32 @@
<field name="inherit_id" ref="base_action_rule.view_base_action_rule_line_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="trg_partner_categ_id" position="after">
<separator colspan="4" string="Condition on Communication History"/>
<field name="regex_history"/>
<field name="trg_max_history"/>
</field>
<group name="partner" position="after">
<group col="2" colspan="2">
<separator colspan="4" string="Condition on Communication History"/>
<field name="regex_history"/>
<field name="trg_max_history"/>
</group>
</group>
</field>
</record>
<record id="view_base_action_rule_line_form2" model="ir.ui.view">
<field name="name">base.action.rule.line.form2.inherit</field>
<field name="model">base.action.rule.line</field>
<field name="inherit_id" ref="base_action_rule.view_base_action_rule_line_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="regex_name" position="after">
<field name="trg_section_id" select="1" widget="selection"/>
<field name="trg_categ_id"/>
</field>
<group name="partner" position="after">
<group col="2" colspan="2">
<separator colspan="4" string="Condition Case Fields"/>
<field name="trg_section_id" select="1" widget="selection"/>
<field name="trg_categ_id"/>
</group>
</group>
</field>
</record>
<record id="view_base_action_rule_line_form3" model="ir.ui.view">
<field name="name">base.action.rule.line.form3.inherit</field>
<field name="model">base.action.rule.line</field>
@@ -36,7 +41,8 @@
<field name="type">form</field>
<field name="arch" type="xml">
<field name="act_user_id" position="after">
<field name="act_section_id"/>
<field name="act_section_id"/>
<field name="act_categ_id"/>
<field name="act_mail_to_partner"/>
</field>
</field>
+2
View File
@@ -36,6 +36,8 @@
<field name="id"/>
<field name="name"/>
<field name="partner_id"/>
<field name="user_id" />
<field name="section_id" string="Section" />
<field name="date" string="Claim Date"/>
<field name="date_deadline" string="Deadline"/>
<field name="date_closed" string="Closure Date"/>
+2 -2
View File
@@ -37,7 +37,7 @@
<field name="arch" type="xml">
<tree string="Funds Tree" colors="red:state=='open';black:state in ('draft', 'cancel','done','pending')">
<field name="id"/>
<field name="name" string="Funds"/>
<field name="name" string="Fund Description"/>
<field name="categ_id"/>
<field name="type_id" string="Payment Mode"/>
<field name="planned_cost" string="Amount"/>
@@ -197,7 +197,7 @@
<filter icon="gtk-yes" domain="[('state','=','open')]" help="Open Funds"/>
<filter icon="gtk-media-pause" domain="[('state','=','pending')]" help="Pending Funds"/>
</field>
<field name="name" select='1'/>
<field name="name" select='1' string="Fund Description"/>
<field name="user_id" select="1" widget="selection"/>
<field name="section_id" select="1" widget="selection" string="Section" default="context.get('section_id', False)">
<filter icon="terp-crm"
+2 -2
View File
@@ -39,8 +39,8 @@ class crm_fundraising(osv.osv):
'partner_name2': fields.char('Employee Email', size=64),
'partner_phone': fields.char('Phone', size=32),
'partner_mobile': fields.char('Mobile', size=32),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id)]"),
'type_id': fields.many2one('crm.case.resource.type', 'Fundraising Type', domain="[('section_id','=',section_id)]"),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]"),
'type_id': fields.many2one('crm.case.resource.type', 'Fundraising Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]"),
'duration': fields.float('Duration'),
'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
+2 -3
View File
@@ -129,6 +129,7 @@
<field name="date" string="Date"/>
<field name="date_deadline"/>
<field name="user_id"/>
<field name="section_id" string="Section" />
<field name="state"/>
<button name="case_close" string="Done" states="open,draft,pending" type="object" icon="gtk-close"/>
<button name="case_open" string="Open" states="draft,pending" type="object" icon="gtk-go-forward"/>
@@ -172,12 +173,10 @@
/>
<separator orientation="vertical"/>
<field name="name" select='1' string="Query"/>
<field name="partner_id" />
<field name="user_id" select="1" widget="selection">
<filter icon="terp-partner" domain="[('user_id','=',uid)]" help="My Helpdesk Requests" default="1"/>
</field>
<field name="state" select="1">
<filter icon="gtk-index" domain="[('state','in',('open','draft' ))]" help="Current " default="1"/>
</field>
<field name="section_id" default="context.get('section_id', False)" select="1" widget="selection" string="Section">
<filter icon="terp-crm"
domain="[('section_id','=',context.get('section_id',False))]"
+1 -1
View File
@@ -79,7 +79,7 @@
<group col="3" colspan="2">
<separator colspan="3" string="Contacts" />
<field name="partner_id" />
<button string="Convert to Partner"
<button string="Create a Partner"
icon="terp-crm"
name="%(wizard_crm_phonecall_partner_create)d"
type="action"
+2 -2
View File
@@ -30,7 +30,7 @@ from tools.translate import _
class partner_create(wizard.interface):
case_form = """<?xml version="1.0"?>
<form string="Convert To Partner">
<form string="Create a Partner">
<label string="Are you sure you want to create a partner based on this lead ?" colspan="4"/>
<label string="You may have to verify that this partner does not exist already." colspan="4"/>
<!--field name="close"/-->
@@ -41,7 +41,7 @@ class partner_create(wizard.interface):
}
partner_form = """<?xml version="1.0"?>
<form string="Convert To Partner">
<form string="Create a Partner">
<label string="Are you sure you want to create a partner based on this lead ?" colspan="4"/>
<label string="You may have to verify that this partner does not exist already." colspan="4"/>
<newline />
+2 -2
View File
@@ -30,7 +30,7 @@ from tools.translate import _
class partner_create(wizard.interface):
case_form = """<?xml version="1.0"?>
<form string="Convert To Partner">
<form string="Create a Partner">
<label string="Are you sure you want to create a partner based on this phonecall ?" colspan="4"/>
<label string="You may have to verify that this partner does not exist already." colspan="4"/>
<!--field name="close"/-->
@@ -41,7 +41,7 @@ class partner_create(wizard.interface):
}
partner_form = """<?xml version="1.0"?>
<form string="Convert To Partner">
<form string="Create a Partner">
<label string="Are you sure you want to create a partner based on this lead ?" colspan="4"/>
<label string="You may have to verify that this partner does not exist already." colspan="4"/>
<newline />
+2 -3
View File
@@ -36,11 +36,10 @@
'crm_caldav_data.xml',
],
'update_xml': [
'crm_caldav_wizard.xml',
],
'update_xml': [],
'demo_xml': [],
'installable': True,
'active': False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+1 -24
View File
@@ -23,11 +23,10 @@ from osv import fields, osv
from crm import crm
from caldav import caldav
from base_calendar import base_calendar
class crm_meeting(osv.osv):
_inherit = 'crm.meeting'
def export_cal(self, cr, uid, ids, context={}):
ids = map(lambda x: base_calendar.base_calendar_id2real_id(x), ids)
event_data = self.read(cr, uid, ids)
@@ -39,29 +38,7 @@ class crm_meeting(osv.osv):
event_obj = self.pool.get('basic.calendar.event')
vals = event_obj.import_cal(cr, uid, data, context=context)
return self.check_import(cr, uid, vals, context=context)
def check_import(self, cr, uid, vals, context={}):
ids = []
for val in vals:
exists, r_id = caldav.uid2openobjectid(cr, val['id'], \
self._name, val.get('recurrent_id'))
if val.has_key('create_date'): val.pop('create_date')
val['base_calendar_url'] = context.get('url') or ''
val.pop('id')
if exists and r_id:
val.update({'recurrent_uid': exists})
self.write(cr, uid, [r_id], val)
ids.append(r_id)
elif exists:
self.write(cr, uid, [exists], val)
ids.append(exists)
else:
event_id = self.create(cr, uid, val)
ids.append(event_id)
return ids
crm_meeting()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-11
View File
@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard string="Import .ics File" model="crm.meeting"
name="calendar.event.import" id="caldav.wizard_cal_event_import" />
<wizard string="Export .ics File" model="crm.meeting"
name="calendar.event.export" id="caldav.wizard_cal_event_export" />
</data>
</openerp>
@@ -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:
@@ -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>
@@ -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
+1 -76
View File
@@ -4,88 +4,13 @@
<!-- Example employee -->
<record id="timesheet_group1" model="resource.calendar">
<field name="name">38 Hours/Week</field>
</record>
<record id="employee1" model="hr.employee">
<field name="name">Fabien Pinckaers</field>
<field name="calendar_id" ref="timesheet_group1"/>
<field name="calendar_id" ref="resource.timesheet_group1"/>
<!--<field name="regime">45</field>-->
<field name="user_id" ref="base.user_root"/>
<!--<field name="holiday_max">25</field>-->
</record>
<record model="resource.calendar.week">
<field name="name">Monday morning</field>
<field name="dayofweek">0</field>
<field name="hour_from">08</field>
<field name="hour_to">12</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Monday evening</field>
<field name="dayofweek">0</field>
<field name="hour_from">13</field>
<field name="hour_to">18</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Tuesday morning</field>
<field name="dayofweek">1</field>
<field name="hour_from">08</field>
<field name="hour_to">12</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Tuesday evening</field>
<field name="dayofweek">1</field>
<field name="hour_from">13</field>
<field name="hour_to">18</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Wednesday morning</field>
<field name="dayofweek">2</field>
<field name="hour_from">08</field>
<field name="hour_to">12</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Wednesday evening</field>
<field name="dayofweek">2</field>
<field name="hour_from">13</field>
<field name="hour_to">18</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Thursday morning</field>
<field name="dayofweek">3</field>
<field name="hour_from">08</field>
<field name="hour_to">12</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Thursday evening</field>
<field name="hour_from">13</field>
<field name="hour_to">18</field>
<field name="dayofweek">3</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Friday morning</field>
<field name="dayofweek">4</field>
<field name="hour_from">08</field>
<field name="hour_to">12</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Friday evening</field>
<field name="dayofweek">4</field>
<field name="hour_from">13</field>
<field name="hour_to">18</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
</data>
</openerp>
+1 -2
View File
@@ -377,11 +377,10 @@
<field name="view_mode">tree,form</field>
</record>
<menuitem icon="terp-hr" id="base.menu_hr" name="Human Resources"/>
<menuitem
name="Recruitment"
id="base.menu_crm_case_job_req_main"
parent="base.menu_hr"/>
parent="menu_hr_root"/>
<menuitem parent="base.menu_crm_case_job_req_main" id="menu_hr_job" action="action_hr_job" sequence="2"/>
</data>
+29 -7
View File
@@ -21,6 +21,7 @@
import time
from osv import fields, osv
from mx import DateTime as dt
class hr_evaluation_plan(osv.osv):
_name = "hr_evaluation.plan"
@@ -75,13 +76,36 @@ class hr_employee(osv.osv):
_inherit="hr.employee"
_columns = {
'evaluation_plan_id': fields.many2one('hr_evaluation.plan', 'Evaluation Plan'),
'evaluation_date': fields.date('Next Evaluation', help="Date of the next evaluation"),
'evaluation_date': fields.date('Next Evaluation', help="Date of the next evaluation",readonly=True),
}
def onchange_evaluation_plan_id(self, *args):
# return the right evaluation date
pass
def onchange_evaluation_plan_id(self,cr,uid,ids,evaluation_plan_id,context={}):
evaluation_date = self.browse(cr, uid, ids)[0].evaluation_date or ''
evaluation_plan_obj=self.pool.get('hr_evaluation.plan')
if evaluation_plan_id:
for evaluation_plan in evaluation_plan_obj.browse(cr,uid,[evaluation_plan_id]):
if not evaluation_date:
evaluation_date=(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d'))+ dt.RelativeDateTime(months=+evaluation_plan.month_first)).strftime('%Y-%m-%d')
else:
evaluation_date=(dt.ISO.ParseAny(evaluation_date)+ dt.RelativeDateTime(months=+evaluation_plan.month_next)).strftime('%Y-%m-%d')
return {'value': {'evaluation_date':evaluation_date}}
hr_employee()
class hr_evaluation_interview(osv.osv):
_name = "hr.evaluation.interview"
_inherit = "survey.request"
def default_get(self, cr, uid, fields, context={}):
data = super(hr_evaluation_interview, self).default_get(cr, uid, fields, context)
if context.has_key('phase_id'):
data['survey_id'] =self.pool.get('hr_evaluation.plan.phase').browse(cr, uid, context['phase_id']).survey_id.id
return data
_columns = {
'user_to_review_id': fields.many2one('hr.employee', 'Employee'),
}
hr_evaluation_interview()
class hr_evaluation(osv.osv):
_name = "hr_evaluation.evaluation"
_description = "Employee Evaluation"
@@ -89,7 +113,6 @@ class hr_evaluation(osv.osv):
_columns = {
'date': fields.date("Evaluation Deadline", required=True),
'employee_id': fields.many2one('hr.employee', "Employee", required=True),
'manager_id': fields.many2one('res.users', "Manager", required=True),
'note_summary': fields.text('Evaluation Summary'),
'note_action': fields.text('Action Plan',
help="If the evaluation does not meet the expectations, you can propose"+
@@ -101,7 +124,7 @@ class hr_evaluation(osv.osv):
('3','Exceeds expectations'),
('4','Significantly exceeds expectations'),
], "Overall Rating", help="This is the overall rating on that summarize the evaluation"),
'survey_request_ids': fields.many2many('survey.request',
'survey_request_ids': fields.many2many('hr.evaluation.interview',
'hr_evaluation_evaluation_requests',
'evaluation_id',
'survey_id',
@@ -139,4 +162,3 @@ class hr_evaluation(osv.osv):
hr_evaluation()
+11 -1
View File
@@ -1577,13 +1577,23 @@ Once the form had been filled, the employee send it to his supervisor.
<field eval="1" name="wait"/>
</record>
</data>
<data noupdate="1">
<record id="hr_evaluation_interview_1" model="hr.evaluation.interview">
<field name="state">waiting_answer</field>
<field name="survey_id" ref="hr_evaluation.survey_2"/>
<field name="user_id" ref="base.user_root"/>
<field name="email">fp@tinyerp.com</field>
<field name="date_deadline">2010-02-21</field>
</record>
</data>
<data noupdate="1">
<record id="hr_evaluation_evaluation_0" model="hr_evaluation.evaluation">
<field name="rating">0</field>
<field name="employee_id" ref="hr.employee1"/>
<field name="plan_id" ref="hr_evaluation_plan_managersevaluationplan0"/>
<field name="state">draft</field>
<field eval="[(6,0,[ref('survey_request_1')])]" name="survey_request_ids"/>
<field eval="[(6,0,[ref('hr_evaluation_interview_1')])]" name="survey_request_ids"/>
<field name="date">2010-01-21</field>
<field name="phase_id" ref="hr_evaluation_plan_phase_sendtomanagers0"/>
<field name="manager_id" ref="base.user_root"/>
+67 -4
View File
@@ -106,7 +106,7 @@
<field name="arch" type="xml">
<notebook position="inside">
<page string="Evaluation">
<field name="evaluation_plan_id"/>
<field name="evaluation_plan_id" on_change="onchange_evaluation_plan_id(evaluation_plan_id)"/>
<field name="evaluation_date"/>
</page>
</notebook>
@@ -123,13 +123,12 @@
<field name="date" select="1"/>
<field name="rating"/>
<field name="employee_id" select="1"/>
<field name="manager_id" select="1"/>
<field name="plan_id"/>
<field name="phase_id" domain="[('plan_id', '=', plan_id)]"/>
</group>
<notebook colspan="4">
<page string="Appraisal">
<field name="survey_request_ids" nolabel="1" colspan="4"/>
<field name="survey_request_ids" context="{'phase_id': phase_id}" nolabel="1" colspan="4"/>
</page>
<page string="Action Plan">
<field name="note_action" colspan="4" nolabel="1"/>
@@ -169,7 +168,6 @@
<tree string="Evaluation">
<field name="date"/>
<field name="employee_id"/>
<field name="manager_id"/>
</tree>
</field>
</record>
@@ -182,5 +180,70 @@
name="Evaluation" parent="menu_eval_hr"
id="menu_open_view_hr_evaluation_tree"
action="open_view_hr_evaluation_tree"/>
<record model="ir.ui.view" id="view_hr_evaluation_interview_form">
<field name="name">hr_evaluation.interview.form</field>
<field name="model">hr.evaluation.interview</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Survey Request">
<group col="4" colspan="4">
<field name="survey_id" widget="selection" colspan="3"/>
<group colspan="1">
<button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action"
icon="gtk-execute" context="{'survey_id': survey_id, 'response_id': response, 'active' : response, 'object' : 'hr.evaluation.interview', 'cur_id' : active_id}" attrs="{'readonly':[('survey_id','=',False)]}"/>
<button name="%(survey.survey_browse_response)d" string="Print Interview" type="action"
icon="gtk-print" context="{'survey_id': survey_id, 'response_id' : response,}" attrs="{'readonly':[('response','!=',True),('survey_id','!=',True)]}" />
</group>
</group>
<group col="4" colspan="4">
<field name="date_deadline"/>
<field name="response" readonly="1"/>
<field name="user_to_review_id"/>
<field name="user_id"/>
</group>
<newline/>
<separator string="State" colspan="4"/>
<group colspan="4" col="5">
<field name="state"/>
<button name="survey_req_waiting_answer" string="Set to Watting Answer" states="cancel,done" type="object" icon="gtk-new"/>
<button name="survey_req_done" string="Done" states="waiting_answer" type="object" icon="gtk-ok"/>
<button name="survey_req_cancel" string="Cancelled" states="waiting_answer" type="object" icon="gtk-cancel"/>
</group>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_hr_evaluation_interview_tree">
<field name="name">hr_evaluation.interview.tree</field>
<field name="model">hr.evaluation.interview</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Evaluation Plan Phase">
<field name="date_deadline"/>
<field name="survey_id" widget="selection"/>
<field name="user_to_review_id"/>
<field name="response" readonly="1" invisible="True"/>
<button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action" states="waiting_answer,done,cancel"
icon="gtk-execute" context="{'survey_id': survey_id, 'response_id': response, 'active' : response, 'object' : 'hr.evaluation.interview', 'cur_id' : active_id}" attrs="{'readonly':[('survey_id','=',False)]}"/>
<button name="%(survey.survey_browse_response)d" string="Print Interview" type="action" states="waiting_answer,done,cancel"
icon="gtk-print" context="{'survey_id': survey_id, 'response_id' : response,}" attrs="{'readonly':[('response','!=',True),('survey_id','!=',True)]}" />
<field name="state" />
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_hr_evaluation_interview_tree">
<field name="res_model">hr.evaluation.interview</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem
name="Intreview Requests" parent="menu_eval_hr"
id="menu_open_hr_evaluation_interview_requests"
action="action_hr_evaluation_interview_tree"/>
</data>
</openerp>
+3 -3
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -15,7 +15,7 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@@ -26,7 +26,7 @@
"author" : "Tiny",
"website" : "http://www.openerp.com",
"category" : "Generic Modules/Production",
"depends" : ["stock", "hr", "purchase", "product","process"],
"depends" : ["stock", "resource", "purchase", "product","process"],
"description": """
This is the base module to manage the manufacturing process in Open ERP.
+16 -18
View File
@@ -1,26 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<!--
Resource: mrp.workcenter
-->
<record id="mrp_workcenter_0" model="mrp.workcenter">
<field name="name">Assembly workshop</field>
<field name="calendar_id" ref="hr.timesheet_group1"/>
<field name="type">hr</field>
<field name="calendar_id" ref="resource.timesheet_group1"/>
</record>
<record id="mrp_workcenter_1" model="mrp.workcenter">
<field name="name">Repairs workshop</field>
<field name="calendar_id" ref="hr.timesheet_group1"/>
<field name="type">hr</field>
<field name="calendar_id" ref="resource.timesheet_group1"/>
</record>
<!--
Resource: mrp.property.group
-->
<record id="mrp_property_group_ram" model="mrp.property.group">
<field name="name">RAM</field>
</record>
@@ -54,11 +52,11 @@
<record id="mrp_property_group_psu" model="mrp.property.group">
<field name="name">PSU</field>
</record>
<!--
Resource: mrp.property
-->
<record id="mrp_property_0" model="mrp.property">
<field name="group_id" ref="mrp_property_group_ram"/>
<field name="name">DDR 512MB PC400</field>
@@ -140,7 +138,7 @@
<!--
Resource: mrp.routing.workcenter
-->
<record id="mrp_routing_workcenter_0" model="mrp.routing.workcenter">
<field name="routing_id" ref="mrp_routing_0"/>
<field name="workcenter_id" ref="mrp_workcenter_0"/>
@@ -160,11 +158,11 @@
<field name="hour_nbr">3</field>
<field name="name">assembly main + processor + fan</field>
</record>
<!--
Resource: mrp.bom
-->
<record id="mrp_bom_0" model="mrp.bom">
<field name="name">Regular processor config</field>
<field name="product_uom" ref="product.product_uom_unit"/>
@@ -173,7 +171,7 @@
<field name="type">normal</field>
<field model="product.product" name="product_id" search="[('default_code','=','CPU_GEN')]"/>
</record>
<record id="mrp_bom_1" model="mrp.bom">
<field name="name">Assembly Basic+ PC</field>
<field name="product_uom" ref="product.product_uom_unit"/>
@@ -249,14 +247,14 @@
<field name="type">phantom</field>
<field model="product.product" name="product_id" search="[('default_code','=','RAM_GEN')]"/>
</record>
<record id="mrp_bom_13" model="mrp.bom">
<field name="name">High Speed Processor + main board on demand</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field model="product.product" name="product_id" search="[('default_code','=','CPU2')]"/>
</record>
<record id="mrp_bom_kit" model="mrp.bom">
<field name="code">KIT</field>
<field name="name">Kit Mouse</field>
@@ -486,7 +484,7 @@
<field name="bom_id" ref="mrp_bom_9"/>
<field model="product.product" name="product_id" search="[('default_code','=','TOW1')]"/>
</record>
<record id="mrp_bom_kit2" model="mrp.bom">
<field name="code">KIT</field>
<field name="name">Kit Keyboard + Mouse</field>
@@ -510,6 +508,6 @@
<field name="bom_id" ref="mrp_bom_kit2"/>
<field model="product.product" name="product_id" search="[('default_code','=','KEYA')]"/>
</record>
</data>
</openerp>
+1 -1
View File
@@ -26,7 +26,7 @@
"author" : "Tiny",
"website" : "http://www.openerp.com",
"category" : "Generic Modules/Projects & Services",
"depends" : ["product", "analytic", "hr", "process", "mail_gateway"],
"depends" : ["product", "analytic", "process", "mail_gateway"],
"description": """Project management module that track multi-level projects, tasks,
works done on tasks, eso. It is able to render planning, order tasks, eso.
""",
+2 -102
View File
@@ -134,10 +134,6 @@ class project(osv.osv):
'warn_customer': fields.boolean('Warn Partner', help="If you check this, the user will have a popup when closing a task that propose a message to send by email to the customer."),
'warn_header': fields.text('Mail Header', help="Header added at the beginning of the email for the warning message sent to the customer when a task is closed."),
'warn_footer': fields.text('Mail Footer', help="Footer added at the beginning of the email for the warning message sent to the customer when a task is closed."),
'resource_calendar_id': fields.many2one('resource.calendar', 'Working Time', help="Timetable working hours to adjust the gantt diagram report"),
# 'state': fields.selection([('template', 'Template'), ('open', 'Running'), ('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')], 'State', required=True, readonly=True,
# help='The project can be in either if the states \'Template\' and \'Running\'.\n If it is template then we can make projects based on the template projects. If its in \'Running\' state it is a normal project.\
# \n If it is to be reviewed then the state is \'Pending\'.\n When the project is completed the state is set to \'Done\'.'),
'type_ids': fields.many2many('project.task.type', 'project_task_type_rel', 'project_id', 'type_id', 'Tasks Stages'),
}
_order = "sequence"
@@ -256,25 +252,8 @@ class task(osv.osv):
res[task.id]['delay_hours'] = res[task.id]['total_hours'] - task.planned_hours
return res
def onchange_planned(self, cr, uid, ids, project, user_id = False,planned=0.0, effective=0.0,date_start=None,occupation_rate=0.0):
result = {}
if date_start:
resource_pool = self.pool.get('resource.resource')
project_pool = self.pool.get('project.project')
resource_calendar = self.pool.get('resource.calendar')
dt_start = mx.DateTime.strptime(date_start,'%Y-%m-%d %H:%M:%S')
resource_id = resource_pool.search(cr,uid,[('user_id','=',user_id)])
if resource_id:
resource_obj = resource_pool.browse(cr,uid,resource_id)[0]
hrs = planned/(float(occupation_rate) * resource_obj.time_efficiency)
calendar_id = resource_obj.calendar_id.id
else:
hrs = float(planned / occupation_rate)
calendar_id = project_pool.browse(cr,uid,project).resource_calendar_id .id
work_times = resource_calendar.interval_get(cr, uid, calendar_id or False, dt_start, hrs or 0.0,resource_id or False)
result['date_end'] = work_times[-1][1].strftime('%Y-%m-%d %H:%M:%S')
result['remaining_hours'] = planned-effective
return {'value':result}
def onchange_planned(self, cr, uid, ids, planned = 0.0, effective = 0.0):
return {'value':{'remaining_hours' : planned - effective}}
def _default_project(self, cr, uid, context={}):
if 'project_id' in context and context['project_id']:
@@ -315,7 +294,6 @@ class task(osv.osv):
'parent_ids': fields.many2many('project.task', 'project_task_parent_rel', 'task_id', 'parent_id', 'Parent Tasks'),
'child_ids': fields.many2many('project.task', 'project_task_parent_rel', 'parent_id', 'task_id', 'Delegated Tasks'),
'notes': fields.text('Notes'),
'occupation_rate': fields.float('Occupation Rate', help='The occupation rate fields indicates how much of his time a user is working on a task. A 100% occupation rate means the user works full time on the tasks. The ending date of a task is computed like this: Starting Date + Duration / Occupation Rate.'),
'planned_hours': fields.float('Planned Hours', required=True, help='Estimated time to do the task, usually set by the project manager when the task is in draft state.'),
'effective_hours': fields.function(_hours_get, method=True, string='Hours Spent', multi='hours', store=True, help="Computed using the sum of the task work done."),
'remaining_hours': fields.float('Remaining Hours', digits=(16,4), help="Total remaining time, can be re-estimated periodically by the assignee of the task."),
@@ -339,7 +317,6 @@ class task(osv.osv):
'active': lambda *a: True,
'date_start': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'project_id': _default_project,
'occupation_rate':lambda *a: '1',
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'project.task', context=c)
}
_order = "sequence, priority, date_start, id"
@@ -479,83 +456,6 @@ class task(osv.osv):
self.write(cr, uid, typ.id, {'type': index and types[index-1] or False})
return True
def constraint_date_start(self,cr,uid,task,date_end,context=None):
# Recursive call for all previous tasks if change in date_start < older time
resource_cal_pool = self.pool.get('resource.calendar')
resource_pool = self.pool.get('resource.resource')
calendar_id = task.project_id.resource_calendar_id.id
hours = task.remaining_hours / task.occupation_rate
resource_id = resource_pool.search(cr,uid,[('user_id','=',task.user_id.id)])
if resource_id:
resource_obj = resource_pool.browse(cr,uid,resource_id[0])
calendar_id = resource_obj.calendar_id.id
hours = task.planned_hours/(float(task.occupation_rate) * resource_obj.time_efficiency)
work_time = resource_cal_pool.interval_min_get(cr, uid, calendar_id or False, date_end, hours or 0.0,resource_id or False)
dt_start = work_time[0][0].strftime('%Y-%m-%d %H:%M:%S')
self.write(cr,uid,[task.id],{'date_start':dt_start,'date_end':date_end.strftime('%Y-%m-%d %H:%M:%S')})
def constraint_date_end(self,cr,uid,task,date_start,context=None):
# Recursive call for all next tasks if change in date_end > older time
resource_cal_pool = self.pool.get('resource.calendar')
resource_pool = self.pool.get('resource.resource')
calendar_id = task.project_id.resource_calendar_id.id
hours = task.remaining_hours / task.occupation_rate
resource_id = resource_pool.search(cr,uid,[('user_id','=',task.user_id.id)])
if resource_id:
resource_obj = resource_pool.browse(cr,uid,resource_id[0])
calendar_id = resource_obj.calendar_id.id
hours = task.planned_hours/(float(task.occupation_rate) * resource_obj.time_efficiency)
work_time = resource_cal_pool.interval_get(cr, uid, calendar_id or False, date_start, hours or 0.0,resource_id or False)
dt_end = work_time[-1][1].strftime('%Y-%m-%d %H:%M:%S')
self.write(cr,uid,[task.id],{'date_start':date_start.strftime('%Y-%m-%d %H:%M:%S'),'date_end':dt_end})
def write_old(self, cr, uid, ids, vals,context=None):
if not context:
context = {}
if context.get('scheduler',False):
return super(task, self).write(cr, uid, ids, vals, context=context)
# if the task is performed by a resource then its calendar and efficiency also taken
# otherwise the project's working calendar considered
tasks = self.browse(cr,uid,ids[0])
resource_cal_pool = self.pool.get('resource.calendar')
resource_pool = self.pool.get('resource.resource')
calendar_id = tasks.project_id.resource_calendar_id.id
hrs = tasks.remaining_hours / tasks.occupation_rate
resource_id = resource_pool.search(cr,uid,[('user_id','=',tasks.user_id.id)])
if resource_id:
resource_obj = resource_pool.browse(cr,uid,resource_id[0])
calendar_id = resource_obj.calendar_id.id
hrs = tasks.planned_hours/(float(tasks.occupation_rate) * resource_obj.time_efficiency)
# write method changes the date_start and date_end
# for previous and next tasks respectively based on valid condition
if vals.get('date_start'):
if vals['date_start'] < tasks.date_start:
dt_start = mx.DateTime.strptime(vals['date_start'],'%Y-%m-%d %H:%M:%S')
work_times = resource_cal_pool.interval_get(cr, uid, calendar_id or False, dt_start, hrs or 0.0,resource_id or False)
vals['date_end'] = work_times[-1][1].strftime('%Y-%m-%d %H:%M:%S')
super(task, self).write(cr, uid, ids, vals, context=context)
for prv_task in tasks.parent_ids:
self.constraint_date_start(cr,uid,prv_task,dt_start)
if vals.get('date_end'):
if vals['date_end'] > tasks.date_end:
dt_end = mx.DateTime.strptime(vals['date_end'],'%Y-%m-%d %H:%M:%S')
hrs = tasks.remaining_hours / tasks.occupation_rate
work_times = resource_cal_pool.interval_min_get(cr, uid, calendar_id or False, dt_end, hrs or 0.0,resource_id or False)
vals['date_start'] = work_times[0][0].strftime('%Y-%m-%d %H:%M:%S')
super(task, self).write(cr, uid, ids, vals, context=context)
for next_task in tasks.child_ids:
self.constraint_date_end(cr,uid,next_task,dt_end)
return super(task, self).write(cr, uid, ids, vals, context=context)
task()
class project_work(osv.osv):
+6 -8
View File
@@ -25,8 +25,7 @@
<page string="Administration">
<group col="2" colspan="2">
<separator colspan="2" string="Scheduling"/>
<field name="resource_calendar_id"/>
<field name="priority"/>
<field name="priority"/>
<field name="active" select="2"/>
</group>
<group col="2" colspan="2">
@@ -247,7 +246,7 @@
name="planned_hours"
widget="float_time"
attrs="{'readonly':[('state','!=','draft')]}"
on_change="onchange_planned(project_id,user_id,planned_hours,effective_hours,date_start,occupation_rate)"/>
on_change="onchange_planned(planned_hours, effective_hours)"/>
<field name="remaining_hours" select="2" widget="float_time" attrs="{'readonly':[('state','!=','draft')]}" colspan="2"/>
<button name="%(action_config_compute_remaining)d" string="Review" type="action" colspan="1" target="new" states="open,pending" icon="gtk-edit"/>
</group>
@@ -304,7 +303,6 @@
<separator string="Dates" colspan="2"/>
<field name="date_start"/>
<field name="date_end"/>
<field name="occupation_rate"/>
</group>
<separator string="Miscelleanous" colspan="4"/>
<field name="partner_id" select="2"/>
@@ -331,7 +329,7 @@
<tree colors="grey:state in ('cancelled','done');blue:remaining_hours&lt;0;red:bool(date_deadline) and (date_deadline&lt;current_date) and (state in ('draft','open'));black:state not in ('cancelled','done')" string="Tasks">
<field name="sequence" invisible="1"/>
<field name="name"/>
<field name="planned_hours" widget="float_time" on_change="onchange_planned(planned_hours)" invisible="not context.get('set_visible',False)"/>
<field name="planned_hours" widget="float_time" on_change="onchange_planned(planned_hours, effective_hours)" invisible="not context.get('set_visible',False)"/>
<field name="project_id" icon="gtk-indent" domain="['|',('user_id','=',uid),('members','=',uid)]"/>
<field name="user_id"/>
<field name="delegated_user_id" invisible="context.get('show_delegated', True)"/>
@@ -404,8 +402,7 @@
<field name="arch" type="xml">
<search string="Task Edition">
<group col="20" colspan="4">
<filter string="TODO" domain="[('state','in',('open','draft'))]" help="Draft and Open Tasks" icon="terp-project" default="1"/>
<filter string="Current" domain="[('state','in',('open','draft','pending'))]" help="Draft, Open and Pending Tasks" icon="terp-project" default="1"/>
<filter string="Current" domain="[('state','in',('open','draft'))]" help="Draft, Open and Pending Tasks" icon="terp-project" default="1"/>
<filter string="In Progress" domain="[('state','=','open')]" help="Open Tasks" icon="terp-project"/>
<filter string="Pending" domain="[('state','=','pending')]" context="{'show_delegated':False}" help="Pending Tasks" icon="terp-project"/>
<separator orientation="vertical"/>
@@ -413,7 +410,8 @@
<separator orientation="vertical"/>
<field name="name" select="1"/>
<field name="project_id" select="1" widget="selection" default="context.get('project_id', False)">
<filter domain="[('manager_id','=',False)]" help="Unassigned Project" icon="terp-project"/>
<filter domain="[('project_id.user_id','=',uid)]" help="My Projects" icon="terp-project"/>
<filter domain="[('project_id','=',False)]" help="Tasks not assigned to a project" icon="terp-project"/>
</field>
<field name="user_id" select="1" widget="selection">
<filter domain="[('user_id','=',uid)]" help="My Tasks" icon="gtk-execute" default="1"/>
-10
View File
@@ -3,16 +3,6 @@
<data>
<wizard id="wizard_close_task" menu="False" model="project.task" name="project.task.close" string="Close Task"/>
<wizard id="wizard_delegate_task" menu="False" model="project.task" name="project.task.delegate" string="Delegate Task"/>
<wizard id="wizard_compute_task" model="project.task" menu="False" name="wizard.compute.tasks" string="Compute Task Scheduling"/>
<menuitem id="base.menu_pm_planning" name="Planning" parent="base.menu_main" sequence="3"/>
<menuitem
action="wizard_compute_task"
id="menu_wizard_compute_task"
parent="base.menu_pm_planning"
type="wizard"
sequence="1"/>
<wizard
id="wizard_duplicate_template"
menu="False"
-2
View File
@@ -21,9 +21,7 @@
import close_task
import task_delegate
import compute_tasks_date
import duplicate_template_wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+1 -1
View File
@@ -26,7 +26,7 @@
"author" : "Tiny",
"website" : "http://www.openerp.com",
"category" : "Generic Modules/Projects & Services",
"depends" : ["project"],
"depends" : ["project","resource"],
"description": """Long Term Project management module that track planning, scheduling, resources allocation.
""",
"init_xml" : [],
+156 -37
View File
@@ -78,6 +78,19 @@ class project_phase(osv.osv):
return False
return True
def _check_constraint_start(self, cr, uid, ids):
phase = self.read(cr, uid, ids[0],['date_start','constraint_date_start'])
if phase['date_start'] and phase['constraint_date_start']:
if phase['date_start'] < phase['constraint_date_start']:
return False
return True
def _check_constraint_end(self, cr, uid, ids):
phase = self.read(cr, uid, ids[0],['date_end','constraint_date_end'])
if phase['date_end'] and phase['constraint_date_end']:
if phase['date_end'] > phase['constraint_date_end']:
return False
return True
_columns = {
'name': fields.char("Phase Name", size=64, required=True),
@@ -110,52 +123,55 @@ class project_phase(osv.osv):
_order = "name"
_constraints = [
(_check_recursion,'Error ! Loops In Phases Not Allowed',['next_phase_ids','previous_phase_ids']),
(_check_dates, 'Error! Phase start-date must be lower then Phase end-date.', ['date_start', 'date_end'])
(_check_dates, 'Error! Phase start-date must be lower then Phase end-date.', ['date_start', 'date_end']),
(_check_constraint_start, 'Error! Phase must start-after Constraint Start Date.', ['date_start', 'constraint_date_start']),
(_check_constraint_end, 'Error! Phase must end-before Constraint End Date.', ['date_end', 'constraint_date_end']),
]
def onchange_project(self,cr,uid,ids,project):
def onchange_project(self, cr, uid, ids, project):
result = {}
if project:
project_pool = self.pool.get('project.project')
project_id = project_pool.browse(cr,uid,project)
project_id = project_pool.browse(cr, uid, project)
if project_id.date_start:
result['date_start'] = mx.DateTime.strptime(project_id.date_start,"%Y-%m-%d").strftime('%Y-%m-%d %H:%M:%S')
return {'value':result}
return {'value':{'date_start':[]}}
result['date_start'] = mx.DateTime.strptime(project_id.date_start, "%Y-%m-%d").strftime('%Y-%m-%d %H:%M:%S')
return {'value' : result}
return {'value' : {'date_start' : []}}
def constraint_date_start(self,cr,uid,phase,date_end,context=None):
def constraint_date_start(self, cr, uid, phase, date_end, context=None):
# Recursive call for all previous phases if change in date_start < older time
resource_cal_pool = self.pool.get('resource.calendar')
uom_pool = self.pool.get('product.uom')
resource_pool = self.pool.get('resource.resource')
calendar_id = phase.project_id.resource_calendar_id.id
if phase.responsible_id.id:
resource_id = resource_pool.search(cr,uid,[('user_id','=',phase.responsible_id.id)])
calendar_id = resource_pool.browse(cr,uid,resource_id[0]).calendar_id.id
default_uom_id = uom_pool.search(cr,uid,[('name','=','Hour')])[0]
avg_hours = uom_pool._compute_qty(cr, uid, phase.product_uom.id, phase.duration,default_uom_id)
work_time = resource_cal_pool.interval_min_get(cr, uid, calendar_id or False, date_end, avg_hours or 0.0,resource_id or False)
resource_id = resource_pool.search(cr, uid, [('user_id','=',phase.responsible_id.id)])
if resource_id:
calendar_id = resource_pool.browse(cr, uid, resource_id[0]).calendar_id.id
default_uom_id = uom_pool.search(cr, uid, [('name','=','Hour')])[0]
avg_hours = uom_pool._compute_qty(cr, uid, phase.product_uom.id, phase.duration, default_uom_id)
work_time = resource_cal_pool.interval_min_get(cr, uid, calendar_id or False, date_end, avg_hours or 0.0, resource_id or False)
dt_start = work_time[0][0].strftime('%Y-%m-%d %H:%M:%S')
self.write(cr,uid,[phase.id],{'date_start':dt_start,'date_end':date_end.strftime('%Y-%m-%d %H:%M:%S')})
self.write(cr, uid, [phase.id], {'date_start' : dt_start, 'date_end' : date_end.strftime('%Y-%m-%d %H:%M:%S')})
def constraint_date_end(self,cr,uid,phase,date_start,context=None):
def constraint_date_end(self, cr, uid, phase, date_start, context=None):
# Recursive call for all next phases if change in date_end > older time
resource_cal_pool = self.pool.get('resource.calendar')
uom_pool = self.pool.get('product.uom')
resource_pool = self.pool.get('resource.resource')
calendar_id = phase.project_id.resource_calendar_id.id
if phase.responsible_id.id:
resource_id = resource_pool.search(cr,uid,[('user_id','=',phase.responsible_id.id)])
calendar_id = resource_pool.browse(cr,uid,resource_id[0]).calendar_id.id
default_uom_id = uom_pool.search(cr,uid,[('name','=','Hour')])[0]
avg_hours = uom_pool._compute_qty(cr, uid, phase.product_uom.id, phase.duration,default_uom_id)
work_time = resource_cal_pool.interval_get(cr, uid, calendar_id or False, date_start, avg_hours or 0.0,resource_id or False)
resource_id = resource_pool.search(cr, uid, [('user_id','=',phase.responsible_id.id)])
if resource_id:
calendar_id = resource_pool.browse(cr, uid, resource_id[0]).calendar_id.id
default_uom_id = uom_pool.search(cr, uid, [('name','=','Hour')])[0]
avg_hours = uom_pool._compute_qty(cr, uid, phase.product_uom.id, phase.duration, default_uom_id)
work_time = resource_cal_pool.interval_get(cr, uid, calendar_id or False, date_start, avg_hours or 0.0, resource_id or False)
dt_end = work_time[-1][1].strftime('%Y-%m-%d %H:%M:%S')
self.write(cr,uid,[phase.id],{'date_start':date_start.strftime('%Y-%m-%d %H:%M:%S'),'date_end':dt_end})
self.write(cr, uid, [phase.id], {'date_start' : date_start.strftime('%Y-%m-%d %H:%M:%S'), 'date_end' : dt_end})
def write(self, cr, uid, ids, vals,context=None):
def write(self, cr, uid, ids, vals, context=None):
if not context:
context = {}
@@ -165,19 +181,17 @@ class project_phase(osv.osv):
# if the phase is performed by a resource then its calendar and efficiency also taken
# otherwise the project's working calendar considered
phase = self.browse(cr,uid,ids[0])
phase = self.browse(cr, uid, ids[0])
resource_cal_pool = self.pool.get('resource.calendar')
resource_pool = self.pool.get('resource.resource')
uom_pool = self.pool.get('product.uom')
resource_id = False
calendar_id = phase.project_id.resource_calendar_id.id
if phase.responsible_id.id:
resource_id = resource_pool.search(cr,uid,[('user_id','=',phase.responsible_id.id)])
if resource_id:
calendar_id = resource_pool.browse(cr,uid,resource_id[0]).calendar_id.id
default_uom_id = uom_pool.search(cr,uid,[('name','=','Hour')])[0]
avg_hours = uom_pool._compute_qty(cr, uid, phase.product_uom.id, phase.duration,default_uom_id)
resource_id = resource_pool.search(cr, uid, [('user_id','=',phase.responsible_id.id)])
if resource_id:
calendar_id = resource_pool.browse(cr, uid, resource_id[0]).calendar_id.id
default_uom_id = uom_pool.search(cr, uid, [('name','=','Hour')])[0]
avg_hours = uom_pool._compute_qty(cr, uid, phase.product_uom.id, phase.duration, default_uom_id)
# write method changes the date_start and date_end
#for previous and next phases respectively based on valid condition
@@ -185,22 +199,22 @@ class project_phase(osv.osv):
if vals.get('date_start'):
if vals['date_start'] < phase.date_start:
dt_start = mx.DateTime.strptime(vals['date_start'],'%Y-%m-%d %H:%M:%S')
work_times = resource_cal_pool.interval_get(cr, uid, calendar_id or False, dt_start, avg_hours or 0.0,resource_id or False)
work_times = resource_cal_pool.interval_get(cr, uid, calendar_id or False, dt_start, avg_hours or 0.0, resource_id or False)
vals['date_end'] = work_times[-1][1].strftime('%Y-%m-%d %H:%M:%S')
super(project_phase, self).write(cr, uid, ids, vals, context=context)
for prv_phase in phase.previous_phase_ids:
self.constraint_date_start(cr,uid,prv_phase,dt_start)
self.constraint_date_start(cr, uid, prv_phase, dt_start)
if vals.get('date_end'):
if vals['date_end'] > phase.date_end:
dt_end = mx.DateTime.strptime(vals['date_end'],'%Y-%m-%d %H:%M:%S')
work_times = resource_cal_pool.interval_min_get(cr, uid, calendar_id or False, dt_end, avg_hours or 0.0,resource_id or False)
work_times = resource_cal_pool.interval_min_get(cr, uid, calendar_id or False, dt_end, avg_hours or 0.0, resource_id or False)
vals['date_start'] = work_times[0][0].strftime('%Y-%m-%d %H:%M:%S')
super(project_phase, self).write(cr, uid, ids, vals, context=context)
for next_phase in phase.next_phase_ids:
self.constraint_date_end(cr,uid,next_phase,dt_end)
self.constraint_date_end(cr, uid, next_phase, dt_end)
return super(project_phase, self).write(cr, uid, ids, vals, context=context)
@@ -245,7 +259,8 @@ class project(osv.osv):
_inherit = "project.project"
_columns = {
'phase_ids': fields.one2many('project.phase', 'project_id', "Project Phases")
'phase_ids': fields.one2many('project.phase', 'project_id', "Project Phases"),
'resource_calendar_id': fields.many2one('resource.calendar', 'Working Time', help="Timetable working hours to adjust the gantt diagram report"),
}
project()
@@ -254,8 +269,112 @@ class task(osv.osv):
_inherit = "project.task"
_columns = {
'phase_id': fields.many2one('project.phase', 'Project Phase')
'phase_id': fields.many2one('project.phase', 'Project Phase'),
'occupation_rate': fields.float('Occupation Rate', help='The occupation rate fields indicates how much of his time a user is working on a task. A 100% occupation rate means the user works full time on the tasks. The ending date of a task is computed like this: Starting Date + Duration / Occupation Rate.'),
'planned_hours': fields.float('Planned Hours', required=True, help='Estimated time to do the task, usually set by the project manager when the task is in draft state.'),
}
_defaults = {
'occupation_rate':lambda *a: '1'
}
def onchange_planned(self, cr, uid, ids, project, user_id=False, planned=0.0, effective=0.0, date_start=None, occupation_rate=0.0):
result = {}
if date_start:
resource_pool = self.pool.get('resource.resource')
project_pool = self.pool.get('project.project')
resource_calendar = self.pool.get('resource.calendar')
dt_start = mx.DateTime.strptime(date_start, '%Y-%m-%d %H:%M:%S')
resource_id = resource_pool.search(cr, uid, [('user_id','=',user_id)])
if resource_id:
resource_obj = resource_pool.browse(cr, uid, resource_id)[0]
hrs = planned / (float(occupation_rate) * resource_obj.time_efficiency)
calendar_id = resource_obj.calendar_id.id
else:
hrs = float(planned / float(occupation_rate))
calendar_id = project_pool.browse(cr, uid, project).resource_calendar_id .id
work_times = resource_calendar.interval_get(cr, uid, calendar_id or False, dt_start, hrs or 0.0, resource_id or False)
result['date_end'] = work_times[-1][1].strftime('%Y-%m-%d %H:%M:%S')
result['remaining_hours'] = planned - effective
return {'value' : result}
def constraint_date_start(self, cr, uid, task, date_end, context=None):
# Recursive call for all previous tasks if change in date_start < older time
resource_cal_pool = self.pool.get('resource.calendar')
resource_pool = self.pool.get('resource.resource')
calendar_id = task.project_id.resource_calendar_id.id
hours = task.remaining_hours / task.occupation_rate
resource_id = resource_pool.search(cr, uid, [('user_id','=',task.user_id.id)])
if resource_id:
resource_obj = resource_pool.browse(cr, uid, resource_id[0])
calendar_id = resource_obj.calendar_id.id
hours = task.planned_hours / (float(task.occupation_rate) * resource_obj.time_efficiency)
work_time = resource_cal_pool.interval_min_get(cr, uid, calendar_id or False, date_end, hours or 0.0, resource_id or False)
dt_start = work_time[0][0].strftime('%Y-%m-%d %H:%M:%S')
self.write(cr, uid, [task.id], {'date_start' : dt_start,'date_end' : date_end.strftime('%Y-%m-%d %H:%M:%S')})
def constraint_date_end(self, cr, uid, task, date_start, context=None):
# Recursive call for all next tasks if change in date_end > older time
resource_cal_pool = self.pool.get('resource.calendar')
resource_pool = self.pool.get('resource.resource')
calendar_id = task.project_id.resource_calendar_id.id
hours = task.remaining_hours / task.occupation_rate
resource_id = resource_pool.search(cr,uid,[('user_id','=',task.user_id.id)])
if resource_id:
resource_obj = resource_pool.browse(cr, uid, resource_id[0])
calendar_id = resource_obj.calendar_id.id
hours = task.planned_hours / (float(task.occupation_rate) * resource_obj.time_efficiency)
work_time = resource_cal_pool.interval_get(cr, uid, calendar_id or False, date_start, hours or 0.0, resource_id or False)
dt_end = work_time[-1][1].strftime('%Y-%m-%d %H:%M:%S')
self.write(cr, uid, [task.id], {'date_start' : date_start.strftime('%Y-%m-%d %H:%M:%S'),'date_end' : dt_end})
def write(self, cr, uid, ids, vals, context=None):
if not context:
context = {}
if context.get('scheduler',False):
return super(task, self).write(cr, uid, ids, vals, context=context)
# if the task is performed by a resource then its calendar and efficiency also taken
# otherwise the project's working calendar considered
tasks = self.browse( cr, uid, ids[0])
resource_cal_pool = self.pool.get('resource.calendar')
resource_pool = self.pool.get('resource.resource')
calendar_id = tasks.project_id.resource_calendar_id.id
hrs = tasks.remaining_hours / tasks.occupation_rate
resource_id = resource_pool.search(cr, uid, [('user_id','=',tasks.user_id.id)])
if resource_id:
resource_obj = resource_pool.browse(cr, uid, resource_id[0])
calendar_id = resource_obj.calendar_id.id
hrs = tasks.planned_hours / (float(tasks.occupation_rate) * resource_obj.time_efficiency)
# write method changes the date_start and date_end
# for previous and next tasks respectively based on valid condition
if vals.get('date_start'):
if vals['date_start'] < tasks.date_start:
dt_start = mx.DateTime.strptime(vals['date_start'],'%Y-%m-%d %H:%M:%S')
work_times = resource_cal_pool.interval_get(cr, uid, calendar_id or False, dt_start, hrs or 0.0, resource_id or False)
vals['date_end'] = work_times[-1][1].strftime('%Y-%m-%d %H:%M:%S')
super(task, self).write(cr, uid, ids, vals, context=context)
for prv_task in tasks.parent_ids:
self.constraint_date_start(cr, uid, prv_task, dt_start)
if vals.get('date_end'):
if vals['date_end'] > tasks.date_end:
dt_end = mx.DateTime.strptime(vals['date_end'],'%Y-%m-%d %H:%M:%S')
hrs = tasks.remaining_hours / tasks.occupation_rate
work_times = resource_cal_pool.interval_min_get(cr, uid, calendar_id or False, dt_end, hrs or 0.0, resource_id or False)
vals['date_start'] = work_times[0][0].strftime('%Y-%m-%d %H:%M:%S')
super(task, self).write(cr, uid, ids, vals, context=context)
for next_task in tasks.child_ids:
self.constraint_date_end(cr, uid, next_task, dt_end)
return super(task, self).write(cr, uid, ids, vals, context=context)
task()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+19 -29
View File
@@ -34,7 +34,7 @@
<field name="password">manager1</field>
<field eval="[(6,0,[])]" name="company_ids"/>
</record>
<record id="res_users_manager1" model="res.users">
<field model="ir.actions.actions" name="menu_id" search="[('name', '=', u'Menu')]"/>
<field name="context_lang">en_US</field>
@@ -49,7 +49,7 @@
<field name="password">manager2</field>
<field eval="[(6,0,[])]" name="company_ids"/>
</record>
<record id="res_users_user0" model="res.users">
<field model="ir.actions.actions" name="menu_id" search="[('name', '=', u'Menu')]"/>
<field name="context_lang">en_US</field>
@@ -64,7 +64,7 @@
<field name="password">USER1</field>
<field eval="[(6,0,[])]" name="company_ids"/>
</record>
<record id="res_users_user1" model="res.users">
<field model="ir.actions.actions" name="menu_id" search="[('name', '=', u'Menu')]"/>
<field name="context_lang">en_US</field>
@@ -79,7 +79,7 @@
<field name="password">user2</field>
<field eval="[(6,0,[])]" name="company_ids"/>
</record>
<record id="res_users_userfinance0" model="res.users">
<field model="ir.actions.actions" name="menu_id" search="[('name', '=', u'Menu')]"/>
<field name="context_lang">en_US</field>
@@ -94,7 +94,7 @@
<field name="password">user_finance</field>
<field eval="[(6,0,[])]" name="company_ids"/>
</record>
<record id="res_users_userdesign0" model="res.users">
<field model="ir.actions.actions" name="menu_id" search="[('name', '=', u'Menu')]"/>
<field name="context_lang">en_US</field>
@@ -109,7 +109,7 @@
<field name="password">user_design1</field>
<field eval="[(6,0,[])]" name="company_ids"/>
</record>
<record id="res_users_userdesign1" model="res.users">
<field model="ir.actions.actions" name="menu_id" search="[('name', '=', u'Menu')]"/>
<field name="context_lang">en_US</field>
@@ -201,23 +201,13 @@
</record>
<!-- Resources -->
<record id="resource_resource_fabienpinckaers0" model="resource.resource">
<field eval="1.0" name="time_efficiency"/>
<field name="user_id" ref="base.user_root"/>
<field name="name">Fabien Pinckaers</field>
<field name="company_id" ref="base.main_company"/>
<field eval="1" name="active"/>
<field name="calendar_id" ref="hr.timesheet_group1"/>
<field name="resource_type">user</field>
</record>
<record id="resource_resource_analyst0" model="resource.resource">
<field eval="1.0" name="time_efficiency"/>
<field name="user_id" ref="res_users_useranalyst0"/>
<field name="name">Analyst</field>
<field name="company_id" ref="base.main_company"/>
<field eval="1" name="active"/>
<field name="calendar_id" ref="hr.timesheet_group1"/>
<field name="calendar_id" ref="resource.timesheet_group1"/>
<field name="resource_type">user</field>
</record>
@@ -227,7 +217,7 @@
<field name="name">Programmer</field>
<field name="company_id" ref="base.main_company"/>
<field eval="1" name="active"/>
<field name="calendar_id" ref="hr.timesheet_group1"/>
<field name="calendar_id" ref="resource.timesheet_group1"/>
<field name="resource_type">user</field>
</record>
@@ -237,7 +227,7 @@
<field name="name">Tester</field>
<field name="company_id" ref="base.main_company"/>
<field eval="1" name="active"/>
<field name="calendar_id" ref="hr.timesheet_group1"/>
<field name="calendar_id" ref="resource.timesheet_group1"/>
<field name="resource_type">user</field>
</record>
@@ -247,7 +237,7 @@
<field name="name">Web Designer</field>
<field name="company_id" ref="base.main_company"/>
<field eval="1" name="active"/>
<field name="calendar_id" ref="hr.timesheet_group1"/>
<field name="calendar_id" ref="resource.timesheet_group1"/>
<field name="resource_type">user</field>
</record>
@@ -271,7 +261,7 @@
<field eval="[(6,0,[])]" name="type_ids"/>
<field name="name">OpenERP Website Development</field>
</record>
<!-- Project Phases -->
<record id="project_phase_informationgatheringandunderstanding0" model="project.phase">
<field eval="[(6,0,[])]" name="previous_phase_ids"/>
@@ -284,7 +274,7 @@
<field name="responsible_id" ref="res_users_demouser1"/>
<field eval="10.0" name="duration"/>
<field name="project_id" ref="project_project_openerpwebsitedevelopment0"/>
<field name="constraint_date_start">2010-02-26 15:37:00</field>
<field name="constraint_date_start">2010-02-24 15:37:00</field>
<field name="date_end">2010-03-10 15:33:00</field>
</record>
@@ -293,7 +283,7 @@
<field name="name">Planning</field>
<field name="product_uom" ref="product.uom_day"/>
<field eval="10" name="sequence"/>
<field name="constraint_date_end">2010-02-18 15:49:00</field>
<field name="constraint_date_end">2010-03-25 15:49:00</field>
<field name="date_start">2010-02-18 15:48:00</field>
<field name="state">draft</field>
<field name="responsible_id" ref="res_users_manager0"/>
@@ -308,13 +298,13 @@
<field name="name">Web Design </field>
<field name="product_uom" ref="product.uom_day"/>
<field eval="10" name="sequence"/>
<field name="constraint_date_end">2010-04-10 16:08:00</field>
<field name="constraint_date_end">2010-04-15 16:08:00</field>
<field name="date_start">2010-04-01 16:02:00</field>
<field name="state">draft</field>
<field name="responsible_id" ref="res_users_userdesign0"/>
<field eval="10.0" name="duration"/>
<field name="project_id" ref="project_project_openerpwebsitedevelopment0"/>
<field name="constraint_date_start">2010-04-01 16:08:00</field>
<field name="constraint_date_start">2010-03-09 16:00:00</field>
<field name="date_end">2010-04-10 16:02:00</field>
</record>
@@ -329,7 +319,7 @@
<field name="responsible_id" ref="res_users_manager0"/>
<field eval="15.0" name="duration"/>
<field name="project_id" ref="project_project_openerpwebsitedevelopment0"/>
<field name="constraint_date_start">2010-04-14 16:11:00</field>
<field name="constraint_date_start">2010-03-10 16:11:00</field>
<field name="date_end">2010-04-26 16:10:00</field>
</record>
@@ -338,13 +328,13 @@
<field name="name">Website Deployment</field>
<field name="product_uom" ref="product.uom_day"/>
<field eval="10" name="sequence"/>
<field name="constraint_date_end">2010-04-28 16:35:00</field>
<field name="constraint_date_end">2010-04-30 16:35:00</field>
<field name="date_start">2010-04-26 16:35:00</field>
<field name="state">draft</field>
<field name="responsible_id" ref="res_users_manager0"/>
<field eval="2.0" name="duration"/>
<field name="project_id" ref="project_project_openerpwebsitedevelopment0"/>
<field name="constraint_date_start">2010-04-27 16:35:00</field>
<field name="constraint_date_start">2010-03-10 16:35:00</field>
<field name="date_end">2010-04-27 16:34:00</field>
</record>
@@ -402,7 +392,7 @@
<field name="phase_id" ref="project_phase_developmentintegrationandtesting0"/>
<field eval="50.0" name="useability"/>
</record>
<!-- Tasks -->
<record id="project_task_preparerequirementsdocument0" model="project.task">
<field eval="10" name="sequence"/>
+39 -1
View File
@@ -96,7 +96,7 @@
<field name="arch" type="xml">
<tree string="Project Phases">
<field name="name"/>
<field name="project_id"/>
<field name="project_id" on_change="onchange_project(project_id)"/>
<field name="date_start"/>
<field name="date_end"/>
<field name="duration"/>
@@ -112,6 +112,44 @@
<field name="view_type">form</field>
</record>
<record id="view_phase_project_form1" model="ir.ui.view">
<field name="name">phase.project.form1</field>
<field name="model">project.project</field>
<field name="type">form</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<field name="priority" position="before">
<field name="resource_calendar_id"/>
</field>
</field>
</record>
<record id="view_project_phase_task_form1" model="ir.ui.view">
<field name="name">project.phase.task.form1</field>
<field name="model">project.task</field>
<field name="type">form</field>
<field name="inherit_id" ref="project.view_task_form2"/>
<field name="arch" type="xml">
<field name="planned_hours" position="replace">
<field name="planned_hours" widget="float_time" attrs="{'readonly':[('state','!=','draft')]}" on_change="onchange_planned(project_id, user_id, planned_hours, effective_hours, date_start, occupation_rate)"/>
</field>
</field>
</record>
<record id="view_project_phase_task_form2" model="ir.ui.view">
<field name="name">project.phase.task.form2</field>
<field name="model">project.task</field>
<field name="type">form</field>
<field name="inherit_id" ref="project.view_task_form2"/>
<field name="arch" type="xml">
<field name="date_end" position = "after">
<field name="occupation_rate"/>
</field>
</field>
</record>
<act_window
id="project_phase_task_list"
name="Related Tasks"
+9 -1
View File
@@ -3,12 +3,20 @@
<data>
<wizard id="wizard_compute_phase" menu="False" model="project.phase" name="wizard.compute.phases" string="Compute Phase Scheduling"/>
<wizard id="wizard_schedule_task" menu="False" model="project.phase" name="phase.schedule.tasks" string="Schedule Tasks"/>
<menuitem id="base.menu_pm_planning" name="Planning" parent="base.menu_main" sequence="3"/>
<wizard id="wizard_compute_task" model="project.task" menu="False" name="wizard.compute.tasks" string="Compute Task Scheduling"/>
<menuitem id="base.menu_pm_planning" name="Planning" parent="base.menu_main" sequence="3"/>
<menuitem
action="wizard_compute_phase"
id="menu_wizard_compute_phase"
parent="base.menu_pm_planning"
type="wizard"
sequence="1"/>
<menuitem
action="wizard_compute_task"
id="menu_wizard_compute_task"
parent="base.menu_pm_planning"
type="wizard"
sequence="1"/>
</data>
</openerp>
@@ -20,7 +20,9 @@
##############################################################################
import compute_phases_date
import compute_tasks_date
import schedule_tasks
import project_resource
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -25,7 +25,7 @@ from tools.translate import _
import datetime
from resource.faces import *
from new import classobj
import project.project_resource as proj
import project_resource as proj
compute_form = """<?xml version="1.0" ?>
<form string="Compute Scheduling of Phases">
@@ -44,7 +44,7 @@ success_msg = """<?xml version="1.0" ?>
<label string="Phase Scheduling completed successfully."/>
</form>"""
def phase_schedule(cr,uid,phase,start_date,calendar_id=False):
def phase_schedule(cr, uid, phase, start_date, calendar_id=False):
pool = pooler.get_pool(cr.dbname)
phase_pool = pool.get('project.phase')
resource_pool = pool.get('resource.resource')
@@ -53,13 +53,13 @@ def phase_schedule(cr,uid,phase,start_date,calendar_id=False):
resource_cal = False
phase_resource = False
if phase:
resource_id = resource_pool.search(cr,uid,[('user_id','=',phase.responsible_id.id)])
resource_id = resource_pool.search(cr, uid, [('user_id','=',phase.responsible_id.id)])
if resource_id:
resource_obj = resource_pool.browse(cr,uid,resource_id)[0]
leaves = proj.leaves_resource(cr,uid,calendar_id or False ,resource_id,resource_obj.calendar_id.id)
phase_resource = classobj(str(resource_obj.name),(Resource,),{'__doc__':resource_obj.name,'__name__':resource_obj.name,'vacation':tuple(leaves),'efficiency':resource_obj.time_efficiency})
default_uom_id = uom_pool.search(cr,uid,[('name','=','Hour')])[0]
avg_hours = uom_pool._compute_qty(cr, uid, phase.product_uom.id, phase.duration,default_uom_id)
resource_obj = resource_pool.browse(cr, uid, resource_id)[0]
leaves = proj.leaves_resource(cr, uid, calendar_id or False , resource_id, resource_obj.calendar_id.id)
phase_resource = classobj(str(resource_obj.name), (Resource,), {'__doc__' : resource_obj.name, '__name__' : resource_obj.name, 'vacation' : tuple(leaves), 'efficiency' : resource_obj.time_efficiency})
default_uom_id = uom_pool.search(cr, uid, [('name','=','Hour')])[0]
avg_hours = uom_pool._compute_qty(cr, uid, phase.product_uom.id, phase.duration, default_uom_id)
duration = str(avg_hours) + 'H'
# Creating a new project for each phase
@@ -69,8 +69,8 @@ def phase_schedule(cr,uid,phase,start_date,calendar_id=False):
resource = phase_resource
# If project has working calendar else the default one would be considered
if calendar_id:
working_days = proj.compute_working_calendar(cr,uid,calendar_id)
vacation = tuple(proj.leaves_resource(cr,uid,calendar_id))
working_days = proj.compute_working_calendar(cr, uid, calendar_id)
vacation = tuple(proj.leaves_resource(cr, uid, calendar_id))
def phase():
effort = duration
@@ -78,26 +78,25 @@ def phase_schedule(cr,uid,phase,start_date,calendar_id=False):
project = BalancedProject(Project)
s_date = project.phase.start.to_datetime()
e_date = project.phase.end.to_datetime()
# According to constraints on date start and date end on phase recalculation done
if phase.constraint_date_start and str(s_date) < phase.constraint_date_start:
start_date = datetime.datetime.strptime(phase.constraint_date_start,'%Y-%m-%d %H:%M:%S')
start_date = datetime.datetime.strptime(phase.constraint_date_start, '%Y-%m-%d %H:%M:%S')
else:
start_date = s_date
if phase.constraint_date_end and str(e_date) > phase.constraint_date_end:
end_date= datetime.datetime.strptime(phase.constraint_date_end,'%Y-%m-%d %H:%M:%S')
end_date= datetime.datetime.strptime(phase.constraint_date_end, '%Y-%m-%d %H:%M:%S')
date_start = phase.constraint_date_end[:-3]
else:
end_date = e_date
date_start = end_date
# Writing the dates back
phase_pool.write(cr,uid,[phase.id],{'date_start':start_date.strftime('%Y-%m-%d %H:%M:%S'),'date_end':end_date.strftime('%Y-%m-%d %H:%M:%S')},context={'scheduler':True})
phase_pool.write(cr, uid, [phase.id], {'date_start' :start_date.strftime('%Y-%m-%d %H:%M:%S'), 'date_end' :end_date.strftime('%Y-%m-%d %H:%M:%S')}, context={'scheduler' :True})
# Recursive calling the next phases till all the phases are scheduled
for phase in phase.next_phase_ids:
if phase.state in ['draft','open','pending']:
phase_schedule(cr,uid,phase,date_start,phase.project_id.resource_calendar_id.id or False)
phase_schedule(cr, uid, phase, date_start, phase.project_id.resource_calendar_id.id or False)
else:
continue
@@ -111,22 +110,22 @@ class wizard_compute_phases(wizard.interface):
# if project mentioned
if data['form']['project_id']:
project_id = project_pool.browse(cr,uid,data['form']['project_id'])
phase_ids = phase_pool.search(cr,uid,[('project_id','=',project_id.id),('state','in',['draft','open','pending']),('previous_phase_ids','=',False)])
project_id = project_pool.browse(cr, uid, data['form']['project_id'])
phase_ids = phase_pool.search(cr, uid, [('project_id','=',project_id.id), ('state','in',['draft','open','pending']), ('previous_phase_ids','=',False)])
# else all the draft,open,pending states phases taken
else:
phase_ids = phase_pool.search(cr,uid,[('state','in',['draft','open','pending']),('previous_phase_ids','=',False)])
phase_ids = phase_pool.search(cr, uid,[('state','in',['draft','open','pending']), ('previous_phase_ids','=',False)])
phase_ids.sort()
phase_objs = phase_pool.browse(cr,uid,phase_ids)
phase_objs = phase_pool.browse(cr, uid, phase_ids)
for phase in phase_objs:
start_date = phase.project_id.date_start
if not phase.project_id.date_start:
start_date = datetime.datetime.now().strftime("%Y-%m-%d")
start_dt = datetime.datetime.strftime((datetime.datetime.strptime(start_date,"%Y-%m-%d")),"%Y-%m-%d %H:%M")
start_dt = datetime.datetime.strftime((datetime.datetime.strptime(start_date, "%Y-%m-%d")), "%Y-%m-%d %H:%M")
calendar_id = phase.project_id.resource_calendar_id.id
phase_schedule(cr,uid,phase,start_dt,calendar_id or False)
phase_schedule(cr, uid, phase, start_dt, calendar_id or False)
return {}
states = {
@@ -0,0 +1,150 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
from tools.translate import _
import datetime
from resource.faces import *
from new import classobj
import operator
import project_resource as proj
compute_form = """<?xml version="1.0" ?>
<form string="Compute Scheduling of Tasks">
<field name="project_id" colspan="4"/>
</form>"""
success_msg = """<?xml version="1.0" ?>
<form string="Compute Scheduling of Tasks">
<label string="Task Scheduling completed successfully."/>
</form>"""
compute_fields = {
'project_id': {'string':'Project', 'type':'many2one', 'relation': 'project.project', 'required':'True'},
}
class wizard_compute_tasks(wizard.interface):
def _compute_date(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
project_pool = pool.get('project.project')
task_pool = pool.get('project.task')
resource_pool = pool.get('resource.resource')
user_pool = pool.get('res.users')
project_id = data['form']['project_id']
project = project_pool.browse(cr, uid, project_id)
task_ids = task_pool.search(cr, uid, [('project_id','=',project_id), ('state','in',['draft','open','pending'])])
if task_ids:
wktime_cal = []
task_ids.sort()
task_obj = task_pool.browse(cr, uid, task_ids)
calendar_id = project.resource_calendar_id.id
start_date = project.date_start
if not project.date_start:
start_date = datetime.datetime.now().strftime("%Y-%m-%d")
date_start = datetime.datetime.strftime(datetime.datetime.strptime(start_date, "%Y-%m-%d"), "%Y-%m-%d %H:%M")
# To create resources which are the Project Members
resource_objs = []
for resource in project.members:
leaves = []
resource_id = resource_pool.search(cr, uid, [('user_id','=',resource.id)])
if resource_id:
resource_obj = resource_pool.browse(cr, uid, resource_id)[0]
leaves = proj.leaves_resource(cr, uid, calendar_id or False , resource_id, resource_obj.calendar_id.id)
resource_objs.append(classobj(str(resource.name), (Resource,), {'__doc__' : resource.name, '__name__' : resource.name, 'vacation' : tuple(leaves), 'efficiency' : resource_obj.time_efficiency}))
priority_dict = {'0' :1000, '1' :800, '2' :500, '3' :300,'4' :100}
# To create dynamic no of tasks with the resource specified
def tasks_resource(j, eff, priorty=500, obj=None):
def task():
"""
task is a dynamic method!
"""
effort = eff
if obj:
resource = obj
priority = priorty
task.__doc__ = "TaskNO%d" %j
task.__name__ = "task%d" %j
return task
# Creating the project with all the tasks and resources
def Project():
title = project.name
start = date_start
resource = reduce(operator.or_, resource_objs)
minimum_time_unit = 1
# If project has calendar
if calendar_id:
working_days = proj.compute_working_calendar(cr, uid, calendar_id)
vacation = tuple(proj.leaves_resource(cr, uid, calendar_id))
# Dynamic Creation of tasks
i = 0
for each_task in task_obj:
hours = str(each_task.planned_hours / each_task.occupation_rate)+ 'H'
if each_task.priority in priority_dict.keys():
priorty = priority_dict[each_task.priority]
if each_task.user_id:
for resource_object in resource_objs:
if resource_object.__name__ == each_task.user_id.name:
task = tasks_resource(i, hours, priorty, resource_object)
else:
task = tasks_resource(i, hours, priorty)
i += 1
# Writing back the dates
project = BalancedProject(Project)
loop_no = 0
for t in project:
s_date = t.start.to_datetime()
e_date = t.end.to_datetime()
if loop_no == 0:
project_pool.write(cr, uid, [project_id], {'date' : e_date})
else:
user_id = user_pool.search(cr, uid, [('name','=',t.booked_resource[0].__name__)])
task_pool.write(cr, uid, [task_obj[loop_no-1].id], {'date_start' :s_date.strftime('%Y-%m-%d %H:%M:%S'), 'date_deadline' :e_date.strftime('%Y-%m-%d %H:%M:%S'), 'user_id' :user_id[0]}, context={'scheduler' :True})
loop_no +=1
return {}
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':compute_form, 'fields':compute_fields, 'state':[
('end', 'Cancel'),
('compute', 'Compute')
]},
},
'compute': {
'actions': [_compute_date],
'result': {'type':'form','arch':success_msg,'fields':{}, 'state':[('end', 'Ok')]},
}
}
wizard_compute_tasks('wizard.compute.tasks')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,81 @@
import pooler
import datetime
def timeformat_convert(cr, uid, time_string, context={}):
# Function to convert input time string:: 8.5 to output time string 8:30
split_list = str(time_string).split('.')
hour_part = split_list[0]
mins_part = split_list[1]
round_mins = int(round(float(mins_part) * 60,-2))
converted_string = hour_part + ':' + str(round_mins)[0:2]
return converted_string
def leaves_resource(cr, uid, calendar_id, resource_id=False, resource_calendar=False):
# To get the leaves for the resource_ids working on phase
pool = pooler.get_pool(cr.dbname)
resource_leaves_pool = pool.get('resource.calendar.leaves')
leaves = []
if resource_id:
resource_leave_ids = resource_leaves_pool.search(cr, uid, ['|', ('calendar_id','=',calendar_id), ('calendar_id','=',resource_calendar), ('resource_id','=',resource_id)])
else:
resource_leave_ids = resource_leaves_pool.search(cr, uid, [('calendar_id','=',calendar_id), ('resource_id','=',False)])
res_leaves = resource_leaves_pool.read(cr, uid, resource_leave_ids, ['date_from', 'date_to'])
for leave in range(len(res_leaves)):
dt_start = datetime.datetime.strptime(res_leaves[leave]['date_from'], '%Y-%m-%d %H:%M:%S')
dt_end = datetime.datetime.strptime(res_leaves[leave]['date_to'], '%Y-%m-%d %H:%M:%S')
no = dt_end - dt_start
[leaves.append((dt_start + datetime.timedelta(days=x)).strftime('%Y-%m-%d')) for x in range(int(no.days + 1))]
leaves.sort()
return leaves
def compute_working_calendar(cr, uid, calendar_id):
# To change the format of working calendar to bring it into 'faces' format
pool = pooler.get_pool(cr.dbname)
resource_week_pool = pool.get('resource.calendar.week')
time_range = "8:00-8:00"
non_working = ""
wk = {"0":"mon","1":"tue","2":"wed","3":"thu","4":"fri","5":"sat","6":"sun"}
wk_days = {}
wk_time = {}
wktime_list = []
wktime_cal = []
week_ids = resource_week_pool.search(cr, uid, [('calendar_id','=',calendar_id)])
week_obj = resource_week_pool.read(cr, uid, week_ids, ['dayofweek', 'hour_from', 'hour_to'])
# Converting time formats into appropriate format required
# and creating a list like [('mon', '8:00-12:00'), ('mon', '13:00-18:00')]
for week in week_obj:
res_str = ""
if wk.has_key(week['dayofweek']):
day = wk[week['dayofweek']]
wk_days[week['dayofweek']] = wk[week['dayofweek']]
hour_from_str = timeformat_convert(cr, uid, week['hour_from'])
hour_to_str = timeformat_convert(cr, uid, week['hour_to'])
res_str = hour_from_str + '-' + hour_to_str
wktime_list.append((day, res_str))
# Converting it to format like [('mon', '8:00-12:00', '13:00-18:00')]
for item in wktime_list:
if wk_time.has_key(item[0]):
wk_time[item[0]].append(item[1])
else:
wk_time[item[0]] = [item[0]]
wk_time[item[0]].append(item[1])
for k,v in wk_time.items():
wktime_cal.append(tuple(v))
# For non working days adding [('tue,wed,fri,sat,sun', '8:00-8:00')]
for k,v in wk_days.items():
if wk.has_key(k):
wk.pop(k)
for v in wk.itervalues():
non_working += v + ','
if non_working:
wktime_cal.append((non_working[:-1], time_range))
return wktime_cal
@@ -27,14 +27,14 @@ from resource.faces import *
from new import classobj
import operator
import time
import project.project_resource as proj
import project_resource as proj
success_msg = """<?xml version="1.0" ?>
<form string="Compute Scheduling of Tasks">
<label string="Task Scheduling completed successfully."/>
</form>"""
def resource_list(cr,uid,phase):
def resource_list(cr, uid, phase):
# To create resources which are the Project Members
resource_objs = []
@@ -43,9 +43,9 @@ def resource_list(cr,uid,phase):
leaves = []
resource_eff = res.time_efficiency
resource_cal = res.calendar_id.id
wktime_cal = proj.compute_working_calendar(cr,uid,resource_cal)
leaves = proj.leaves_resource(cr,uid,phase.project_id.resource_calendar_id.id or False ,res.id,resource_cal)
resource_objs.append(classobj(str(res.user_id.name),(Resource,),{'__doc__':res.user_id.name,'__name__':res.user_id.name,'vacation':tuple(leaves),'efficiency':resource_eff}))
wktime_cal = proj.compute_working_calendar(cr, uid, resource_cal)
leaves = proj.leaves_resource(cr, uid, phase.project_id.resource_calendar_id.id or False , res.id, resource_cal)
resource_objs.append(classobj(str(res.user_id.name), (Resource,), {'__doc__' : res.user_id.name, '__name__' : res.user_id.name, 'vacation' : tuple(leaves), 'efficiency' : resource_eff}))
return resource_objs
class wizard_schedule_task(wizard.interface):
@@ -55,12 +55,12 @@ class wizard_schedule_task(wizard.interface):
phase_pool = pool.get('project.phase')
task_pool = pool.get('project.task')
user_pool = pool.get('res.users')
phase = phase_pool.browse(cr,uid,data['id'])
task_ids = map(lambda x:x.id,(filter(lambda x:x.state in ['open','draft','pending'] ,phase.task_ids)))
phase = phase_pool.browse(cr, uid, data['id'])
task_ids = map(lambda x : x.id, (filter(lambda x : x.state in ['open','draft','pending'] , phase.task_ids)))
if task_ids:
task_ids.sort()
tasks = task_pool.browse(cr,uid,task_ids)
tasks = task_pool.browse(cr, uid, task_ids)
wktime_cal = []
start_date = str(phase.date_start)[:-9]
if not phase.date_start:
@@ -68,13 +68,13 @@ class wizard_schedule_task(wizard.interface):
start_date = datetime.datetime.now().strftime("%Y-%m-%d")
else:
start_date = phase.project_id.date_start
date_start = datetime.datetime.strftime(datetime.datetime.strptime(start_date,"%Y-%m-%d"),"%Y-%m-%d %H:%M")
date_start = datetime.datetime.strftime(datetime.datetime.strptime(start_date, "%Y-%m-%d"), "%Y-%m-%d %H:%M")
calendar_id = phase.project_id.resource_calendar_id.id
resource_objs = resource_list(cr,uid,phase)
priority_dict = {'0':1000,'1':800,'2':500,'3':300,'4':100}
resource_objs = resource_list(cr, uid, phase)
priority_dict = {'0' :1000,'1' :800,'2' :500,'3' :300,'4' :100}
# To create dynamic no of tasks with the resource specified
def tasks_resource(j,eff,priorty = 500,obj=False):
def tasks_resource(j, eff, priorty=500, obj=False):
def task():
"""
task is a dynamic method!
@@ -91,13 +91,13 @@ class wizard_schedule_task(wizard.interface):
def Project():
title = "Test Project"
start = date_start
resource = reduce(operator.or_,resource_objs)
resource = reduce(operator.or_, resource_objs)
minimum_time_unit = 1
# If project has calendar
if calendar_id:
working_days = proj.compute_working_calendar(cr,uid,calendar_id)
vacation = tuple(proj.leaves_resource(cr,uid,calendar_id))
working_days = proj.compute_working_calendar(cr, uid, calendar_id)
vacation = tuple(proj.leaves_resource(cr, uid, calendar_id))
# Dynamic Creation of tasks
i = 0
@@ -108,9 +108,9 @@ class wizard_schedule_task(wizard.interface):
if each_task.user_id:
for resource_object in resource_objs:
if resource_object.__name__ == each_task.user_id.name:
task = tasks_resource(i,hours,priorty,resource_object)
task = tasks_resource(i, hours, priorty, resource_object)
else:
task = tasks_resource(i,hours,priorty)
task = tasks_resource(i, hours, priorty)
i += 1
# Writing back the dates
@@ -120,8 +120,8 @@ class wizard_schedule_task(wizard.interface):
s_date = t.start.to_datetime()
e_date = t.end.to_datetime()
if loop_no > 0:
user_id = user_pool.search(cr,uid,[('name','=',t.booked_resource[0].__name__)])
task_pool.write(cr,uid,[tasks[loop_no-1].id],{'date_start':s_date.strftime('%Y-%m-%d %H:%M:%S'),'date_deadline':e_date.strftime('%Y-%m-%d %H:%M:%S'),'user_id':user_id[0]},context={'scheduler':True})
user_id = user_pool.search(cr, uid, [('name','=',t.booked_resource[0].__name__)])
task_pool.write(cr, uid, [tasks[loop_no-1].id], {'date_start' :s_date.strftime('%Y-%m-%d %H:%M:%S'), 'date_deadline' :e_date.strftime('%Y-%m-%d %H:%M:%S'), 'user_id' :user_id[0]}, context={'scheduler' :True})
loop_no +=1
return {}
+2 -2
View File
@@ -286,7 +286,7 @@ Business Days - (Time Allocation of Tasks + Time Allocation without Tasks + Holi
cr.execute(""" CREATE OR REPLACE VIEW report_account_analytic_planning_user AS (
SELECT
planning.id AS planning_id,
planning.id::varchar(32) || '-' || COALESCE(users.id,0)::varchar(32) AS id,
(1000*(planning.id) + users.id)::integer AS id,
planning.business_days,
users.id AS user_id,
(SELECT sum(line1.amount_in_base_uom)
@@ -330,7 +330,7 @@ Business Days - (Time Allocation of Tasks + Time Allocation without Tasks + Holi
SELECT
planning.id AS planning_id,
planning.id::varchar(32) || '-' || '0' AS id,
(1000*(planning.id) - 1)::integer AS id,
planning.business_days,
line.user_id,
(SELECT SUM(line1.amount_in_base_uom)
+3 -3
View File
@@ -24,13 +24,13 @@
'name': 'CRM Management - Reporting',
'version': '1.0',
'category': 'Generic Modules/CRM & SRM',
'description': """A module that adds new reports based on CRM cases.
Case By section, Case By category""",
'description': """A module that adds new reports based on Leads, Opportunities, Phonecalls, Claims, FunRising.
""",
'author': 'Tiny',
'website': 'http://www.openerp.com',
'depends': ['crm'],
'init_xml': [],
'update_xml': ['security/ir.model.access.csv',
'update_xml': [#'security/ir.model.access.csv',
'report_crm_view.xml',
'report_crm_lead_view.xml',
'report_crm_claim_view.xml',
+38 -198
View File
@@ -30,24 +30,56 @@ AVAILABLE_STATES = [
('pending','Pending')
]
class report_crm_case_user(osv.osv):
_name = "report.crm.case.user"
_description = "Cases by user and section"
class report_crm_case(osv.osv):
_name = "report.crm.case"
_description = "Cases and section"
_auto = False
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_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
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_cases
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, 'Status', 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),
}
_order = 'name desc, user_id'
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_crm_case_user')
tools.drop_view_if_exists(cr, 'report_crm_case')
cr.execute("""
create or replace view report_crm_case_user as (
create or replace view report_crm_case as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
@@ -60,68 +92,7 @@ class report_crm_case_user(osv.osv):
crm_case 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_case_user()
class report_crm_case_categ(osv.osv):
_name = "report.crm.case.categ"
_description = "Cases by section and category"
_auto = False
_columns = {
'name': fields.char('Year',size=64,required=False, 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),
'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),
}
_order = 'name desc'
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_crm_case_categ')
cr.execute("""
create or replace view report_crm_case_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.state,
c.section_id,
count(*) as nbr
from
crm_case c
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state,c.section_id
)""")
report_crm_case_categ()
class report_crm_case_section(osv.osv):
_name = "report.crm.case.section"
_description = "Cases by Section"
_auto = False
_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_cases': fields.integer('# of Cases', readonly=True),
'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),
}
_order = 'name desc'
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_crm_case_section')
cr.execute("""
create or replace view report_crm_case_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
from
crm_case c
group by to_char(c.create_date, 'YYYY'),to_char(c.create_date, 'MM'), c.section_id
)""")
report_crm_case_section()
report_crm_case()
class report_crm_case_service_dashboard(osv.osv):
_name = "report.crm.case.service.dashboard"
@@ -157,137 +128,6 @@ class report_crm_case_service_dashboard(osv.osv):
)""")
report_crm_case_service_dashboard()
class report_crm_case_section_stage(osv.osv):
_name = "report.crm.case.section.stage"
_description = "Cases by section and stage"
_auto = False
_columns = {
'name': fields.char('Year',size=64,required=False, readonly=True),
'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),
'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),
}
_order = 'section_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_case_section_stage")
cr.execute("""
create view report_crm_case_section_stage as (
select
min(c.id) as id,
to_char(c.create_date,'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.state,
c.section_id,
count(*) as nbr
from
crm_case c
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.user_id, c.state, c.section_id)""")
report_crm_case_section_stage()
class report_crm_case_section_type(osv.osv):
_name = "report.crm.case.section.type"
_description = "Cases by Section and Type"
_auto = False
_columns = {
'name': fields.char('Year',size=64,required=False, readonly=True),
'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),
'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),
}
_order = 'section_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_case_section_type")
cr.execute("""
create view report_crm_case_section_type as (
select
min(c.id) as id,
to_char(c.create_date,'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.state,
c.section_id,
count(*) as nbr
from
crm_case c
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.user_id, c.section_id, c.state)""")
report_crm_case_section_type()
class report_crm_case_section_categ_stage(osv.osv):
_name = "report.crm.case.section.categ.stage"
_description = "Cases by Section, Category and Stage"
_auto = False
_columns = {
'name': fields.char('Year',size=64,required=False, readonly=True),
'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),
'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),
}
_order = 'section_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_case_section_categ_stage")
cr.execute("""
create view report_crm_case_section_categ_stage as (
select
min(c.id) as id,
to_char(c.create_date,'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.state,
c.section_id,
count(*) as nbr
from
crm_case c
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),c.user_id, c.state, c.section_id)""")
report_crm_case_section_categ_stage()
class report_crm_case_section_categ_type(osv.osv):
_name = "report.crm.case.section.categ.type"
_description = "Cases by Section, Category and Type"
_auto = False
_columns = {
'name': fields.char('Year',size=64,required=False, readonly=True),
'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),
'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),
}
_order = 'section_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_case_section_categ_type")
cr.execute("""
create view report_crm_case_section_categ_type as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.state,
c.section_id,
count(*) as nbr
from
crm_case c
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),c.user_id, c.state, c.section_id)""")
report_crm_case_section_categ_type()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+11 -211
View File
@@ -1,237 +1,37 @@
from osv import fields,osv
import tools
class report_crm_claim_user(osv.osv):
_name = "report.crm.claim.user"
_description = "Claim by user and section"
class report_crm_claim(osv.osv):
_name = "report.crm.claim"
_auto = False
_inherit = "report.crm.case.user"
_inherit = "report.crm.case"
_columns = {
'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),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.claim')]", readonly=True),
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.claim')]"),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_crm_claim_user')
tools.drop_view_if_exists(cr, 'report_crm_claim')
cr.execute("""
create or replace view report_crm_claim_user as (
create or replace view report_crm_claim as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.state,
c.user_id,
c.stage_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_claim 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_claim_user()
class report_crm_claim_categ(osv.osv):
_name = "report.crm.claim.categ"
_description = "Claim 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.claim')]"),
'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_claim_categ')
cr.execute("""
create or replace view report_crm_claim_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,
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_claim c
group by c.categ_id,to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state,c.section_id
)""")
report_crm_claim_categ()
class report_crm_claim_section(osv.osv):
_name = "report.crm.claim.section"
_description = "Claim 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_claim 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_claim_section')
cr.execute("""
create or replace view report_crm_claim_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_claim c
group by to_char(c.create_date, 'YYYY'),to_char(c.create_date, 'MM'),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.stage_id,c.categ_id
)""")
report_crm_claim_section()
report_crm_claim()
class report_crm_claim_section_type(osv.osv):
_name = "report.crm.claim.section.type"
_inherit = "report.crm.case.section.type"
_description = "Claims by section and type"
_auto = False
_columns = {
'type_id': fields.many2one('crm.case.resource.type', 'Claim Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.claim')]", readonly=True),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.claim')]", readonly=True),
'amount_revenue': fields.float('Est.Revenue', readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'type_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_claim_section_type")
cr.execute("""
create view report_crm_claim_section_type as (
select
min(c.id) as id,
to_char(c.create_date,'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.state,
c.type_id,
c.stage_id,
c.section_id,
count(*) as nbr,
sum(planned_revenue) as amount_revenue,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_claim c
where c.type_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.user_id, c.state, c.stage_id, c.type_id, c.section_id)""")
report_crm_claim_section_type()
class report_crm_claim_section_categ_stage(osv.osv):
_name = "report.crm.claim.section.categ.stage"
_inherit = "report.crm.case.section.categ.stage"
_description = "Claims by Section, Category and Stage"
_auto = False
_columns = {
'categ_id': fields.many2one('crm.case.categ','Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.claim')]", readonly=True),
'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.claim')]", readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'stage_id, categ_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_claim_section_categ_stage")
cr.execute("""
create view report_crm_claim_section_categ_stage as (
select
min(c.id) as id,
to_char(c.create_date,'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.categ_id,
c.state,
c.stage_id,
c.section_id,
count(*) as nbr,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_claim c
where c.categ_id is not null AND c.stage_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),c.user_id, c.categ_id, c.state, c.stage_id, c.section_id)""")
report_crm_claim_section_categ_stage()
class report_crm_claim_section_categ_type(osv.osv):
_name = "report.crm.claim.section.categ.type"
_inherit = "report.crm.case.section.categ.type"
_description = "Claims by Section, Category and Type"
_auto = False
_columns = {
'categ_id':fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.claim')]", readonly=True),
'type_id': fields.many2one('crm.case.resource.type', 'Claim Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.claim')]", readonly=True),
'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.claim')]", readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'categ_id, type_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_claim_section_categ_type")
cr.execute("""
create view report_crm_claim_section_categ_type as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.categ_id,
c.type_id,
c.state,
c.stage_id,
c.section_id,
count(*) as nbr,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_claim c
where c.categ_id is not null AND c.type_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),c.user_id, c.categ_id, c.type_id, c.state, c.stage_id, c.section_id)""")
report_crm_claim_section_categ_type()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+52 -386
View File
@@ -1,29 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--
Claim by user and section
-->
<data>
<record id="view_crm_claim_user_tree" model="ir.ui.view">
<field name="name">report.crm.claim.user.tree</field>
<field name="model">report.crm.claim.user</field>
<field name="inherit_id" ref="view_crm_case_user_tree"/>
<record id="view_report_crm_claim_tree" model="ir.ui.view">
<field name="name">report.crm.claim.tree</field>
<field name="model">report.crm.claim</field>
<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>
<tree string="Claims">
<field name="name" />
<field name="month"/>
<field name="nbr" string="#Claim"/>
<field name="delay_close"/>
<field name="state" invisible="1"/>
<field name="section_id" invisible="1"/>
<field name="stage_id" invisible="1"/>
<field name="user_id" invisible="1"/>
<field name="categ_id" invisible="1"/>
</tree>
</field>
</record>
<record id="view_crm_claim_user_form" model="ir.ui.view">
<field name="name">report.crm.claim.user.form</field>
<field name="model">report.crm.claim.user</field>
<field name="inherit_id" ref="view_crm_case_user_form"/>
<record id="view_crm_claim_form" model="ir.ui.view">
<field name="name">report.crm.claim.form</field>
<field name="model">report.crm.claim</field>
<field name="inherit_id" ref="view_crm_case_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
@@ -36,12 +36,12 @@
</field>
</record>
<record id="view_crm_claim_user_graph" model="ir.ui.view">
<field name="name">report.crm.claim.user.graph</field>
<field name="model">report.crm.claim.user</field>
<record id="view_crm_claim_graph" model="ir.ui.view">
<field name="name">report.crm.claim.graph</field>
<field name="model">report.crm.claim</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Claims by User and Section" type="bar">
<graph orientation="horizontal" string="Claims" type="bar">
<field name="state"/>
<field name="nbr" operator="+"/>
<field group="True" name="user_id"/>
@@ -49,379 +49,45 @@
</field>
</record>
<record id="view_crm_claim_user_filter" model="ir.ui.view">
<field name="name">report.crm.claim.user.select</field>
<field name="model">report.crm.claim.user</field>
<field name="inherit_id" ref="view_crm_case_user_filter"/>
<record id="view_crm_claim_filter" model="ir.ui.view">
<field name="name">report.crm.claim.select</field>
<field name="model">report.crm.claim</field>
<field name="inherit_id" ref="view_crm_case_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="state" position="before">
<field name="user_id" position="before">
</field>
</field>
</record>
<record id="action_report_crm_claim_user_tree" model="ir.actions.act_window">
<field name="name">Claim by User and Section</field>
<field name="res_model">report.crm.claim.user</field>
<record id="action_report_crm_claim" model="ir.actions.act_window">
<field name="name">Claims</field>
<field name="res_model">report.crm.claim</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_crm_claim_user_graph"/>
<field name="search_view_id" ref="view_crm_claim_user_filter"/>
<field name="view_id" ref="view_crm_claim_graph"/>
<field name="search_view_id" ref="view_crm_claim_filter"/>
</record>
<menuitem name="Claim" id="menu_crm_claim_tree" parent="crm.next_id_52"/>
<menuitem action="action_report_crm_claim_user_tree" id="menu_crm_claim_user_tree" parent="menu_crm_claim_tree"/>
<record model="ir.actions.act_window.view" id="action_report_crm_claim_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_report_crm_claim_tree"/>
<field name="act_window_id" ref="action_report_crm_claim"/>
</record>
<record model="ir.actions.act_window.view" id="action_report_crm_claim_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_claim_graph"/>
<field name="act_window_id" ref="action_report_crm_claim"/>
</record>
<!-- # Claims by section and category of case -->
<menuitem name="Claims" id="menu_crm_claim_tree" action="action_report_crm_claim" parent="base.next_id_64"/>
<record id="view_crm_claim_categ_tree" model="ir.ui.view">
<field name="name">report.crm.claim.categ.tree</field>
<field name="model">report.crm.claim.categ</field>
<field name="inherit_id" ref="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_claim_categ_form" model="ir.ui.view">
<field name="name">report.crm.claim.categ.form</field>
<field name="model">report.crm.claim.categ</field>
<field name="inherit_id" ref="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_claim_categ_graph" model="ir.ui.view">
<field name="name">report.crm.claim.categ.graph</field>
<field name="model">report.crm.claim.categ</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Claims 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_claim_categ_filter" model="ir.ui.view">
<field name="name">report.crm.claim.categ.select</field>
<field name="model">report.crm.claim.categ</field>
<field name="inherit_id" ref="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_claim_categ_tree" model="ir.actions.act_window">
<field name="name">Claims by Categories and Section</field>
<field name="res_model">report.crm.claim.categ</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_crm_claim_categ_graph"/>
<field name="search_view_id" ref="view_crm_claim_categ_filter"/>
</record>
<menuitem action="action_report_crm_claim_categ_tree" id="menu_crm_claim_categ_tree" parent="menu_crm_claim_tree"/>
<!-- Claim by Section -->
<record id="view_report_crm_claim_section_tree" model="ir.ui.view">
<field name="name">report.crm.claim.section.tree</field>
<field name="model">report.crm.claim.section</field>
<field name="inherit_id" ref="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_claim_section_graph" model="ir.ui.view">
<field name="name">report.crm.claim.section.graph</field>
<field name="model">report.crm.claim.section</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="claims by Section" type="bar">
<field name="name"/>
<field name="nbr_cases" operator="+"/>
</graph>
</field>
</record>
<record id="view_report_crm_claim_section_filter" model="ir.ui.view">
<field name="name">report.crm.claim.section.select</field>
<field name="model">report.crm.claim.section</field>
<field name="inherit_id" ref="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_claim_section_tree" model="ir.actions.act_window">
<field name="name">Claims by Section</field>
<field name="res_model">report.crm.claim.section</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_report_crm_claim_section_graph"/>
<field name="search_view_id" ref="view_report_crm_claim_section_filter"/>
</record>
<menuitem action="action_report_crm_claim_section_tree" id="menu_crm_claim_section_tree" parent="menu_crm_claim_tree"/>
#
# Claims by section and type
#
<record model="ir.ui.view" id="view_crm_claim_section_categ_tree">
<field name="name">CRM Report - Sections and Type(Tree)</field>
<field name="model">report.crm.claim.section.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="type_id"/>
<field name="stage_id"/>
<field name="amount_revenue"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_claim_section_categ_form">
<field name="name">CRM Report - Sections and Type(Form)</field>
<field name="model">report.crm.claim.section.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="type_id"/>
<field name="stage_id"/>
<field name="amount_revenue"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_claim_section_categ_graph">
<field name="name">CRM Report - Sections and Type(Graph)</field>
<field name="model">report.crm.claim.section.type</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Cases by Section and Type" type="bar" orientation="horizontal">
<field name="type_id"/>
<field name="amount_revenue" operator="+"/>
<field name="section_id" group="True"/>
</graph>
</field>
</record>
<record id="view_crm_claim_section_categ_filter" model="ir.ui.view">
<field name="name">CRM Report - Sections and Type(Select)</field>
<field name="model">report.crm.claim.section.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="section_id" position="after">
<field name="type_id"/>
</field>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_claim_section_categ_tree">
<field name="res_model">report.crm.claim.section.type</field>
<field name="name">Claims by section and type</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="search_view_id" ref="view_crm_claim_section_categ_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_claim_section_categ_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_claim_section_categ_graph"/>
<field name="act_window_id" ref="action_report_crm_claim_section_categ_tree"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_claim_section_categ_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_claim_section_categ_tree"/>
<field name="act_window_id" ref="action_report_crm_claim_section_categ_tree"/>
</record>
<menuitem action="action_report_crm_claim_section_categ_tree" id="menu_crm_claim_section_categ_tree" parent="menu_crm_claim_tree"/>
#
# Claims by section, category and stage
#
<record model="ir.ui.view" id="view_crm_claim_section_categ_stage_tree">
<field name="name">CRM Report - Section, Category and Stage(Tree)</field>
<field name="model">report.crm.claim.section.categ.stage</field>
<field name="inherit_id" ref="view_crm_case_section_categ_stage_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_claim_section_categ_stage_form">
<field name="name">CRM Report - Section, Category and Stage(Form)</field>
<field name="model">report.crm.claim.section.categ.stage</field>
<field name="inherit_id" ref="view_crm_case_section_categ_stage_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_claim_section_categ_stage_graph">
<field name="name">CRM Report - Section, Category and Stage(Select)</field>
<field name="model">report.crm.claim.section.categ.stage</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Claims by Section, Category and Stage" type="bar" orientation="horizontal">
<field name="categ_id"/>
<field name="nbr" operator="+"/>
<field name="section_id" group="True"/>
</graph>
</field>
</record>
<record id="view_crm_claim_section_categ_stage_filter" model="ir.ui.view">
<field name="name">CRM Report - Section, Category and Stage(Select)</field>
<field name="model">report.crm.claim.section.categ.stage</field>
<field name="inherit_id" ref="view_crm_case_section_categ_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="section_id" position="after">
<field name="categ_id"/>
<field name="stage_id"/>
</field>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_claim_section_categ_stage_tree">
<field name="res_model">report.crm.claim.section.categ.stage</field>
<field name="name">Claims by section, category and stage</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="search_view_id" ref="view_crm_claim_section_categ_stage_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_claim_section_categ_stage_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_claim_section_categ_stage_graph"/>
<field name="act_window_id" ref="action_report_crm_claim_section_categ_stage_tree"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_claim_section_categ_stage_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_claim_section_categ_stage_tree"/>
<field name="act_window_id" ref="action_report_crm_claim_section_categ_stage_tree"/>
</record>
<menuitem action="action_report_crm_claim_section_categ_stage_tree" id="menu_crm_claim_section_categ_stage_tree" parent="menu_crm_claim_tree"/>
#
# Claims by section, category and type
#
<record model="ir.ui.view" id="view_crm_claim_section_categ_type_tree">
<field name="name">CRM Report - Section, Category and Type(Tree)</field>
<field name="model">report.crm.claim.section.categ.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_type_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="type_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_claim_section_categ_type_form">
<field name="name">CRM Report - Section, Category and Type(Form)</field>
<field name="model">report.crm.claim.section.categ.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_type_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="type_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_claim_section_categ_type_graph">
<field name="name">CRM Report - Section, Category and Type(Select)</field>
<field name="model">report.crm.claim.section.categ.type</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Claims by Section, Category and Type" type="bar" orientation="horizontal">
<field name="type_id"/>
<field name="nbr" operator="+"/>
<field name="section_id" group="True"/>
</graph>
</field>
</record>
<record id="view_crm_claim_section_categ_type_filter" model="ir.ui.view">
<field name="name">CRM Report - Section, Category and Type(Select)</field>
<field name="model">report.crm.claim.section.categ.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_type_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="section_id" position="after">
<field name="categ_id" select="1"/>
<field name="type_id" select="1"/>
<field name="stage_id" select="1"/>
</field>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_claim_section_categ_type_tree">
<field name="res_model">report.crm.claim.section.categ.type</field>
<field name="name">Claims by section, category and type</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="search_view_id" ref="view_crm_claim_section_categ_type_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_claim_section_categ_type_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_claim_section_categ_type_graph"/>
<field name="act_window_id" ref="action_report_crm_claim_section_categ_type_tree"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_claim_section_categ_type_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_claim_section_categ_type_tree"/>
<field name="act_window_id" ref="action_report_crm_claim_section_categ_type_tree"/>
</record>
<menuitem action="action_report_crm_claim_section_categ_type_tree" id="menu_crm_claim_section_categ_type_tree" parent="menu_crm_claim_tree"/>
</data>
</openerp>
</openerp>
+14 -208
View File
@@ -1,12 +1,13 @@
from osv import fields,osv
import tools
class report_crm_fundraising_user(osv.osv):
_name = "report.crm.fundraising.user"
_description = "Fundraising by user and section"
class report_crm_fundraising(osv.osv):
_name = "report.crm.fundraising"
_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.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),
@@ -14,9 +15,9 @@ class report_crm_fundraising_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_fundraising_user')
tools.drop_view_if_exists(cr, 'report_crm_fundraising')
cr.execute("""
create or replace view report_crm_fundraising_user as (
create or replace view report_crm_fundraising as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
@@ -24,214 +25,19 @@ class report_crm_fundraising_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_fundraising 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_fundraising_user()
class report_crm_fundraising_categ(osv.osv):
_name = "report.crm.fundraising.categ"
_description = "Fundraising 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.fundraising')]"),
'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_fundraising_categ')
cr.execute("""
create or replace view report_crm_fundraising_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,
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_fundraising c
group by c.categ_id,to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state,c.section_id
)""")
report_crm_fundraising_categ()
class report_crm_fundraising_section(osv.osv):
_name = "report.crm.fundraising.section"
_description = "Fundraising 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_fundraising 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_fundraising_section')
cr.execute("""
create or replace view report_crm_fundraising_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,
sum(planned_revenue) as amount_revenue,
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_fundraising c
group by to_char(c.create_date, 'YYYY'),to_char(c.create_date, 'MM'),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_fundraising_section()
class report_crm_fundraising_section_type(osv.osv):
_name = "report.crm.fundraising.section.type"
_inherit = "report.crm.case.section.type"
_description = "Fundraising by section and type"
_auto = False
_columns = {
'type_id': fields.many2one('crm.case.resource.type', 'Fundraising Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]", readonly=True),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]", readonly=True),
'amount_revenue': fields.float('Est.Revenue', readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'type_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_fundraising_section_type")
cr.execute("""
create view report_crm_fundraising_section_type as (
select
min(c.id) as id,
to_char(c.create_date,'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.state,
c.type_id,
c.stage_id,
c.section_id,
count(*) as nbr,
sum(planned_revenue) as amount_revenue,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_fundraising c
where c.type_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.user_id, c.state, c.stage_id, c.type_id, c.section_id)""")
report_crm_fundraising_section_type()
class report_crm_fundraising_section_categ_stage(osv.osv):
_name = "report.crm.fundraising.section.categ.stage"
_inherit = "report.crm.case.section.categ.stage"
_description = "Fundraising by Section, Category and Stage"
_auto = False
_columns = {
'categ_id': fields.many2one('crm.case.categ','Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]", readonly=True),
'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]", readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'stage_id, categ_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_fundraising_section_categ_stage")
cr.execute("""
create view report_crm_fundraising_section_categ_stage as (
select
min(c.id) as id,
to_char(c.create_date,'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.categ_id,
c.state,
c.stage_id,
c.section_id,
count(*) as nbr,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_fundraising c
where c.categ_id is not null AND c.stage_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),c.user_id, c.categ_id, c.state, c.stage_id, c.section_id)""")
report_crm_fundraising_section_categ_stage()
class report_crm_fundraising_section_categ_type(osv.osv):
_name = "report.crm.fundraising.section.categ.type"
_inherit = "report.crm.case.section.categ.type"
_description = "Fundraising by Section, Category and Type"
_auto = False
_columns = {
'categ_id':fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]", readonly=True),
'type_id': fields.many2one('crm.case.resource.type', 'Fundraising Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]", readonly=True),
'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]", readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'categ_id, type_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_fundraising_section_categ_type")
cr.execute("""
create view report_crm_fundraising_section_categ_type as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.categ_id,
c.type_id,
c.state,
c.stage_id,
c.section_id,
count(*) as nbr,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_fundraising c
where c.categ_id is not null AND c.type_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),c.user_id, c.categ_id, c.type_id, c.state, c.stage_id, c.section_id)""")
report_crm_fundraising_section_categ_type()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
report_crm_fundraising()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+51 -381
View File
@@ -5,25 +5,32 @@
Fundraising by user and section
-->
<record id="view_crm_fundraising_user_tree" model="ir.ui.view">
<field name="name">report.crm.fundraising.user.tree</field>
<field name="model">report.crm.fundraising.user</field>
<field name="inherit_id" ref="view_crm_case_user_tree"/>
<record id="view_crm_fundraising_tree" model="ir.ui.view">
<field name="name">report.crm.fundraising.tree</field>
<field name="model">report.crm.fundraising</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
<field name="delay_close"/>
<tree string="Fundraising">
<field name="name" />
<field name="month"/>
<field name="nbr" string="#Fundraising"/>
<field name="amount_revenue"/>
<field name="amount_costs"/>
<field name="amount_revenue_prob"/>
<field name="probability"/>
</field>
</field>
<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"/>
</tree>
</field>
</record>
<record id="view_crm_fundraising_user_form" model="ir.ui.view">
<field name="name">report.crm.fundraising.user.form</field>
<field name="model">report.crm.fundraising.user</field>
<field name="inherit_id" ref="view_crm_case_user_form"/>
<record id="view_crm_fundraising_form" model="ir.ui.view">
<field name="name">report.crm.fundraising.form</field>
<field name="model">report.crm.fundraising</field>
<field name="inherit_id" ref="view_crm_case_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
@@ -36,12 +43,12 @@
</field>
</record>
<record id="view_crm_fundraising_user_graph" model="ir.ui.view">
<field name="name">report.crm.fundraising.user.graph</field>
<field name="model">report.crm.fundraising.user</field>
<record id="view_crm_fundraising_graph" model="ir.ui.view">
<field name="name">report.crm.fundraising.graph</field>
<field name="model">report.crm.fundraising</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="fundraising by User and Section" type="bar">
<graph orientation="horizontal" string="Fundraising" type="bar">
<field name="state"/>
<field name="nbr" operator="+"/>
<field group="True" name="user_id"/>
@@ -49,378 +56,41 @@
</field>
</record>
<record id="view_crm_fundraising_user_filter" model="ir.ui.view">
<field name="name">report.crm.fundraising.user.select</field>
<field name="model">report.crm.fundraising.user</field>
<field name="inherit_id" ref="view_crm_case_user_filter"/>
<record id="view_crm_fundraising_filter" model="ir.ui.view">
<field name="name">report.crm.fundraising.select</field>
<field name="model">report.crm.fundraising</field>
<field name="inherit_id" ref="view_crm_case_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="state" position="before">
<field name="user_id" position="before">
</field>
</field>
</record>
<record id="action_report_crm_fundraising_user_tree" model="ir.actions.act_window">
<field name="name">Fundraising by User and Section</field>
<field name="res_model">report.crm.fundraising.user</field>
<record id="action_report_crm_fundraising" model="ir.actions.act_window">
<field name="name">Fundraising</field>
<field name="res_model">report.crm.fundraising</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_crm_fundraising_user_graph"/>
<field name="search_view_id" ref="view_crm_fundraising_user_filter"/>
<field name="view_id" ref="view_crm_fundraising_graph"/>
<field name="search_view_id" ref="view_crm_fundraising_filter"/>
</record>
<menuitem name="Fundraising" id="menu_crm_fundraising_tree" parent="crm.next_id_52"/>
<menuitem action="action_report_crm_fundraising_user_tree" id="menu_crm_fundraising_user_tree" parent="menu_crm_fundraising_tree"/>
<!-- # Fundraising by section and category of case -->
<record model="ir.actions.act_window.view" id="action_report_crm_fundrising_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_fundraising_tree"/>
<field name="act_window_id" ref="action_report_crm_fundraising"/>
</record>
<record id="view_crm_fundraising_categ_tree" model="ir.ui.view">
<field name="name">report.crm.fundraising.categ.tree</field>
<field name="model">report.crm.fundraising.categ</field>
<field name="inherit_id" ref="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_fundraising_categ_form" model="ir.ui.view">
<field name="name">report.crm.fundraising.categ.form</field>
<field name="model">report.crm.fundraising.categ</field>
<field name="inherit_id" ref="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_fundraising_categ_graph" model="ir.ui.view">
<field name="name">report.crm.fundraising.categ.graph</field>
<field name="model">report.crm.fundraising.categ</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="fundraising 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_fundraising_categ_filter" model="ir.ui.view">
<field name="name">report.crm.fundraising.categ.select</field>
<field name="model">report.crm.fundraising.categ</field>
<field name="inherit_id" ref="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_fundraising_categ_tree" model="ir.actions.act_window">
<field name="name">Fundraising by Categories and Section</field>
<field name="res_model">report.crm.fundraising.categ</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_crm_fundraising_categ_graph"/>
<field name="search_view_id" ref="view_crm_fundraising_categ_filter"/>
</record>
<menuitem action="action_report_crm_fundraising_categ_tree" id="menu_crm_fundraising_categ_tree" parent="menu_crm_fundraising_tree"/>
<!-- Fundraising by Section -->
<record id="view_report_crm_fundraising_section_tree" model="ir.ui.view">
<field name="name">report.crm.fundraising.section.tree</field>
<field name="model">report.crm.fundraising.section</field>
<field name="inherit_id" ref="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_fundraising_section_graph" model="ir.ui.view">
<field name="name">report.crm.fundraising.section.graph</field>
<field name="model">report.crm.fundraising.section</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="fundraising by Section" type="bar">
<field name="name"/>
<field name="nbr_cases" operator="+"/>
</graph>
</field>
</record>
<record id="view_report_crm_fundraising_section_filter" model="ir.ui.view">
<field name="name">report.crm.fundraising.section.select</field>
<field name="model">report.crm.fundraising.section</field>
<field name="inherit_id" ref="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_fundraising_section_tree" model="ir.actions.act_window">
<field name="name">Fundraising by Section</field>
<field name="res_model">report.crm.fundraising.section</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_report_crm_fundraising_section_graph"/>
<field name="search_view_id" ref="view_report_crm_fundraising_section_filter"/>
</record>
<menuitem action="action_report_crm_fundraising_section_tree" id="menu_crm_fundraising_section_tree" parent="menu_crm_fundraising_tree"/>
#
# Fundraising by section and type
#
<record model="ir.ui.view" id="view_crm_fundraising_section_categ_tree">
<field name="name">CRM Report - Sections and Type(Tree)</field>
<field name="model">report.crm.fundraising.section.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="type_id"/>
<field name="stage_id"/>
<field name="amount_revenue"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_fundraising_section_categ_form">
<field name="name">CRM Report - Sections and Type(Form)</field>
<field name="model">report.crm.fundraising.section.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="type_id"/>
<field name="stage_id"/>
<field name="amount_revenue"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_fundraising_section_categ_graph">
<field name="name">CRM Report - Sections and Type(Graph)</field>
<field name="model">report.crm.fundraising.section.type</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Fundraising by Section and Type" type="bar" orientation="horizontal">
<field name="type_id"/>
<field name="amount_revenue" operator="+"/>
<field name="section_id" group="True"/>
</graph>
</field>
</record>
<record id="view_crm_fundraising_section_categ_filter" model="ir.ui.view">
<field name="name">CRM Report - Sections and Type(Select)</field>
<field name="model">report.crm.fundraising.section.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="section_id" position="after">
<field name="type_id"/>
</field>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_fundraising_section_categ_tree">
<field name="res_model">report.crm.fundraising.section.type</field>
<field name="name">Fundraising by section and type</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="search_view_id" ref="view_crm_fundraising_section_categ_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_fundraising_section_categ_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_fundraising_section_categ_graph"/>
<field name="act_window_id" ref="action_report_crm_fundraising_section_categ_tree"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_fundraising_section_categ_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_fundraising_section_categ_tree"/>
<field name="act_window_id" ref="action_report_crm_fundraising_section_categ_tree"/>
</record>
<menuitem action="action_report_crm_fundraising_section_categ_tree" id="menu_crm_fundraising_section_categ_tree" parent="menu_crm_fundraising_tree"/>
#
# Fundraising by section, category and stage
#
<record model="ir.ui.view" id="view_crm_fundraising_section_categ_stage_tree">
<field name="name">CRM Report - Section, Category and Stage(Tree)</field>
<field name="model">report.crm.fundraising.section.categ.stage</field>
<field name="inherit_id" ref="view_crm_case_section_categ_stage_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_fundraising_section_categ_stage_form">
<field name="name">CRM Report - Section, Category and Stage(Form)</field>
<field name="model">report.crm.fundraising.section.categ.stage</field>
<field name="inherit_id" ref="view_crm_case_section_categ_stage_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_fundraising_section_categ_stage_graph">
<field name="name">CRM Report - Section, Category and Stage(Select)</field>
<field name="model">report.crm.fundraising.section.categ.stage</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Fundraising by Section, Category and Stage" type="bar" orientation="horizontal">
<field name="categ_id"/>
<field name="nbr" operator="+"/>
<field name="section_id" group="True"/>
</graph>
</field>
</record>
<record id="view_crm_fundraising_section_categ_stage_filter" model="ir.ui.view">
<field name="name">CRM Report - Section, Category and Stage(Select)</field>
<field name="model">report.crm.fundraising.section.categ.stage</field>
<field name="inherit_id" ref="view_crm_case_section_categ_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="section_id" position="after">
<field name="categ_id"/>
<field name="stage_id"/>
</field>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_fundraising_section_categ_stage_tree">
<field name="res_model">report.crm.fundraising.section.categ.stage</field>
<field name="name">Fundraising by section, category and stage</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="search_view_id" ref="view_crm_fundraising_section_categ_stage_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_fundraising_section_categ_stage_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_fundraising_section_categ_stage_graph"/>
<field name="act_window_id" ref="action_report_crm_fundraising_section_categ_stage_tree"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_fundraising_section_categ_stage_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_fundraising_section_categ_stage_tree"/>
<field name="act_window_id" ref="action_report_crm_fundraising_section_categ_stage_tree"/>
</record>
<menuitem action="action_report_crm_fundraising_section_categ_stage_tree" id="menu_crm_fundraising_section_categ_stage_tree" parent="menu_crm_fundraising_tree"/>
#
# Fundraising by section, category and type
#
<record model="ir.ui.view" id="view_crm_fundraising_section_categ_type_tree">
<field name="name">CRM Report - Section, Category and Type(Tree)</field>
<field name="model">report.crm.fundraising.section.categ.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_type_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="type_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_fundraising_section_categ_type_form">
<field name="name">CRM Report - Section, Category and Type(Form)</field>
<field name="model">report.crm.fundraising.section.categ.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_type_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="type_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_fundraising_section_categ_type_graph">
<field name="name">CRM Report - Section, Category and Type(Select)</field>
<field name="model">report.crm.fundraising.section.categ.type</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Fundraising by Section, Category and Type" type="bar" orientation="horizontal">
<field name="type_id"/>
<field name="nbr" operator="+"/>
<field name="section_id" group="True"/>
</graph>
</field>
</record>
<record id="view_crm_fundraising_section_categ_type_filter" model="ir.ui.view">
<field name="name">CRM Report - Section, Category and Type(Select)</field>
<field name="model">report.crm.fundraising.section.categ.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_type_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="section_id" position="after">
<field name="categ_id" select="1"/>
<field name="type_id" select="1"/>
<field name="stage_id" select="1"/>
</field>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_fundraising_section_categ_type_tree">
<field name="res_model">report.crm.fundraising.section.categ.type</field>
<field name="name">Fundraising by section, category and type</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="search_view_id" ref="view_crm_fundraising_section_categ_type_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_fundraising_section_categ_type_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_fundraising_section_categ_type_graph"/>
<field name="act_window_id" ref="action_report_crm_fundraising_section_categ_type_tree"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_fundraising_section_categ_type_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_fundraising_section_categ_type_tree"/>
<field name="act_window_id" ref="action_report_crm_fundraising_section_categ_type_tree"/>
</record>
<menuitem action="action_report_crm_fundraising_section_categ_type_tree" id="menu_crm_fundraising_section_categ_type_tree" parent="menu_crm_fundraising_tree"/>
</data>
<record model="ir.actions.act_window.view" id="action_report_crm_fundrising_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<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="base.next_id_64"/>
</data>
</openerp>
+11 -248
View File
@@ -1,273 +1,36 @@
from osv import fields,osv
import tools
class report_crm_lead_user(osv.osv):
_name = "report.crm.lead.user"
_description = "Leads by user and section"
class report_crm_lead(osv.osv):
_name = "report.crm.lead"
_auto = False
_inherit = "report.crm.case.user"
_inherit = "report.crm.case"
_columns = {
'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),
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]"),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_crm_lead_user')
tools.drop_view_if_exists(cr, 'report_crm_lead')
cr.execute("""
create or replace view report_crm_lead_user as (
create or replace view report_crm_lead as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.state,
c.user_id,
c.stage_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_lead 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_lead_user()
class report_crm_lead_categ(osv.osv):
_name = "report.crm.lead.categ"
_description = "Leads 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.lead')]"),
'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_lead_categ')
cr.execute("""
create or replace view report_crm_lead_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,
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_lead c
group by c.categ_id,to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state,c.section_id
)""")
report_crm_lead_categ()
class report_crm_lead_section(osv.osv):
_name = "report.crm.lead.section"
_description = "Leads 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_lead 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_lead_section')
cr.execute("""
create or replace view report_crm_lead_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_lead c
group by to_char(c.create_date, 'YYYY'),to_char(c.create_date, 'MM'),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.stage_id,categ_id
)""")
report_crm_lead_section()
class report_crm_lead_section_stage(osv.osv):
_name = "report.crm.lead.section.stage"
_description = "Leads by section and stage"
_auto = False
_inherit = "report.crm.case.section.stage"
_columns = {
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'amount_revenue': fields.float('Est.Revenue', readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'stage_id, section_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_lead_section_stage")
cr.execute("""
create view report_crm_lead_section_stage as (
select
min(c.id) as id,
to_char(c.create_date,'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.state,
c.stage_id,
c.section_id,
c.categ_id,
count(*) as nbr,
sum(planned_revenue) as amount_revenue,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_lead c
where c.stage_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.user_id, c.state, c.stage_id, c.categ_id, c.section_id)""")
report_crm_lead_section_stage()
class report_crm_lead_section_type(osv.osv):
_name = "report.crm.lead.section.type"
_inherit = "report.crm.case.section.type"
_description = "Leads by section and type"
_auto = False
_columns = {
'type_id': fields.many2one('crm.case.resource.type', 'Lead Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'amount_revenue': fields.float('Est.Revenue', readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'type_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_lead_section_type")
cr.execute("""
create view report_crm_lead_section_type as (
select
min(c.id) as id,
to_char(c.create_date,'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.state,
c.type_id,
c.stage_id,
c.section_id,
count(*) as nbr,
sum(planned_revenue) as amount_revenue,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_lead c
where c.type_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.user_id, c.state, c.stage_id, c.type_id, c.section_id)""")
report_crm_lead_section_type()
class report_crm_lead_section_categ_stage(osv.osv):
_name = "report.crm.lead.section.categ.stage"
_inherit = "report.crm.case.section.categ.stage"
_description = "Leads by Section, Category and Stage"
_auto = False
_columns = {
'categ_id': fields.many2one('crm.case.categ','Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'stage_id, categ_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_lead_section_categ_stage")
cr.execute("""
create view report_crm_lead_section_categ_stage as (
select
min(c.id) as id,
to_char(c.create_date,'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.categ_id,
c.state,
c.stage_id,
c.section_id,
count(*) as nbr,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_lead c
where c.categ_id is not null AND c.stage_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),c.user_id, c.categ_id, c.state, c.stage_id, c.section_id)""")
report_crm_lead_section_categ_stage()
class report_crm_lead_section_categ_type(osv.osv):
_name = "report.crm.lead.section.categ.type"
_inherit = "report.crm.case.section.categ.type"
_description = "Leads by Section, Category and Type"
_auto = False
_columns = {
'categ_id':fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'type_id': fields.many2one('crm.case.resource.type', 'Lead Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'categ_id, type_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_lead_section_categ_type")
cr.execute("""
create view report_crm_lead_section_categ_type as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.categ_id,
c.type_id,
c.state,
c.stage_id,
c.section_id,
count(*) as nbr,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_lead c
where c.categ_id is not null AND c.type_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),c.user_id, c.categ_id, c.type_id, c.state, c.stage_id, c.section_id)""")
report_crm_lead_section_categ_type()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
report_crm_lead()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+51 -447
View File
@@ -5,43 +5,43 @@
Leads by user and section
-->
<record id="view_crm_lead_user_tree" model="ir.ui.view">
<field name="name">report.crm.lead.user.tree</field>
<field name="model">report.crm.lead.user</field>
<field name="inherit_id" ref="view_crm_case_user_tree"/>
<record id="view_crm_lead_tree" model="ir.ui.view">
<field name="name">report.crm.lead.tree</field>
<field name="model">report.crm.lead</field>
<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>
<tree string="Leads">
<field name="name" />
<field name="month"/>
<field name="nbr" string="#Leads"/>
<field name="delay_close"/>
<field name="section_id" invisible="1"/>
<field name="state" invisible="1"/>
<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_lead_user_form" model="ir.ui.view">
<field name="name">report.crm.lead.user.form</field>
<field name="model">report.crm.lead.user</field>
<field name="inherit_id" ref="view_crm_case_user_form"/>
<record id="view_crm_lead_form" model="ir.ui.view">
<field name="name">report.crm.lead.form</field>
<field name="model">report.crm.lead</field>
<field name="inherit_id" ref="view_crm_case_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 name="stage_id"/>
</field>
</field>
</record>
<record id="view_crm_lead_user_graph" model="ir.ui.view">
<field name="name">report.crm.lead.user.graph</field>
<field name="model">report.crm.lead.user</field>
<record id="view_crm_lead_graph" model="ir.ui.view">
<field name="name">report.crm.lead.graph</field>
<field name="model">report.crm.lead</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Leads by User and Section" type="bar">
<graph orientation="horizontal" string="Leads" type="bar">
<field name="state"/>
<field name="nbr" operator="+"/>
<field group="True" name="user_id"/>
@@ -49,437 +49,41 @@
</field>
</record>
<record id="view_crm_lead_user_filter" model="ir.ui.view">
<field name="name">report.crm.lead.user.select</field>
<field name="model">report.crm.lead.user</field>
<field name="inherit_id" ref="view_crm_case_user_filter"/>
<record id="view_crm_lead_filter" model="ir.ui.view">
<field name="name">report.crm.lead.select</field>
<field name="model">report.crm.lead</field>
<field name="inherit_id" ref="view_crm_case_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="state" position="before">
</field>
<field name="user_id" position="before"/>
</field>
</record>
<record id="action_report_crm_lead_user_tree" model="ir.actions.act_window">
<field name="name">Leads by User and Section</field>
<field name="res_model">report.crm.lead.user</field>
<record id="action_report_crm_lead" model="ir.actions.act_window">
<field name="name">Leads</field>
<field name="res_model">report.crm.lead</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_crm_lead_user_graph"/>
<field name="search_view_id" ref="view_crm_lead_user_filter"/>
<field name="view_id" ref="view_crm_lead_graph"/>
<field name="search_view_id" ref="view_crm_lead_filter"/>
</record>
<menuitem name="Leads" id="menu_crm_leads_tree" parent="crm.next_id_52"/>
<menuitem action="action_report_crm_lead_user_tree" id="menu_crm_lead_user_tree" parent="menu_crm_leads_tree"/>
<!-- # Leads by section and category of case -->
<record model="ir.actions.act_window.view" id="action_report_crm_lead_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_lead_tree"/>
<field name="act_window_id" ref="action_report_crm_lead"/>
</record>
<record model="ir.actions.act_window.view" id="action_report_crm_lead_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_lead_graph"/>
<field name="act_window_id" ref="action_report_crm_lead"/>
</record>
<record id="view_crm_lead_categ_tree" model="ir.ui.view">
<field name="name">report.crm.lead.categ.tree</field>
<field name="model">report.crm.lead.categ</field>
<field name="inherit_id" ref="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_lead_categ_form" model="ir.ui.view">
<field name="name">report.crm.lead.categ.form</field>
<field name="model">report.crm.lead.categ</field>
<field name="inherit_id" ref="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_lead_categ_graph" model="ir.ui.view">
<field name="name">report.crm.lead.categ.graph</field>
<field name="model">report.crm.lead.categ</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Leads 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_lead_categ_filter" model="ir.ui.view">
<field name="name">report.crm.lead.categ.select</field>
<field name="model">report.crm.lead.categ</field>
<field name="inherit_id" ref="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_lead_categ_tree" model="ir.actions.act_window">
<field name="name">Leads by Categories and Section</field>
<field name="res_model">report.crm.lead.categ</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_crm_lead_categ_graph"/>
<field name="search_view_id" ref="view_crm_lead_categ_filter"/>
</record>
<menuitem action="action_report_crm_lead_categ_tree" id="menu_crm_lead_categ_tree" parent="menu_crm_leads_tree"/>
<!-- Leads by Section -->
<record id="view_report_crm_lead_section_tree" model="ir.ui.view">
<field name="name">report.crm.lead.section.tree</field>
<field name="model">report.crm.lead.section</field>
<field name="inherit_id" ref="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_lead_section_graph" model="ir.ui.view">
<field name="name">report.crm.lead.section.graph</field>
<field name="model">report.crm.lead.section</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Leads by Section" type="bar">
<field name="name"/>
<field name="nbr_cases" operator="+"/>
</graph>
</field>
</record>
<record id="view_report_crm_lead_section_filter" model="ir.ui.view">
<field name="name">report.crm.lead.section.select</field>
<field name="model">report.crm.lead.section</field>
<field name="inherit_id" ref="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_lead_section_tree" model="ir.actions.act_window">
<field name="name">Leads by Section</field>
<field name="res_model">report.crm.lead.section</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_report_crm_lead_section_graph"/>
<field name="search_view_id" ref="view_report_crm_lead_section_filter"/>
</record>
<menuitem action="action_report_crm_lead_section_tree" id="menu_crm_lead_section_tree" parent="menu_crm_leads_tree"/>
<!-- Cases by section and stage -->
<record model="ir.ui.view" id="view_crm_lead_section_stage_tree">
<field name="name">Leads Report - Sections and Stage(Tree)</field>
<field name="model">report.crm.lead.section.stage</field>
<field name="inherit_id" ref="view_crm_case_section_stage_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
<field name="categ_id"/>
<field name="stage_id" select="2"/>
<field name="amount_revenue" select="2"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_lead_section_stage_form">
<field name="name">Leads Report - Sections and Stage(Form)</field>
<field name="model">report.crm.lead.section.stage</field>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
<field name="categ_id"/>
<field name="stage_id" select="2"/>
<field name="amount_revenue" select="2"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_lead_section_stage_graph">
<field name="name">Leads Report - Sections and Stage(Graph)</field>
<field name="model">report.crm.lead.section.stage</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Leads by Section and Stage" type="bar" orientation="horizontal">
<field name="stage_id"/>
<field name="amount_revenue" operator="+"/>
<field name="section_id" group="True"/>
</graph>
</field>
</record>
<record id="view_crm_lead_section_stage_filter" model="ir.ui.view">
<field name="name">Leads Report - Sections and Stage(Select)</field>
<field name="model">report.crm.lead.section.stage</field>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="state" position="before">
</field>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_lead_section_stage_tree">
<field name="res_model">report.crm.lead.section.stage</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_crm_lead_section_stage_tree"/>
<field name="search_view_id" ref="view_crm_lead_section_stage_filter"/>
</record>
#
# Leads by section and type
#
<record model="ir.ui.view" id="view_crm_lead_section_categ_tree">
<field name="name">CRM Report - Sections and Type(Tree)</field>
<field name="model">report.crm.lead.section.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="type_id"/>
<field name="stage_id"/>
<field name="amount_revenue"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_lead_section_categ_form">
<field name="name">CRM Report - Sections and Type(Form)</field>
<field name="model">report.crm.lead.section.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="type_id"/>
<field name="stage_id"/>
<field name="amount_revenue"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_lead_section_categ_graph">
<field name="name">CRM Report - Sections and Type(Graph)</field>
<field name="model">report.crm.lead.section.type</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Leads by Section and Type" type="bar" orientation="horizontal">
<field name="type_id"/>
<field name="amount_revenue" operator="+"/>
<field name="section_id" group="True"/>
</graph>
</field>
</record>
<record id="view_crm_lead_section_categ_filter" model="ir.ui.view">
<field name="name">CRM Report - Sections and Type(Select)</field>
<field name="model">report.crm.lead.section.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="section_id" position="after">
<field name="type_id"/>
</field>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_lead_section_categ_tree">
<field name="res_model">report.crm.lead.section.type</field>
<field name="name">Leads by section and type</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="search_view_id" ref="view_crm_lead_section_categ_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_lead_section_categ_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_lead_section_categ_graph"/>
<field name="act_window_id" ref="action_report_crm_lead_section_categ_tree"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_lead_section_categ_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_lead_section_categ_tree"/>
<field name="act_window_id" ref="action_report_crm_lead_section_categ_tree"/>
</record>
<menuitem action="action_report_crm_lead_section_categ_tree" id="menu_crm_lead_section_categ_tree" parent="menu_crm_leads_tree"/>
#
# Leads by section, category and stage
#
<record model="ir.ui.view" id="view_crm_lead_section_categ_stage_tree">
<field name="name">CRM Report - Section, Category and Stage(Tree)</field>
<field name="model">report.crm.lead.section.categ.stage</field>
<field name="inherit_id" ref="view_crm_case_section_categ_stage_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_lead_section_categ_stage_form">
<field name="name">CRM Report - Section, Category and Stage(Form)</field>
<field name="model">report.crm.lead.section.categ.stage</field>
<field name="inherit_id" ref="view_crm_case_section_categ_stage_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_lead_section_categ_stage_graph">
<field name="name">CRM Report - Section, Category and Stage(Select)</field>
<field name="model">report.crm.lead.section.categ.stage</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Leads by Section, Category and Stage" type="bar" orientation="horizontal">
<field name="categ_id"/>
<field name="nbr" operator="+"/>
<field name="section_id" group="True"/>
</graph>
</field>
</record>
<record id="view_crm_lead_section_categ_stage_filter" model="ir.ui.view">
<field name="name">CRM Report - Section, Category and Stage(Select)</field>
<field name="model">report.crm.lead.section.categ.stage</field>
<field name="inherit_id" ref="view_crm_case_section_categ_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="section_id" position="after">
<field name="categ_id"/>
<field name="stage_id"/>
</field>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_lead_section_categ_stage_tree">
<field name="res_model">report.crm.lead.section.categ.stage</field>
<field name="name">Leads by section, category and stage</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="search_view_id" ref="view_crm_lead_section_categ_stage_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_lead_section_categ_stage_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_lead_section_categ_stage_graph"/>
<field name="act_window_id" ref="action_report_crm_lead_section_categ_stage_tree"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_lead_section_categ_stage_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_lead_section_categ_stage_tree"/>
<field name="act_window_id" ref="action_report_crm_lead_section_categ_stage_tree"/>
</record>
<menuitem action="action_report_crm_lead_section_categ_stage_tree" id="menu_crm_lead_section_categ_stage_tree" parent="menu_crm_leads_tree"/>
#
# Leads by section, category and type
#
<record model="ir.ui.view" id="view_crm_lead_section_categ_type_tree">
<field name="name">CRM Report - Section, Category and Type(Tree)</field>
<field name="model">report.crm.lead.section.categ.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_type_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="type_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_lead_section_categ_type_form">
<field name="name">CRM Report - Section, Category and Type(Form)</field>
<field name="model">report.crm.lead.section.categ.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_type_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="type_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_lead_section_categ_type_graph">
<field name="name">CRM Report - Section, Category and Type(Select)</field>
<field name="model">report.crm.lead.section.categ.type</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Leads by Section, Category and Type" type="bar" orientation="horizontal">
<field name="type_id"/>
<field name="nbr" operator="+"/>
<field name="section_id" group="True"/>
</graph>
</field>
</record>
<record id="view_crm_lead_section_categ_type_filter" model="ir.ui.view">
<field name="name">CRM Report - Section, Category and Type(Select)</field>
<field name="model">report.crm.lead.section.categ.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_type_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="section_id" position="after">
<field name="categ_id" select="1"/>
<field name="type_id" select="1"/>
<field name="stage_id" select="1"/>
</field>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_lead_section_categ_type_tree">
<field name="res_model">report.crm.lead.section.categ.type</field>
<field name="name">Leads by section, category and type</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="search_view_id" ref="view_crm_lead_section_categ_type_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_lead_section_categ_type_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_lead_section_categ_type_graph"/>
<field name="act_window_id" ref="action_report_crm_lead_section_categ_type_tree"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_lead_section_categ_type_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_lead_section_categ_type_tree"/>
<field name="act_window_id" ref="action_report_crm_lead_section_categ_type_tree"/>
</record>
<menuitem action="action_report_crm_lead_section_categ_type_tree" id="menu_crm_lead_section_categ_type_tree" parent="menu_crm_leads_tree"/>
<menuitem name="Leads" id="menu_crm_leads_tree" parent="base.next_id_64" action="action_report_crm_lead"/>
</data>
</openerp>
+14 -203
View File
@@ -1,21 +1,23 @@
from osv import fields,osv
import tools
class report_crm_opportunity_user(osv.osv):
_name = "report.crm.opportunity.user"
_description = "Opportunity by user and section"
class report_crm_opportunity(osv.osv):
_name = "report.crm.opportunity"
_auto = False
_inherit = "report.crm.case.user"
_inherit = "report.crm.case"
_columns = {
'probability': fields.float('Avg. Probability', readonly=True),
'amount_revenue': fields.float('Est.Revenue', readonly=True),
'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
'delay_close': fields.char('Delay to close', size=20, readonly=True),
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]", readonly=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_crm_opportunity_user')
tools.drop_view_if_exists(cr, 'report_crm_opportunity')
cr.execute("""
create or replace view report_crm_opportunity_user as (
create or replace view report_crm_opportunity as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
@@ -23,210 +25,19 @@ class report_crm_opportunity_user(osv.osv):
c.state,
c.user_id,
c.section_id,
count(*) as nbr,
sum(planned_revenue) as amount_revenue,
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_opportunity 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_opportunity_user()
class report_crm_opportunity_categ(osv.osv):
_name = "report.crm.opportunity.categ"
_description = "Opportunity 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.opportunity')]"),
'amount_revenue': fields.float('Est.Revenue', 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_opportunity_categ')
cr.execute("""
create or replace view report_crm_opportunity_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_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_opportunity c
group by c.categ_id,to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state,c.section_id
)""")
report_crm_opportunity_categ()
class report_crm_opportunity_section(osv.osv):
_name = "report.crm.opportunity.section"
_description = "Opportunity 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_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
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_opportunity_section')
cr.execute("""
create or replace view report_crm_opportunity_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,
sum(planned_revenue) as amount_revenue,
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_opportunity c
group by to_char(c.create_date, 'YYYY'),to_char(c.create_date, 'MM'),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.stage_id,c.categ_id
)""")
report_crm_opportunity_section()
class report_crm_opportunity_section_type(osv.osv):
_name = "report.crm.opportunity.section.type"
_inherit = "report.crm.case.section.type"
_description = "Opportunity by section and type"
_auto = False
_columns = {
'type_id': fields.many2one('crm.case.resource.type', 'Opportunity Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]", readonly=True),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]", readonly=True),
'amount_revenue': fields.float('Est.Revenue', readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'type_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_opportunity_section_type")
cr.execute("""
create view report_crm_opportunity_section_type as (
select
min(c.id) as id,
to_char(c.create_date,'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.state,
c.type_id,
c.stage_id,
c.section_id,
count(*) as nbr,
sum(planned_revenue) as amount_revenue,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_opportunity c
where c.type_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.user_id, c.state, c.stage_id, c.type_id, c.section_id)""")
report_crm_opportunity_section_type()
class report_crm_opportunity_section_categ_stage(osv.osv):
_name = "report.crm.opportunity.section.categ.stage"
_inherit = "report.crm.case.section.categ.stage"
_description = "Opportunity by Section, Category and Stage"
_auto = False
_columns = {
'categ_id': fields.many2one('crm.case.categ','Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]", readonly=True),
'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]", readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'stage_id, categ_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_opportunity_section_categ_stage")
cr.execute("""
create view report_crm_opportunity_section_categ_stage as (
select
min(c.id) as id,
to_char(c.create_date,'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.categ_id,
c.state,
c.stage_id,
c.section_id,
count(*) as nbr,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_opportunity c
where c.categ_id is not null AND c.stage_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),c.user_id, c.categ_id, c.state, c.stage_id, c.section_id)""")
report_crm_opportunity_section_categ_stage()
class report_crm_opportunity_section_categ_type(osv.osv):
_name = "report.crm.opportunity.section.categ.type"
_inherit = "report.crm.case.section.categ.type"
_description = "Opportunity by Section, Category and Type"
_auto = False
_columns = {
'categ_id':fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]", readonly=True),
'type_id': fields.many2one('crm.case.resource.type', 'Opportunity Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]", readonly=True),
'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]", readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'categ_id, type_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_opportunity_section_categ_type")
cr.execute("""
create view report_crm_opportunity_section_categ_type as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.categ_id,
c.type_id,
c.state,
c.stage_id,
c.section_id,
count(*) as nbr,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_opportunity c
where c.categ_id is not null AND c.type_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),c.user_id, c.categ_id, c.type_id, c.state, c.stage_id, c.section_id)""")
report_crm_opportunity_section_categ_type()
report_crm_opportunity()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+47 -381
View File
@@ -5,25 +5,31 @@
Opportunities by user and section
-->
<record id="view_crm_opportunity_user_tree" model="ir.ui.view">
<field name="name">report.crm.opportunity.user.tree</field>
<field name="model">report.crm.opportunity.user</field>
<field name="inherit_id" ref="view_crm_case_user_tree"/>
<record id="view_crm_opportunity_tree" model="ir.ui.view">
<field name="name">report.crm.opportunity.tree</field>
<field name="model">report.crm.opportunity</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
<field name="delay_close"/>
<tree string="Opportunities">
<field name="name" />
<field name="month"/>
<field name="nbr" string="#Opportunities"/>
<field name="amount_revenue"/>
<field name="amount_costs"/>
<field name="amount_revenue_prob"/>
<field name="probability"/>
</field>
</field>
<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"/>
</tree>
</field>
</record>
<record id="view_crm_opportunity_user_form" model="ir.ui.view">
<field name="name">report.crm.opportunity.user.form</field>
<field name="model">report.crm.opportunity.user</field>
<field name="inherit_id" ref="view_crm_case_user_form"/>
<record id="view_crm_opportunity_form" model="ir.ui.view">
<field name="name">report.crm.opportunity.form</field>
<field name="model">report.crm.opportunity</field>
<field name="inherit_id" ref="view_crm_case_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
@@ -36,12 +42,12 @@
</field>
</record>
<record id="view_crm_opportunity_user_graph" model="ir.ui.view">
<field name="name">report.crm.opportunity.user.graph</field>
<field name="model">report.crm.opportunity.user</field>
<record id="view_crm_opportunity_graph" model="ir.ui.view">
<field name="name">report.crm.opportunity.graph</field>
<field name="model">report.crm.opportunity</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Opportunity by User and Section" type="bar">
<graph orientation="horizontal" string="Opportunity" type="bar">
<field name="state"/>
<field name="nbr" operator="+"/>
<field group="True" name="user_id"/>
@@ -49,378 +55,38 @@
</field>
</record>
<record id="view_crm_opportunity_user_filter" model="ir.ui.view">
<field name="name">report.crm.opportunity.user.select</field>
<field name="model">report.crm.opportunity.user</field>
<field name="inherit_id" ref="view_crm_case_user_filter"/>
<record id="view_crm_opportunity_filter" model="ir.ui.view">
<field name="name">report.crm.opportunity.select</field>
<field name="model">report.crm.opportunity</field>
<field name="inherit_id" ref="view_crm_case_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="state" position="before">
<field name="user_id" position="before">
</field>
</field>
</record>
<record id="action_report_crm_opportunity_user_tree" model="ir.actions.act_window">
<field name="name">Opportunity by User and Section</field>
<field name="res_model">report.crm.opportunity.user</field>
<record id="action_report_crm_opportunity" model="ir.actions.act_window">
<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>
<field name="view_id" ref="view_crm_opportunity_user_graph"/>
<field name="search_view_id" ref="view_crm_opportunity_user_filter"/>
<field name="view_id" ref="view_crm_opportunity_graph"/>
<field name="search_view_id" ref="view_crm_opportunity_filter"/>
</record>
<menuitem name="Opportinities" id="menu_crm_opportunity_tree" parent="crm.next_id_52"/>
<menuitem action="action_report_crm_opportunity_user_tree" id="menu_crm_opportunity_user_tree" parent="menu_crm_opportunity_tree"/>
<!-- # Opportunity by section and category of case -->
<record model="ir.actions.act_window.view" id="action_report_crm_opportunity_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_opportunity_tree"/>
<field name="act_window_id" ref="action_report_crm_opportunity"/>
</record>
<record model="ir.actions.act_window.view" id="action_report_crm_opportunity_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_opportunity_graph"/>
<field name="act_window_id" ref="action_report_crm_opportunity"/>
</record>
<record id="view_crm_opportunity_categ_tree" model="ir.ui.view">
<field name="name">report.crm.opportunity.categ.tree</field>
<field name="model">report.crm.opportunity.categ</field>
<field name="inherit_id" ref="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_opportunity_categ_form" model="ir.ui.view">
<field name="name">report.crm.opportunity.categ.form</field>
<field name="model">report.crm.opportunity.categ</field>
<field name="inherit_id" ref="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_opportunity_categ_graph" model="ir.ui.view">
<field name="name">report.crm.opportunity.categ.graph</field>
<field name="model">report.crm.opportunity.categ</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Opportunity 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_opportunity_categ_filter" model="ir.ui.view">
<field name="name">report.crm.opportunity.categ.select</field>
<field name="model">report.crm.opportunity.categ</field>
<field name="inherit_id" ref="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_opportunity_categ_tree" model="ir.actions.act_window">
<field name="name">Opportunity by Categories and Section</field>
<field name="res_model">report.crm.opportunity.categ</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_crm_opportunity_categ_graph"/>
<field name="search_view_id" ref="view_crm_opportunity_categ_filter"/>
</record>
<menuitem action="action_report_crm_opportunity_categ_tree" id="menu_crm_opportunity_categ_tree" parent="menu_crm_opportunity_tree"/>
<!-- Opportunity by Section -->
<record id="view_report_crm_opportunity_section_tree" model="ir.ui.view">
<field name="name">report.crm.opportunity.section.tree</field>
<field name="model">report.crm.opportunity.section</field>
<field name="inherit_id" ref="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_opportunity_section_graph" model="ir.ui.view">
<field name="name">report.crm.opportunity.section.graph</field>
<field name="model">report.crm.opportunity.section</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Opportunity by Section" type="bar">
<field name="name"/>
<field name="nbr_cases" operator="+"/>
</graph>
</field>
</record>
<record id="view_report_crm_opportunity_section_filter" model="ir.ui.view">
<field name="name">report.crm.opportunity.section.select</field>
<field name="model">report.crm.opportunity.section</field>
<field name="inherit_id" ref="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_opportunity_section_tree" model="ir.actions.act_window">
<field name="name">Opportunity by Section</field>
<field name="res_model">report.crm.opportunity.section</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_report_crm_opportunity_section_graph"/>
<field name="search_view_id" ref="view_report_crm_opportunity_section_filter"/>
</record>
<menuitem action="action_report_crm_opportunity_section_tree" id="menu_crm_opportunity_section_tree" parent="menu_crm_opportunity_tree"/>
#
# Opportunity by section and type
#
<record model="ir.ui.view" id="view_crm_opportunity_section_categ_tree">
<field name="name">CRM Report - Sections and Type(Tree)</field>
<field name="model">report.crm.opportunity.section.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="type_id"/>
<field name="stage_id"/>
<field name="amount_revenue"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_opportunity_section_categ_form">
<field name="name">CRM Report - Sections and Type(Form)</field>
<field name="model">report.crm.opportunity.section.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="type_id"/>
<field name="stage_id"/>
<field name="amount_revenue"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_opportunity_section_categ_graph">
<field name="name">CRM Report - Sections and Type(Graph)</field>
<field name="model">report.crm.opportunity.section.type</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Opportunity by Section and Type" type="bar" orientation="horizontal">
<field name="type_id"/>
<field name="amount_revenue" operator="+"/>
<field name="section_id" group="True"/>
</graph>
</field>
</record>
<record id="view_crm_opportunity_section_categ_filter" model="ir.ui.view">
<field name="name">CRM Report - Sections and Type(Select)</field>
<field name="model">report.crm.opportunity.section.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="section_id" position="after">
<field name="type_id"/>
</field>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_opportunity_section_categ_tree">
<field name="res_model">report.crm.opportunity.section.type</field>
<field name="name">Opportunity by section and type</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="search_view_id" ref="view_crm_opportunity_section_categ_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_opportunity_section_categ_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_opportunity_section_categ_graph"/>
<field name="act_window_id" ref="action_report_crm_opportunity_section_categ_tree"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_opportunity_section_categ_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_opportunity_section_categ_tree"/>
<field name="act_window_id" ref="action_report_crm_opportunity_section_categ_tree"/>
</record>
<menuitem action="action_report_crm_opportunity_section_categ_tree" id="menu_crm_opportunity_section_categ_tree" parent="menu_crm_opportunity_tree"/>
#
# Opportunity by section, category and stage
#
<record model="ir.ui.view" id="view_crm_opportunity_section_categ_stage_tree">
<field name="name">CRM Report - Section, Category and Stage(Tree)</field>
<field name="model">report.crm.opportunity.section.categ.stage</field>
<field name="inherit_id" ref="view_crm_case_section_categ_stage_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_opportunity_section_categ_stage_form">
<field name="name">CRM Report - Section, Category and Stage(Form)</field>
<field name="model">report.crm.opportunity.section.categ.stage</field>
<field name="inherit_id" ref="view_crm_case_section_categ_stage_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_opportunity_section_categ_stage_graph">
<field name="name">CRM Report - Section, Category and Stage(Select)</field>
<field name="model">report.crm.opportunity.section.categ.stage</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Opportunity by Section, Category and Stage" type="bar" orientation="horizontal">
<field name="categ_id"/>
<field name="nbr" operator="+"/>
<field name="section_id" group="True"/>
</graph>
</field>
</record>
<record id="view_crm_opportunity_section_categ_stage_filter" model="ir.ui.view">
<field name="name">CRM Report - Section, Category and Stage(Select)</field>
<field name="model">report.crm.opportunity.section.categ.stage</field>
<field name="inherit_id" ref="view_crm_case_section_categ_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="section_id" position="after">
<field name="categ_id"/>
<field name="stage_id"/>
</field>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_opportunity_section_categ_stage_tree">
<field name="res_model">report.crm.opportunity.section.categ.stage</field>
<field name="name">Opportunity by section, category and stage</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="search_view_id" ref="view_crm_opportunity_section_categ_stage_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_opportunity_section_categ_stage_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_opportunity_section_categ_stage_graph"/>
<field name="act_window_id" ref="action_report_crm_opportunity_section_categ_stage_tree"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_opportunity_section_categ_stage_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_opportunity_section_categ_stage_tree"/>
<field name="act_window_id" ref="action_report_crm_opportunity_section_categ_stage_tree"/>
</record>
<menuitem action="action_report_crm_opportunity_section_categ_stage_tree" id="menu_crm_opportunity_section_categ_stage_tree" parent="menu_crm_opportunity_tree"/>
#
# opportunitys by section, category and type
#
<record model="ir.ui.view" id="view_crm_opportunity_section_categ_type_tree">
<field name="name">CRM Report - Section, Category and Type(Tree)</field>
<field name="model">report.crm.opportunity.section.categ.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_type_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="type_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_opportunity_section_categ_type_form">
<field name="name">CRM Report - Section, Category and Type(Form)</field>
<field name="model">report.crm.opportunity.section.categ.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_type_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="categ_id"/>
<field name="type_id"/>
<field name="stage_id"/>
<field name="delay_close"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_opportunity_section_categ_type_graph">
<field name="name">CRM Report - Section, Category and Type(Select)</field>
<field name="model">report.crm.opportunity.section.categ.type</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Opportunity by Section, Category and Type" type="bar" orientation="horizontal">
<field name="type_id"/>
<field name="nbr" operator="+"/>
<field name="section_id" group="True"/>
</graph>
</field>
</record>
<record id="view_crm_opportunity_section_categ_type_filter" model="ir.ui.view">
<field name="name">CRM Report - Section, Category and Type(Select)</field>
<field name="model">report.crm.opportunity.section.categ.type</field>
<field name="inherit_id" ref="view_crm_case_section_categ_type_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="section_id" position="after">
<field name="categ_id" select="1"/>
<field name="type_id" select="1"/>
<field name="stage_id" select="1"/>
</field>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_opportunity_section_categ_type_tree">
<field name="res_model">report.crm.opportunity.section.categ.type</field>
<field name="name">Opportunity by section, category and type</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="search_view_id" ref="view_crm_opportunity_section_categ_type_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_opportunity_section_categ_type_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_opportunity_section_categ_type_graph"/>
<field name="act_window_id" ref="action_report_crm_opportunity_section_categ_type_tree"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_opportunity_section_categ_type_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_opportunity_section_categ_type_tree"/>
<field name="act_window_id" ref="action_report_crm_opportunity_section_categ_type_tree"/>
</record>
<menuitem action="action_report_crm_opportunity_section_categ_type_tree" id="menu_crm_opportunity_section_categ_type_tree" parent="menu_crm_opportunity_tree"/>
<menuitem name="Opportunities" action="action_report_crm_opportunity" id="menu_crm_opportunity_tree" parent="base.next_id_64"/>
</data>
</openerp>
+10 -90
View File
@@ -1,18 +1,19 @@
from osv import fields,osv
import tools
class report_crm_phonecall_user(osv.osv):
_name = "report.crm.phonecall.user"
class report_crm_phonecall(osv.osv):
_name = "report.crm.phonecall"
_description = "Phone calls by user and section"
_auto = False
_inherit = "report.crm.case.user"
_inherit = "report.crm.case"
_columns = {
'delay_close': fields.char('Delay to close', size=20, readonly=True),
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.phonecall')]"),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_crm_phonecall_user')
tools.drop_view_if_exists(cr, 'report_crm_phonecall')
cr.execute("""
create or replace view report_crm_phonecall_user as (
create or replace view report_crm_phonecall as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
@@ -20,96 +21,15 @@ class report_crm_phonecall_user(osv.osv):
c.state,
c.user_id,
c.section_id,
count(*) as nbr,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_phonecall 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_phonecall_user()
class report_crm_phonecall_categ(osv.osv):
_name = "report.crm.phonecall.categ"
_description = "Phone calls 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.phonecall')]"),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_crm_phonecall_categ')
cr.execute("""
create or replace view report_crm_phonecall_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,
count(*) as nbr,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_phonecall c
group by c.categ_id,to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state,c.section_id
)""")
report_crm_phonecall_categ()
class report_crm_phonecall_section(osv.osv):
_name = "report.crm.phonecall.section"
_description = "Phone calls 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_phonecall 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_phonecall_section')
cr.execute("""
create or replace view report_crm_phonecall_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,
count(*) as nbr,
0 as avg_answers,
0.0 as perc_done,
0.0 as perc_cancel,
0.0 as perc_cancel,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_phonecall c
group by to_char(c.create_date, 'YYYY'),to_char(c.create_date, 'MM'),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
)""")
report_crm_phonecall_section()
report_crm_phonecall()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+48 -145
View File
@@ -5,24 +5,27 @@
Phone calls by user and section
-->
<record id="view_crm_phonecall_user_tree" model="ir.ui.view">
<field name="name">report.crm.phonecall.user.tree</field>
<field name="model">report.crm.phonecall.user</field>
<field name="inherit_id" ref="view_crm_case_user_tree"/>
<record id="view_crm_phonecall_tree" model="ir.ui.view">
<field name="name">report.crm.phonecall.tree</field>
<field name="model">report.crm.phonecall</field>
<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_revenue_prob"/>
<field name="probability"/>
</field>
<tree string="Phone calls">
<field name="name" />
<field name="month"/>
<field name="nbr" string="#Phone calls" />
<field name="delay_close"/>
<field name="state" invisible="1"/>
<field name="section_id" invisible="1"/>
<field name="user_id" invisible="1"/>
<field name="categ_id" invisible="1"/>
</tree>
</field>
</record>
<record id="view_crm_phonecall_user_form" model="ir.ui.view">
<field name="name">report.crm.phonecall.user.form</field>
<field name="model">report.crm.phonecall.user</field>
<field name="inherit_id" ref="view_crm_case_user_form"/>
<record id="view_crm_phonecall_form" model="ir.ui.view">
<field name="name">report.crm.phonecall.form</field>
<field name="model">report.crm.phonecall</field>
<field name="inherit_id" ref="view_crm_case_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
@@ -34,9 +37,9 @@
</field>
</record>
<record id="view_crm_phonecall_user_graph" model="ir.ui.view">
<field name="name">report.crm.phonecall.user.graph</field>
<field name="model">report.crm.phonecall.user</field>
<record id="view_crm_phonecall_graph" model="ir.ui.view">
<field name="name">report.crm.phonecall.graph</field>
<field name="model">report.crm.phonecall</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Phone calls by User and Section" type="bar">
@@ -45,143 +48,43 @@
<field group="True" name="user_id"/>
</graph>
</field>
</record>
</record>
<record id="view_crm_phonecall_user_filter" model="ir.ui.view">
<field name="name">report.crm.phonecall.user.select</field>
<field name="model">report.crm.phonecall.user</field>
<field name="inherit_id" ref="view_crm_case_user_filter"/>
<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="state" position="before">
<field name="user_id" position="before">
</field>
</field>
</record>
</record>
<record id="action_report_crm_phonecall_user_tree" model="ir.actions.act_window">
<field name="name">Phone calls by User and Section</field>
<field name="res_model">report.crm.phonecall.user</field>
<record id="action_report_crm_phonecall" model="ir.actions.act_window">
<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>
<field name="view_id" ref="view_crm_phonecall_user_graph"/>
<field name="search_view_id" ref="view_crm_phonecall_user_filter"/>
<field name="view_id" ref="view_crm_phonecall_graph"/>
<field name="search_view_id" ref="view_crm_phonecall_filter"/>
</record>
<menuitem name="Phone Calls" id="menu_crm_phonecalls_tree" parent="crm.next_id_52"/>
<menuitem action="action_report_crm_phonecall_user_tree" id="menu_crm_phonecall_user_tree" parent="menu_crm_phonecalls_tree"/>
<!-- # Phonecalls by section and category of case -->
<record model="ir.actions.act_window.view" id="action_report_crm_phonecall_tree">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_phonecall_tree"/>
<field name="act_window_id" ref="action_report_crm_phonecall"/>
</record>
<record id="view_crm_phonecall_categ_tree" model="ir.ui.view">
<field name="name">report.crm.phonecall.categ.tree</field>
<field name="model">report.crm.phonecall.categ</field>
<field name="inherit_id" ref="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_revenue_prob"/>
<field name="probability"/>
</field>
</field>
</record>
<record id="view_crm_phonecall_categ_form" model="ir.ui.view">
<field name="name">report.crm.phonecall.categ.form</field>
<field name="model">report.crm.phonecall.categ</field>
<field name="inherit_id" ref="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_revenue_prob"/>
<field name="probability"/>
</field>
</field>
</record>
<record id="view_crm_phonecall_categ_graph" model="ir.ui.view">
<field name="name">report.crm.phonecall.categ.graph</field>
<field name="model">report.crm.phonecall.categ</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Phone calls 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_phonecall_categ_filter" model="ir.ui.view">
<field name="name">report.crm.phonecall.categ.select</field>
<field name="model">report.crm.phonecall.categ</field>
<field name="inherit_id" ref="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_phonecall_categ_tree" model="ir.actions.act_window">
<field name="name">Phone calls by Categories and Section</field>
<field name="res_model">report.crm.phonecall.categ</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_crm_phonecall_categ_graph"/>
<field name="search_view_id" ref="view_crm_phonecall_categ_filter"/>
</record>
<menuitem action="action_report_crm_phonecall_categ_tree" id="menu_crm_phonecall_categ_tree" parent="menu_crm_phonecalls_tree"/>
<!-- Phone calls by Section -->
<record id="view_report_crm_phonecall_section_tree" model="ir.ui.view">
<field name="name">report.crm.phonecall.section.tree</field>
<field name="model">report.crm.phonecall.section</field>
<field name="inherit_id" ref="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_phonecall_section_graph" model="ir.ui.view">
<field name="name">report.crm.phonecall.section.graph</field>
<field name="model">report.crm.phonecall.section</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Phone calls by Section" type="bar">
<field name="name"/>
<field name="nbr_cases" operator="+"/>
</graph>
</field>
</record>
<record id="view_report_crm_phonecall_section_filter" model="ir.ui.view">
<field name="name">report.crm.phonecall.section.select</field>
<field name="model">report.crm.phonecall.section</field>
<field name="inherit_id" ref="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_phonecall_section_tree" model="ir.actions.act_window">
<field name="name">Phone calls by Section</field>
<field name="res_model">report.crm.phonecall.section</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_report_crm_phonecall_section_graph"/>
<field name="search_view_id" ref="view_report_crm_phonecall_section_filter"/>
</record>
<menuitem action="action_report_crm_phonecall_section_tree" id="menu_crm_phonecall_section_tree" parent="menu_crm_phonecalls_tree"/>
<record model="ir.actions.act_window.view" id="action_report_crm_phonecall_graph">
<field name="sequence" eval="1"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_crm_phonecall_graph"/>
<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="base.next_id_64"/>
</data>
</openerp>
+56 -391
View File
@@ -1,17 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<data>
<!--
Cases by user and section
-->
<record id="view_crm_case_user_tree" model="ir.ui.view">
<field name="name">report.crm.case.user.tree</field>
<field name="model">report.crm.case.user</field>
<record id="view_crm_case_tree" model="ir.ui.view">
<field name="name">report.crm.case.tree</field>
<field name="model">report.crm.case</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Cases by User and Section">
<tree string="Cases">
<field name="name" />
<field name="month"/>
<field name="user_id"/>
@@ -21,12 +17,12 @@
</tree>
</field>
</record>
<record id="view_crm_case_user_form" model="ir.ui.view">
<field name="name">report.crm.case.user.form</field>
<field name="model">report.crm.case.user</field>
<record id="view_crm_case_form" model="ir.ui.view">
<field name="name">report.crm.case.form</field>
<field name="model">report.crm.case</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Cases by User and Section">
<form string="Cases">
<field name="name" select="1"/>
<field name="month" select="1"/>
<field name="user_id" select="1"/>
@@ -37,9 +33,9 @@
</field>
</record>
<record id="view_crm_case_user_graph" model="ir.ui.view">
<field name="name">report.crm.case.user.graph</field>
<field name="model">report.crm.case.user</field>
<record id="view_crm_case_graph" model="ir.ui.view">
<field name="name">report.crm.case.graph</field>
<field name="model">report.crm.case</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Cases by User and Section" type="bar">
@@ -50,402 +46,71 @@
</field>
</record>
<record id="view_crm_case_user_filter" model="ir.ui.view">
<field name="name">report.crm.case.user.select</field>
<field name="model">report.crm.case.user</field>
<record id="view_crm_case_filter" model="ir.ui.view">
<field name="name">report.crm.case.select</field>
<field name="model">report.crm.case</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Cases by User">
<group col="12" colspan="4">
<filter string="My Cases" icon="terp-hr" domain="[('user_id','=',uid)]" help="My cases by section"/>
<separator orientation="vertical"/>
<search string="Search">
<group col="16" colspan="8">
<filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]"/>
<filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]"/>
<separator orientation="vertical"/>
<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="state" select="1"/>
<separator orientation="vertical"/>
<filter string="Current" icon="terp-hr" domain="[('state','in',('open','draft'))]"/>
<filter string="Won" icon="terp-hr" domain="[('state','=','done')]"/>
<filter string="Lost" icon="terp-hr" domain="[('state','=','cancel')]"/>
<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="user_id" widget="selection">
<filter icon="terp-partner"
domain="[('user_id','=',uid)]"
help="My " default="1"
/>
</field>
</group>
<newline/>
<group expand="1" string="Group By..." colspan="4" col="8">
<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'}"/>
</group>
</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_user_tree" model="ir.actions.act_window">
<field name="name">Cases by User and Section</field>
<field name="res_model">report.crm.case.user</field>
<record id="action_report_crm_case_tree" model="ir.actions.act_window">
<field name="name">Cases</field>
<field name="res_model">report.crm.case</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="search_view_id" ref="view_crm_case_user_filter"/>
<field name="search_view_id" ref="view_crm_case_filter"/>
</record>
<!--<menuitem action="action_report_crm_case_user_tree" id="menu_crm_case_user_tree" parent="crm.next_id_52"/>
-->
<!-- # Cases by section and categoryof case -->
<record id="view_crm_case_categ_tree" model="ir.ui.view">
<field name="name">report.crm.case.categ.tree</field>
<field name="model">report.crm.case.categ</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Cases by User and Section">
<field name="name"/>
<field name="section_id" select="1"/>
<field name="month"/>
<field name="nbr"/>
<field name="state"/>
</tree>
</field>
</record>
<record id="view_crm_case_categ_form" model="ir.ui.view">
<field name="name">report.crm.case.categ.form</field>
<field name="model">report.crm.case.categ</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Cases by User and Section">
<field name="name" select="1"/>
<field name="section_id" select="1"/>
<field name="month" select="1"/>
<field name="nbr" select="1"/>
<field name="state" select="1"/>
</form>
</field>
</record>
<record id="view_crm_case_categ_filter" model="ir.ui.view">
<field name="name">report.crm.case.categ.select</field>
<field name="model">report.crm.case.categ</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Cases by categories and Sections">
<group col="12" colspan="4">
<filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]"/>
<filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]"/>
<separator orientation="vertical"/>
<field name="name" select="1"/>
<field name="section_id" select="1"/>
<field name="nbr" select="1"/>
<field name="state" select="1"/>
</group>
</search>
</field>
</record>
<record id="action_report_crm_case_categ_tree" model="ir.actions.act_window">
<field name="name">Cases by Categories and Section</field>
<field name="res_model">report.crm.case.categ</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="search_view_id" ref="view_crm_case_categ_filter"/>
</record>
<!-- <menuitem action="action_report_crm_case_categ_tree" id="menu_crm_case_categ_tree" parent="crm.next_id_52"/>-->
<act_window domain="[('user_id', '=', active_id)]" id="act_res_users_2_report_crm_case_user" name="Monthly cases" res_model="report.crm.case.user" src_model="res.users"/>
<act_window domain="[('user_id', '=', active_id)]" id="act_res_users_2_report_crm_case_user" name="Monthly cases" res_model="report.crm.case" src_model="res.users"/>
<act_window domain="[('section_id', '=', active_id)]" id="act_crm_case_section_2_report_crm_case_user" name="Monthly cases by user" res_model="report.crm.case.user" src_model="crm.case.section"/>
<act_window domain="[('section_id', '=', active_id)]" id="act_crm_case_section_2_report_crm_case_user" name="Monthly cases by user" res_model="report.crm.case" src_model="crm.case.section"/>
<act_window domain="[('section_id', '=', active_id)]" id="act_crm_case_section_2_report_crm_case_categ" name="Monthly cases by section" res_model="report.crm.case.categ" src_model="crm.case.section"/>
<act_window domain="[('section_id', '=', active_id)]" id="act_crm_case_section_2_report_crm_case_categ" name="Monthly cases by section" res_model="report.crm.case" src_model="crm.case.section"/>
<!-- Cases by Section -->
<record id="view_report_crm_case_section_tree" model="ir.ui.view">
<field name="name">report.crm.case.section.tree</field>
<field name="model">report.crm.case.section</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Cases by Section">
<field name="name" select="1"/>
<field name="section_id" select="1"/>
<field name="month" select="1"/>
<field name="nbr_cases" select="1"/>
<field name="avg_answers"/>
</tree>
</field>
</record>
<record id="view_report_crm_case_section_graph" model="ir.ui.view">
<field name="name">report.crm.case.section.graph</field>
<field name="model">report.crm.case.section</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Cases by Section" type="bar">
<field name="name"/>
<field name="nbr_cases" operator="+"/>
</graph>
</field>
</record>
<record id="view_report_crm_case_section_filter" model="ir.ui.view">
<field name="name">report.crm.case.section.select</field>
<field name="model">report.crm.case.section</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Cases by Section">
<group col="8" colspan="4">
<filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]"/>
<filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]"/>
<separator orientation="vertical"/>
<field name="name" select="1"/>
<field name="section_id" select="1"/>
<field name="month" select="1"/>
<field name="nbr_cases" select="1"/>
</group>
</search>
</field>
</record>
<record id="action_report_crm_case_section_tree" model="ir.actions.act_window">
<field name="name">Cases by Section</field>
<field name="res_model">report.crm.case.section</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="search_view_id" ref="view_report_crm_case_section_filter"/>
</record>
#
# Cases by section and stage
#
<record model="ir.ui.view" id="view_crm_case_section_stage_tree">
<field name="name">CRM Report - Sections and Stage(Tree)</field>
<field name="model">report.crm.case.section.stage</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Cases by Section and Stage">
<field name="name"/>
<field name="month"/>
<field name="user_id"/>
<field name="section_id"/>
<field name="nbr"/>
<field name="state"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_crm_case_section_stage_form">
<field name="name">CRM Report - Sections and Stage(Form)</field>
<field name="model">report.crm.case.section.stage</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Cases by Section and Stage">
<field name="name"/>
<field name="month"/>
<field name="user_id"/>
<field name="section_id" select="1" widget="selection"/>
<field name="nbr" select="1"/>
<field name="state" select="1"/>
</form>
</field>
</record>
<record id="view_crm_case_section_stage_filter" model="ir.ui.view">
<field name="name">CRM Report - Sections and Stage(Select)</field>
<field name="model">report.crm.case.section.stage</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Cases by Section and Stage">
<group col="8" colspan="4">
<filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]" help="Cases by Section and Stage for this year"/>
<filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]" help="Cases by Section and Stage for this month"/>
<separator orientation="vertical"/>
<field name="section_id" select="1" widget="selection"/>
<field name="nbr" select="1"/>
<field name="state" select="1"/>
</group>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_case_section_stage_tree">
<field name="res_model">report.crm.case.section.stage</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="search_view_id" ref="view_crm_case_section_stage_filter"/>
</record>
#
# Cases by section and type of case
#
<record model="ir.ui.view" id="view_crm_case_section_categ_tree">
<field name="name">CRM Report - Sections and Type(Tree)</field>
<field name="model">report.crm.case.section.type</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Cases by Section and Type">
<field name="name"/>
<field name="month"/>
<field name="user_id"/>
<field name="section_id"/>
<field name="nbr"/>
<field name="state"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_crm_case_section_categ_form">
<field name="name">CRM Report - Sections and Type(Form)</field>
<field name="model">report.crm.case.section.type</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Cases by Section and Type">
<field name="name"/>
<field name="month"/>
<field name="user_id"/>
<field name="section_id" select="1" widget="selection"/>
<field name="nbr" select="1"/>
<field name="state" select="1"/>
</form>
</field>
</record>
<record id="view_crm_case_section_categ_filter" model="ir.ui.view">
<field name="name">CRM Report - Sections and Type(Select)</field>
<field name="model">report.crm.case.section.type</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Cases by Section and Type">
<group col="10" colspan="4">
<filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]" help="Cases by Section and Type for this year"/>
<filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]" help="Cases by Section and Type for this month"/>
<separator orientation="vertical"/>
<field name="section_id" select="1" widget="selection"/>
<field name="nbr" select="1"/>
<field name="state" select="1"/>
</group>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_case_section_categ_tree">
<field name="res_model">report.crm.case.section.type</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="search_view_id" ref="view_crm_case_section_categ_filter"/>
</record>
#
# Cases by section, category and stage
#
<record model="ir.ui.view" id="view_crm_case_section_categ_stage_tree">
<field name="name">CRM Report - Section, Category and Stage(Tree)</field>
<field name="model">report.crm.case.section.categ.stage</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Cases by Section, Category and Stage">
<field name="name"/>
<field name="month"/>
<field name="user_id"/>
<field name="section_id"/>
<field name="nbr"/>
<field name="state"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_crm_case_section_categ_stage_form">
<field name="name">CRM Report - Section, Category and Stage(Form)</field>
<field name="model">report.crm.case.section.categ.stage</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Cases by Section, Category and Stage">
<field name="name"/>
<field name="month"/>
<field name="user_id"/>
<field name="section_id" select="1" widget="selection"/>
<field name="nbr" select="1"/>
<field name="state" select="1"/>
</form>
</field>
</record>
<record id="view_crm_case_section_categ_stage_filter" model="ir.ui.view">
<field name="name">CRM Report - Section, Category and Stage(Select)</field>
<field name="model">report.crm.case.section.categ.stage</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Cases by Section, Category and Stage">
<group col='8' colspan='4'>
<filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]" help="Cases by Section, Category and Stage for this year"/>
<filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]" help="Cases by Section, Category and Stage for this month"/>
<separator orientation="vertical"/>
<field name="section_id" select="1" widget="selection"/>
<field name="nbr" select="1"/>
<field name="state" select="1"/>
</group>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_case_section_categ_stage_tree">
<field name="res_model">report.crm.case.section.categ.stage</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="search_view_id" ref="view_crm_case_section_categ_stage_filter"/>
</record>
#
# Cases by section, category and type
#
<record model="ir.ui.view" id="view_crm_case_section_categ_type_tree">
<field name="name">CRM Report - Section, Category and Type(Tree)</field>
<field name="model">report.crm.case.section.categ.type</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Cases by Section, Category and Type">
<field name="name"/>
<field name="month"/>
<field name="user_id"/>
<field name="section_id"/>
<field name="nbr"/>
<field name="state"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_crm_case_section_categ_type_form">
<field name="name">CRM Report - Section, Category and Type(Form)</field>
<field name="model">report.crm.case.section.categ.type</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Cases by Section, Category and Type">
<field name="name"/>
<field name="month"/>
<field name="user_id"/>
<field name="section_id" select="1" widget="selection"/>
<field name="nbr" select="1"/>
<field name="state" select="1"/>
</form>
</field>
</record>
<record id="view_crm_case_section_categ_type_filter" model="ir.ui.view">
<field name="name">CRM Report - Section, Category and Type(Select)</field>
<field name="model">report.crm.case.section.categ.type</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Cases by User">
<group col='12' colspan='4'>
<filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]" help="Cases by User for this year"/>
<filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]" help="Cases by User for this month"/>
<separator orientation="vertical"/>
<field name="section_id" select="1" widget="selection"/>
<field name="nbr" select="1"/>
<field name="state" select="1"/>
</group>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_crm_case_section_categ_type_tree">
<field name="res_model">report.crm.case.section.categ.type</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="search_view_id" ref="view_crm_case_section_categ_type_filter"/>
</record>
<!-- Closed & Open CRM Case view for Random Activities dashboard -->
+7 -7
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
@@ -15,7 +15,7 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@@ -29,7 +29,7 @@
"description": """
Module for resource management. You can manage:
* Leave/Holidays or Days off of the company
""",
'author': 'Tiny',
'website': 'http://www.openerp.com',
@@ -37,11 +37,11 @@
'init_xml': [],
'update_xml': [
#'security/resource_security.xml',
# 'security/ir.model.access.csv',
'resource_view.xml',
# 'security/ir.model.access.csv',
'resource_view.xml',
],
'demo_xml': ['resource_demo.xml'
],
'demo_xml': [#'resource_demo.xml'
],
'installable': True,
'active': False,
'certificate': None,
+22 -23
View File
@@ -37,16 +37,16 @@ class resource_calendar(osv.osv):
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'resource.calendar', c)
}
def interval_min_get(self, cr, uid, id, dt_from, hours,resource=False):
def interval_min_get(self, cr, uid, id, dt_from, hours, resource=False):
resource_cal_leaves = self.pool.get('resource.calendar.leaves')
dt_leave = []
if not id:
return [(dt_from-mx.DateTime.RelativeDateTime(hours=int(hours)*3), dt_from)]
resource_leave_ids = resource_cal_leaves.search(cr,uid,[('calendar_id','=',id),'|',('resource_id','=',False),('resource_id','=',resource)])
res_leaves = resource_cal_leaves.read(cr,uid,resource_leave_ids,['date_from','date_to'])
return [(dt_from - mx.DateTime.RelativeDateTime(hours=int(hours)*3), dt_from)]
resource_leave_ids = resource_cal_leaves.search(cr, uid, [('calendar_id','=',id), '|', ('resource_id','=',False), ('resource_id','=',resource)])
res_leaves = resource_cal_leaves.read(cr, uid, resource_leave_ids, ['date_from', 'date_to'])
for leave in res_leaves:
dtf = mx.DateTime.strptime(leave['date_from'],'%Y-%m-%d %H:%M:%S')
dtt = mx.DateTime.strptime(leave['date_to'],'%Y-%m-%d %H:%M:%S')
dtf = mx.DateTime.strptime(leave['date_from'], '%Y-%m-%d %H:%M:%S')
dtt = mx.DateTime.strptime(leave['date_to'], '%Y-%m-%d %H:%M:%S')
no = dtt - dtf
[dt_leave.append((dtf + mx.DateTime.RelativeDateTime(days=x)).strftime('%Y-%m-%d')) for x in range(int(no.days + 1))]
dt_leave.sort()
@@ -72,8 +72,8 @@ class resource_calendar(osv.osv):
if leave_flag:
break
else:
d1 = mx.DateTime.DateTime(dt_from.year,dt_from.month,dt_from.day,int(math.floor(hour_from)),int((hour_from%1) * 60))
d2 = mx.DateTime.DateTime(dt_from.year,dt_from.month,dt_from.day,int(math.floor(m)),int((m%1) * 60))
d1 = mx.DateTime.DateTime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(hour_from)), int((hour_from%1) * 60))
d2 = mx.DateTime.DateTime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(m)), int((m%1) * 60))
result.append((d1, d2))
current_hour = hour_from
todo -= (m-hour_from)
@@ -87,16 +87,15 @@ class resource_calendar(osv.osv):
resource_cal_leaves = self.pool.get('resource.calendar.leaves')
dt_leave = []
if not id:
return [(dt_from,dt_from+mx.DateTime.RelativeDateTime(hours=int(hours)*3))]
resource_leave_ids = resource_cal_leaves.search(cr,uid,[('calendar_id','=',id),'|',('resource_id','=',False),('resource_id','=',resource)])
res_leaves = resource_cal_leaves.read(cr,uid,resource_leave_ids,['date_from','date_to'])
return [(dt_from,dt_from + mx.DateTime.RelativeDateTime(hours=int(hours)*3))]
resource_leave_ids = resource_cal_leaves.search(cr, uid, [('calendar_id','=',id), '|', ('resource_id','=',False), ('resource_id','=',resource)])
res_leaves = resource_cal_leaves.read(cr, uid, resource_leave_ids, ['date_from', 'date_to'])
for leave in res_leaves:
dtf = mx.DateTime.strptime(leave['date_from'],'%Y-%m-%d %H:%M:%S')
dtt = mx.DateTime.strptime(leave['date_to'],'%Y-%m-%d %H:%M:%S')
dtf = mx.DateTime.strptime(leave['date_from'], '%Y-%m-%d %H:%M:%S')
dtt = mx.DateTime.strptime(leave['date_to'], '%Y-%m-%d %H:%M:%S')
no = dtt - dtf
[dt_leave.append((dtf + mx.DateTime.RelativeDateTime(days=x)).strftime('%Y-%m-%d')) for x in range(int(no.days + 1))]
dt_leave.sort()
print 'dtLevae',dt_leave
todo = hours
cycle = 0
result = []
@@ -113,13 +112,13 @@ class resource_calendar(osv.osv):
dt_check = dt_from.strftime('%Y-%m-%d')
for leave in dt_leave:
if dt_check == leave:
dt_check = mx.DateTime.strptime(dt_check,"%Y-%m-%d") + mx.DateTime.RelativeDateTime(days=1)
dt_check = mx.DateTime.strptime(dt_check, "%Y-%m-%d") + mx.DateTime.RelativeDateTime(days=1)
leave_flag = True
if leave_flag:
break
else:
d1 = mx.DateTime.DateTime(dt_from.year,dt_from.month,dt_from.day,int(math.floor(m)),int((m%1) * 60))
d2 = mx.DateTime.DateTime(dt_from.year,dt_from.month,dt_from.day,int(math.floor(hour_to)),int((hour_to%1) * 60))
d1 = mx.DateTime.DateTime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(m)), int((m%1) * 60))
d2 = mx.DateTime.DateTime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(hour_to)), int((hour_to%1) * 60))
result.append((d1, d2))
current_hour = hour_to
todo -= (hour_to - m)
@@ -170,11 +169,11 @@ class resource_resource(osv.osv):
if context.get('project_id',False):
project_pool = self.pool.get('project.project')
project_rec = project_pool.browse(cr,uid,context['project_id'])
project_rec = project_pool.browse(cr, uid, context['project_id'])
user_ids = [user_id.id for user_id in project_rec.members]
args.append(('user_id','in',user_ids))
return super(resource_resource, self).search(cr, uid, args, offset, limit,order, context, count)
return super(resource_resource, self).search(cr, uid, args, offset, limit, order, context, count)
resource_resource()
class resource_calendar_leaves(osv.osv):
@@ -189,7 +188,7 @@ class resource_calendar_leaves(osv.osv):
'resource_id' : fields.many2one("resource.resource", "Resource", help="If empty, this is a generic holiday for the company. If a resource is set, the holiday/leave is only for this resource"),
}
def check_dates(self, cr, uid, ids):
leave = self.read(cr, uid, ids[0],['date_from','date_to'])
leave = self.read(cr, uid, ids[0], ['date_from', 'date_to'])
if leave['date_from'] and leave['date_to']:
if leave['date_from'] > leave['date_to']:
return False
@@ -203,9 +202,9 @@ class resource_calendar_leaves(osv.osv):
result = {}
if resource:
resource_pool = self.pool.get('resource.resource')
result['calendar_id'] = resource_pool.browse(cr,uid,resource).calendar_id.id
return {'value':result}
return {'value':{'calendar_id':[]}}
result['calendar_id'] = resource_pool.browse(cr, uid, resource).calendar_id.id
return {'value': result}
return {'value': {'calendar_id': []}}
resource_calendar_leaves()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+83
View File
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Example employee -->
<record id="timesheet_group1" model="resource.calendar">
<field name="name">38 Hours/Week</field>
</record>
<record model="resource.calendar.week">
<field name="name">Monday morning</field>
<field name="dayofweek">0</field>
<field name="hour_from">08</field>
<field name="hour_to">12</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Monday evening</field>
<field name="dayofweek">0</field>
<field name="hour_from">13</field>
<field name="hour_to">18</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Tuesday morning</field>
<field name="dayofweek">1</field>
<field name="hour_from">08</field>
<field name="hour_to">12</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Tuesday evening</field>
<field name="dayofweek">1</field>
<field name="hour_from">13</field>
<field name="hour_to">18</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Wednesday morning</field>
<field name="dayofweek">2</field>
<field name="hour_from">08</field>
<field name="hour_to">12</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Wednesday evening</field>
<field name="dayofweek">2</field>
<field name="hour_from">13</field>
<field name="hour_to">18</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Thursday morning</field>
<field name="dayofweek">3</field>
<field name="hour_from">08</field>
<field name="hour_to">12</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Thursday evening</field>
<field name="hour_from">13</field>
<field name="hour_to">18</field>
<field name="dayofweek">3</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Friday morning</field>
<field name="dayofweek">4</field>
<field name="hour_from">08</field>
<field name="hour_to">12</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
<record model="resource.calendar.week">
<field name="name">Friday evening</field>
<field name="dayofweek">4</field>
<field name="hour_from">13</field>
<field name="hour_to">18</field>
<field name="calendar_id" ref="timesheet_group1"/>
</record>
</data>
</openerp>
+1 -14
View File
@@ -120,8 +120,7 @@
<field name="view_mode">tree,form</field>
</record>
<menuitem id="base.menu_pm_planning" name="Planning" parent="base.menu_main" sequence="3"/>
<menuitem action="action_resource_resource_tree" id="base.menu_resource_resource_tree" parent="base.menu_pm_planning" />
<menuitem action="action_resource_resource_tree" id="base.menu_resource_resource_tree" parent="base.menu_pm_resources" />
<record id="resource_calendar_leave_form" model="ir.ui.view">
<field name="name">resource.calendar.leaves.form</field>
@@ -161,17 +160,5 @@
<menuitem action="action_resource_calendar_leave_tree" id="menu_resource_calendar_leave_tree" parent="base.menu_pm_resources"/>
<!-- project member -->
<record id="view_project_member_tree" model="ir.ui.view">
<field name="name">project.member.tree</field>
<field name="model">resource.resource</field>
<field name="type">tree</field>
<field eval="99" name="priority"/>
<field name="arch" type="xml">
<tree string="Project's Members">
<field name="name"/>
</tree>
</field>
</record>
</data>
</openerp>
+1 -9
View File
@@ -85,13 +85,5 @@
<field name="act_window_id" ref="action_order_report_tree_all"/>
</record>
<menuitem id="base.next_id_64" name="Reporting" parent="base.menu_base_partner" sequence="8"/>
<menuitem id="sale_reporting_menu" name="Sale" parent="base.next_id_64" sequence="8"/>
<menuitem action="action_sale_order_report_all" id="menu_report_sale_order_all" parent="sale.sale_reporting_menu" sequence="3"/>
<menuitem action="action_order_report_tree_all" id="menu_report_order_product_all1" parent="sale.sale_reporting_menu" sequence="4"/>
</data>
</openerp>
</openerp>
+20
View File
@@ -408,6 +408,25 @@
</field>
</record>
<record id="view_sales_order_uninvoiced_line_filter" model="ir.ui.view">
<field name="name">sale.order.uninvoiced.line</field>
<field name="model">sale.order.line</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Uninvoiced Lines">
<field name="order_id" select="1"/>
<field name="product_id" select="1"/>
<newline />
<group expand="1" string="Group By..." colspan="9" col="8">
<filter string="Product" icon="terp-sale" default="1" domain="[]" context="{'group_by':'product_id'}"/>
<!--
<filter string="Customer" icon="terp-sale" domain="[]" context="{'group_by':'order_partner_id'}"/>
-->
</group>
</search>
</field>
</record>
<record id="action_order_line_tree2" model="ir.actions.act_window">
<field name="name">Uninvoiced Lines</field>
<field name="type">ir.actions.act_window</field>
@@ -415,6 +434,7 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form,graph</field>
<field name="domain">[('invoiced','&lt;&gt;', 1),('state','&lt;&gt;','draft'),('state','&lt;&gt;','cancel')]</field>
<field name="search_view_id" ref="view_sales_order_uninvoiced_line_filter" />
<field name="filter" eval="True"/>
</record>
+6 -6
View File
@@ -78,7 +78,7 @@
<field colspan="4" name="note" nolabel="1"/>
</page>
<page string="Tasks">
<field colspan="4" name="tasks_id" nolabel="1" widget="one2many_list"/>
<field colspan="4" name="tasks_id" nolabel="1" widget="one2many_list" context="{'default_project_id':project_id, 'default_sprint_id':sprint_id, 'default_product_backlog_id':active_id}"/>
</page>
</notebook>
<group col="7" colspan="4">
@@ -103,7 +103,7 @@
<filter default="1"
icon="terp-project"
string="Current"
domain="[('sprint_id.date_start','&lt;=',time.strftime('%%Y-%%m-%%d')), ('sprint_id.date_stop','&gt;=',time.strftime('%%Y-%%m-%%d')), ('state','in',['draft','open'])]"
domain="['|','&amp;',('sprint_id.date_start','&lt;=',time.strftime('%%Y-%%m-%%d')), ('sprint_id.date_stop','&gt;=',time.strftime('%%Y-%%m-%%d')), ('state','in',['draft','open'])]"
help="Current Backlogs"/>
<separator orientation="vertical"/>
<filter icon="terp-project" string="Draft" domain="[('state','=','draft')]" help="Draft Backlogs"/>
@@ -184,17 +184,17 @@
<notebook colspan="4">
<page string="Sprint Info">
<group colspan="2" col="2">
<separator string="Owners"/>
<separator string="Owners" colspan="2"/>
<field name="product_owner_id"/>
<field name="scrum_master_id"/>
</group>
<group colspan="2" col="2">
<separator string="Dates"/>
<separator string="Dates" colspan="2"/>
<field name="date_start" select="1"/>
<field name="date_stop"/>
</group>
<group colspan="2" col="2">
<separator string="Planning"/>
<separator string="Planning" colspan="2"/>
<field name="planned_hours" widget="float_time"/>
<field name="expected_hours" widget="float_time"/>
<field name="effective_hours" widget="float_time"/>
@@ -456,7 +456,7 @@
<field name="arch" type="xml">
<field name="project_id" position="after">
<field name="sprint_id" widget="selection" context="{'sprint_invisible':False}">
<filter icon="terp-project" string="Current" context="{'sprint_invisible':False}" domain="[('state','=','open')]" help="Current Sprints"/>
<filter icon="terp-project" string="Current" context="{'sprint_invisible':False}" domain="[('sprint_id.state','in',('draft','open'))]" help="Current Sprints"/>
</field>
</field>
</field>
+1 -1
View File
@@ -48,7 +48,7 @@ def _do_create(self, cr, uid, data, context):
'name': backlog.name,
'description': backlog.note,
'project_id': backlog.project_id.id,
'user_id': (backlog.user_id and backlog.user_id.id) or uid,
'user_id': data['form']['user_id'] or (backlog.user_id and backlog.user_id.id) or uid,
'planned_hours': backlog.planned_hours
}))
+1 -1
View File
@@ -1579,7 +1579,7 @@ class survey_request(osv.osv):
'user_id' : fields.many2one("res.users", "User"),
'email' : fields.char("E-mail", size=64),
'survey_id' : fields.many2one("survey", "Survey", required=1),
'answer_ids' : fields.one2many('survey.answer', 'question_id', 'Answer'),
'response' : fields.many2one('survey.response', 'Answer'),
'state' : fields.selection([('waiting_answer', 'Wating Answer'),('done', 'Done'),('cancel', 'Cancelled')], 'State', readonly=1)
}
_defaults = {
+1 -1
View File
@@ -1022,7 +1022,7 @@
<field name="survey_id" widget="selection"/>
<field name="user_id" on_change="on_change_user(user_id)"/>
<field name="email"/>
<field name="answer_ids" nolabel="1" colspan="4"/>
<field name="response"/>
<group colspan="4" col="5">
<field name="state"/>
<button name="survey_req_waiting_answer" string="Set to Watting Answer" states="cancel,done" type="object" icon="gtk-new"/>