[IMP]: crm: Apply doc string + optimization

bzr revid: ksa@tinyerp.co.in-20100322104026-ek83y39e88bx9zrw
This commit is contained in:
ksa (Open ERP) 2010-03-22 16:10:26 +05:30
parent a91dadcc9f
commit e189ccd665
34 changed files with 1413 additions and 977 deletions

View File

@ -116,6 +116,7 @@ class crm_case_section(osv.osv):
return []
reads = self.read(cr, uid, ids, ['name', 'parent_id'], context)
res = []
for record in reads:
name = record['name']
if record['parent_id']:
@ -178,9 +179,11 @@ class crm_case_resource_type(osv.osv):
object_id = context and context.get('object_id', False) or False
ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', object_id)])
return ids and ids[0]
_defaults = {
'object_id' : _find_object_id
}
crm_case_resource_type()
@ -215,6 +218,7 @@ class crm_case_stage(osv.osv):
object_id = context and context.get('object_id', False) or False
ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', object_id)])
return ids and ids[0]
_defaults = {
'sequence': lambda *args: 1,
'probability': lambda *args: 0.0,
@ -295,11 +299,14 @@ class crm_case(osv.osv):
if 'history_line' in field_names:
history_obj = self.pool.get('crm.case.history')
name = 'history_line'
if 'log_ids' in field_names:
history_obj = self.pool.get('crm.case.log')
name = 'log_ids'
if not history_obj:
return result
for case in self.browse(cr, uid, ids, context):
model_ids = model_obj.search(cr, uid, [('model', '=', case._name)])
history_ids = history_obj.search(cr, uid, [('model_id', '=', model_ids[0]),\
@ -495,6 +502,7 @@ class crm_case(osv.osv):
s = self.get_stage_dict(cr, uid, ids, context=context)
for case in self.browse(cr, uid, ids, context):
section = (case.section_id.id or False)
if section in s:
st = case.stage_id.id or False
s[section] = dict([(v, k) for (k, v) in s[section].iteritems()])
@ -519,8 +527,10 @@ class crm_case(osv.osv):
value = {}
if not name:
value['name'] = case.name
if (not partner_id) and case.partner_id:
value['partner_id'] = case.partner_id.id
if case.partner_address_id:
value['partner_address_id'] = case.partner_address_id.id
if case.email_from:
@ -552,6 +562,7 @@ class crm_case(osv.osv):
model_obj = self.pool.get('ir.model')
for case in cases:
model_ids = model_obj.search(cr, uid, [('model', '=', case._name)])
data = {
@ -562,6 +573,7 @@ class crm_case(osv.osv):
'res_id': case.id,
'section_id': case.section_id.id
}
obj = self.pool.get('crm.case.log')
if history:
obj = self.pool.get('crm.case.history')
@ -636,12 +648,15 @@ class crm_case(osv.osv):
if not case.email_from:
raise osv.except_osv(_('Error!'),
_('You must put a Partner eMail to use this action!'))
if not case.user_id:
raise osv.except_osv(_('Error!'),
_('You must define a responsible user for this case in order to use this action!'))
if not case.description:
raise osv.except_osv(_('Error!'),
_('Can not send mail with empty body,you should have description in the body'))
self.__history(cr, uid, cases, _('Send'), history=True, email=False)
for case in cases:
self.write(cr, uid, [case.id], {
@ -735,6 +750,7 @@ class crm_case(osv.osv):
cases = self.browse(cr, uid, ids)
for case in cases:
data = {'active': True, 'user_id': False}
if case.section_id.parent_id:
data['section_id'] = case.section_id.parent_id.id
if case.section_id.parent_id.user_id:
@ -868,6 +884,7 @@ class crm_case_history(osv.osv):
res[hist.id] = (hist.email or '/') + ' (' + str(hist.date) + ')\n'
res[hist.id] += (hist.description or '')
return res
_columns = {
'description': fields.text('Description'),
'note': fields.function(_note_get, method=True, string="Description", type="text"),
@ -944,6 +961,7 @@ class crm_email_add_cc_wizard(osv.osv_memory):
openobject_id = str(case.id),
subtype = "html"
)
if flag:
model_pool.write(cr, uid, case.id, {'email_cc' : case.email_cc and case.email_cc + ',' + email or email})
else:

View File

@ -27,26 +27,47 @@ import tools
import mx.DateTime
from tools.translate import _
from osv import fields
from osv import osv
from osv import fields
from osv import osv
from osv import orm
from osv.orm import except_orm
import crm
class case(osv.osv):
""" Case """
_inherit = 'crm.case'
_description = 'case'
_columns = {
'date_action_last': fields.datetime('Last Action', readonly=1),
'date_action_next': fields.datetime('Next Action', readonly=1),
}
def remind_partner(self, cr, uid, ids, context={}, attach=False):
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of Remind Partner's IDs
@param context: A standard dictionary for contextual values
"""
return self.remind_user(cr, uid, ids, context, attach,
destination=False)
def remind_user(self, cr, uid, ids, context={}, attach=False,
destination=True):
def remind_user(self, cr, uid, ids, context={}, attach=False,destination=True):
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of Remind user's IDs
@param context: A standard dictionary for contextual values
"""
for case in self.browse(cr, uid, ids):
if not case.section_id.reply_to:
raise osv.except_osv(_('Error!'), ("Reply To is not specified in Section"))
@ -83,34 +104,40 @@ class case(osv.osv):
raise osv.except_osv(_('Email!'),("Email Successfully Sent"))
else:
raise osv.except_osv(_('Email Fail!'),("Email is not sent successfully"))
return True
return True
def _check(self, cr, uid, ids=False, context={}):
'''
"""
Function called by the scheduler to process cases for date actions
Only works on not done and cancelled cases
'''
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values
"""
cr.execute('select * from crm_case \
where (date_action_last<%s or date_action_last is null) \
and (date_action_next<=%s or date_action_next is null) \
and state not in (\'cancel\',\'done\')',
(time.strftime("%Y-%m-%d %H:%M:%S"),
time.strftime('%Y-%m-%d %H:%M:%S')))
ids2 = map(lambda x: x[0], cr.fetchall() or [])
cases = self.browse(cr, uid, ids2, context)
return self._action(cr, uid, cases, False, context=context)
def _action(self, cr, uid, cases, state_to, scrit=None, context={}):
ids2 = map(lambda x: x[0], cr.fetchall() or [])
cases = self.browse(cr, uid, ids2, context)
return self._action(cr, uid, cases, False, context=context)
def _action(self, cr, uid, cases, state_to, scrit=None, context={}):
if not context:
context = {}
context['state_to'] = state_to
context['state_to'] = state_to
rule_obj = self.pool.get('base.action.rule')
model_obj = self.pool.get('ir.model')
model_ids = model_obj.search(cr, uid, [('model','=',self._name)])
model_ids = model_obj.search(cr, uid, [('model','=',self._name)])
rule_ids = rule_obj.search(cr, uid, [('name','=',model_ids[0])])
return rule_obj._action(cr, uid, rule_ids, cases, scrit=scrit, context=context)
def format_body(self, body):
def format_body(self, body):
return self.pool.get('base.action.rule').format_body(body)
def format_mail(self, obj, body):
@ -118,12 +145,19 @@ class case(osv.osv):
case()
class base_action_rule(osv.osv):
""" Base Action Rule """
_inherit = 'base.action.rule'
_description = 'Action Rules'
def do_check(self, cr, uid, action, obj, context={}):
""" @param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values"""
ok = super(base_action_rule, self).do_check(cr, uid, action, obj, context=context)
if hasattr(obj, 'section_id'):
ok = ok and (not action.trg_section_id or action.trg_section_id.id==obj.section_id.id)
if hasattr(obj, 'categ_id'):
@ -143,13 +177,19 @@ class base_action_rule(osv.osv):
return ok
def do_action(self, cr, uid, action, model_obj, obj, context={}):
res = super(base_action_rule, self).do_action(cr, uid, action, model_obj, obj, context=context)
""" @param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values """
res = super(base_action_rule, self).do_action(cr, uid, action, model_obj, obj, context=context)
write = {}
if action.act_section_id:
obj.section_id = action.act_section_id
write['section_id'] = action.act_section_id.id
write['section_id'] = action.act_section_id.id
if hasattr(obj, 'email_cc') and action.act_email_cc:
if '@' in (obj.email_cc or ''):
emails = obj.email_cc.split(",")
@ -157,9 +197,10 @@ class base_action_rule(osv.osv):
write['email_cc'] = obj.email_cc+','+obj.act_email_cc
else:
write['email_cc'] = obj.act_email_cc
model_obj.write(cr, uid, [obj.id], write, context)
emails = []
if hasattr(obj, 'email_from') and action.act_mail_to_partner:
emails.append(obj.email_from)
emails = filter(None, emails)
@ -167,29 +208,44 @@ class base_action_rule(osv.osv):
emails = list(set(emails))
self.email_send(cr, uid, obj, emails, action.act_mail_body)
return True
base_action_rule()
class base_action_rule_line(osv.osv):
""" Base Action Rule Line """
_inherit = 'base.action.rule.line'
_description = 'Base Action Rule Line'
def state_get(self, cr, uid, context={}):
res = super(base_action_rule_line, self).state_get(cr, uid, context=context)
"""@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values """
res = super(base_action_rule_line, self).state_get(cr, uid, context=context)
return res + [('escalate','Escalate')] + crm.AVAILABLE_STATES
def priority_get(self, cr, uid, context={}):
res = super(base_action_rule_line, self).priority_get(cr, uid, context=context)
"""@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values """
res = super(base_action_rule_line, self).priority_get(cr, uid, context=context)
return res + crm.AVAILABLE_PRIORITIES
_columns = {
_columns = {
'trg_section_id': fields.many2one('crm.case.section', 'Section'),
'trg_max_history': fields.integer('Maximum Communication History'),
'trg_categ_id': fields.many2one('crm.case.categ', 'Category'),
'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_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."),
'act_mail_to_partner': fields.boolean('Mail to partner',help="Check this \
if you want the rule to send an email to the partner."),
}
base_action_rule_line()

View File

@ -31,31 +31,43 @@ class crm_claim(osv.osv):
_order = "id desc"
_inherit = 'crm.case'
_columns = {
'date_closed': fields.datetime('Closed', readonly=True),
'date': fields.datetime('Date'),
'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
'canal_id': fields.many2one('res.partner.canal', 'Channel', help="The channels represent the different communication modes available with the customer." \
" With each commercial opportunity, you can indicate the canall which is this opportunity source."),
'planned_revenue': fields.float('Planned Revenue'),
'planned_cost': fields.float('Planned Costs'),
'som': fields.many2one('res.partner.som', 'State of Mind', help="The minds states allow to define a value scale which represents" \
"the partner mentality in relation to our services.The scale has" \
"to be created with a factor for each level from 0 (Very dissatisfied) to 10 (Extremely satisfied)."),
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.claim')]"),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'type_id': fields.many2one('crm.case.resource.type', 'Claim Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.claim')]"),
'partner_name': fields.char("Employee's Name", size=64),
'partner_mobile': fields.char('Mobile', size=32),
'partner_phone': fields.char('Phone', size=32),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.claim')]"),
'probability': fields.float('Probability (%)'),
'date_closed': fields.datetime('Closed', readonly=True),
'date': fields.datetime('Date'),
'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
'canal_id': fields.many2one('res.partner.canal', 'Channel',\
help="The channels represent the different communication\
modes available with the customer." \
" With each commercial opportunity, you can indicate the\
canall which is this opportunity source."),
'planned_revenue': fields.float('Planned Revenue'),
'planned_cost': fields.float('Planned Costs'),
'som': fields.many2one('res.partner.som', 'State of Mind', \
help="The minds states allow to define a value scale which represents" \
"the partner mentality in relation to our services.The scale has" \
"to be created with a factor for each level from 0 (Very dissatisfied) \
to 10 (Extremely satisfied)."),
'categ_id': fields.many2one('crm.case.categ', 'Category',\
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.claim')]"),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'type_id': fields.many2one('crm.case.resource.type', 'Claim Type',\
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.claim')]"),
'partner_name': fields.char("Employee's Name", size=64),
'partner_mobile': fields.char('Mobile', size=32),
'partner_phone': fields.char('Phone', size=32),
'stage_id': fields.many2one ('crm.case.stage', 'Stage',\
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.claim')]"),
'probability': fields.float('Probability (%)'),
}
_defaults = {
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
}
crm_claim()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -2,48 +2,50 @@
<openerp>
<data noupdate="1">
<menuitem id="base.menu_aftersale" name="After-Sale Services" parent="base.menu_base_partner" sequence="6"/>
<menuitem id="base.menu_aftersale" name="After-Sale Services"
parent="base.menu_base_partner" sequence="6" />
<!-- Claims Menu -->
<record model="ir.actions.act_window" id="crm_case_categ_claim0">
<field name="name">Claims</field>
<field name="res_model">crm.claim</field>
<field name="view_type">form</field>
<field name="view_mode">tree,calendar,form,graph</field>
<field name="view_id" ref="crm_case_claims_tree_view"/>
<field name="view_id" ref="crm_case_claims_tree_view"/>
<field name="search_view_id" ref="crm.view_crm_case_claims_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_claim0">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm_case_claims_tree_view"/>
<field name="act_window_id" ref="crm_case_categ_claim0"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_calendar_claim0">
<field name="sequence" eval="2"/>
<field name="view_mode">calendar</field>
<field name="view_id" ref="crm_case_claims_calendar_view"/>
<field name="act_window_id" ref="crm_case_categ_claim0"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_form_claim0">
<field name="sequence" eval="3"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_case_claims_form_view"/>
<field name="act_window_id" ref="crm_case_categ_claim0"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_sec_graph_view_act_job">
<field name="sequence" eval="4"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="crm_case_graph_view_stage_cost"/>
<field name="act_window_id" ref="crm_case_categ_claim0"/>
</record>
<menuitem name="Claims" id="menu_crm_case_claims" parent="base.menu_aftersale" action="crm_case_categ_claim0"/>
</record>
</data>
<menuitem name="Claims" id="menu_crm_case_claims"
parent="base.menu_aftersale" action="crm_case_categ_claim0" />
</data>
</openerp>

View File

@ -1,9 +1,9 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- Claims categories -->
<record id="crm_claim_categ_action" model="ir.actions.act_window">
<field name="name">Claim Categories</field>
<field name="res_model">crm.case.categ</field>
@ -12,12 +12,12 @@
<field name="domain">[('object_id.model', '=', 'crm.claim')]</field>
<field name="context">{'object_id':'crm.claim'}</field>
</record>
<menuitem action="crm_claim_categ_action"
id="menu_crm_case_claim-act" parent="crm.menu_crm_case_categ" />
<!-- Claim Stages -->
<record id="crm_claim_stage_act" model="ir.actions.act_window">
<field name="name">Claim Stages</field>
<field name="res_model">crm.case.stage</field>
@ -26,7 +26,7 @@
<field name="domain">[('object_id.model', '=', 'crm.claim')]</field>
<field name="context">{'object_id':'crm.claim'}</field>
</record>
<menuitem action="crm_claim_stage_act"
id="menu_crm_claim_stage_act" parent="crm.menu_crm_case_stage" />
@ -40,13 +40,13 @@
<field name="domain">[('object_id.model', '=', 'crm.claim')]</field>
<field name="context">{'object_id':'crm.claim'}</field>
</record>
<menuitem action="crm_claim_resource_act"
id="menu_crm_claim_stage_act"
parent="crm.menu_crm_case_resource_type" />
<!-- Claims -->
<record model="ir.ui.view" id="crm_case_claims_tree_view">
<field name="name">CRM - Claims Tree</field>
<field name="model">crm.claim</field>
@ -115,7 +115,7 @@
<field name="stage_id" select="1" nolabel="1"/>
<button icon="gtk-go-forward" string="" name="stage_next" type="object"/>
</group>
<field name="categ_id" select="1" widget="selection"
<field name="categ_id" select="1" widget="selection"
domain="[('object_id.model', '=', 'crm.claim')]" />
<field name="type_id" string="Type of Action" select="1"
domain="[('object_id.model', '=', 'crm.claim')]" />
@ -131,11 +131,21 @@
<separator colspan="4" string=""/>
<group col="8" colspan="4">
<field name="state" select="1"/>
<button name="case_close" string="Done" states="open,draft,pending" type="object" icon="gtk-jump-to"/>
<button name="case_open" string="Open" states="draft,pending" type="object" icon="gtk-go-forward"/>
<button name="case_cancel" string="Cancel" states="draft,open,pending" type="object" icon="gtk-cancel"/>
<button name="case_pending" string="Pending" states="draft,open" type="object" icon="gtk-media-pause"/>
<button name="case_reset" string="Reset to Draft" states="done,cancel" type="object" icon="gtk-convert"/>
<button name="case_close" string="Done"
states="open,draft,pending" type="object"
icon="gtk-jump-to" />
<button name="case_open" string="Open"
states="draft,pending" type="object"
icon="gtk-go-forward" />
<button name="case_cancel" string="Cancel"
states="draft,open,pending" type="object"
icon="gtk-cancel" />
<button name="case_pending" string="Pending"
states="draft,open" type="object"
icon="gtk-media-pause" />
<button name="case_reset"
string="Reset to Draft" states="done,cancel"
type="object" icon="gtk-convert" />
</group>
</page>
<page string="History" groups="base.group_extended">
@ -263,11 +273,12 @@
domain="[('user_id','=', False)]"
help="Unassigned Claims" />
</field>
<field name="section_id" select="1" widget="selection" string="Section" default="context.get('section_id', False)">
<filter icon="terp-crm"
domain="[('section_id','=',context.get('section_id',False))]"
help="My section"
/>
<field name="section_id" select="1"
widget="selection" string="Section"
default="context.get('section_id', False)">
<filter icon="terp-crm"
domain="[('section_id','=',context.get('section_id',False))]"
help="My section" />
</field>
<newline/>
<group expand="1" string="Group By..." colspan="10" col="20">
@ -281,6 +292,6 @@
</search>
</field>
</record>
</data>
</openerp>

View File

@ -1,8 +1,12 @@
<?xml version="1.0"?>
<openerp>
<data noupdate="1">
<!-- MENU -->
<menuitem id="base.menu_fundrising" name="Fund Raising" parent="base.menu_base_partner" sequence="7"/>
<!-- MENU -->
<menuitem id="base.menu_fundrising" name="Fund Raising"
parent="base.menu_base_partner" sequence="7" />
<record model="ir.actions.act_window" id="crm_case_category_act_fund_all1">
<field name="name">Funds</field>
<field name="res_model">crm.fundraising</field>
@ -10,25 +14,31 @@
<field name="view_id" ref="crm.crm_case_tree_view_fund"/>
<field name="search_view_id" ref="crm.view_crm_case_fund_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_view_fund_all1">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm.crm_case_tree_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_all1"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_form_view_fund_all1">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm.crm_case_form_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_all1"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_graph_view_fund_all1">
<field name="sequence" eval="3"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="crm.crm_case_graph_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_all1"/>
</record>
<menuitem name="Fund Raising" id="menu_crm_case_fund_raise" parent="base.menu_fundrising" action="crm_case_category_act_fund_all1" sequence="1"/>
<menuitem name="Fund Raising" id="menu_crm_case_fund_raise"
parent="base.menu_fundrising"
action="crm_case_category_act_fund_all1" sequence="1" />
</data>
</openerp>

View File

@ -2,9 +2,8 @@
<openerp>
<data>
# ------------------------------------------------------
# Fund Raising Categories
# ------------------------------------------------------
<!-- Fund Raising Categories Form View -->
<record id="crm_fund_categ_action" model="ir.actions.act_window">
<field name="name">Fundraising Categories</field>
<field name="res_model">crm.case.categ</field>
@ -13,10 +12,13 @@
<field name="domain">[('object_id.model', '=', 'crm.fundraising')]</field>
<field name="context">{'object_id':'crm.fundraising'}</field>
</record>
<menuitem action="crm_fund_categ_action" id="menu_crm_case_fundraising-act" parent="crm.menu_crm_case_categ"/>
# ------------------------------------------------------
# Fund Stage
# ------------------------------------------------------
<menuitem action="crm_fund_categ_action"
id="menu_crm_case_fundraising-act"
parent="crm.menu_crm_case_categ" />
<!-- Fund Stage Form View -->
<record id="crm_fundraising_stage_act" model="ir.actions.act_window">
<field name="name">Fundraising Stages</field>
<field name="res_model">crm.case.stage</field>
@ -25,11 +27,13 @@
<field name="domain">[('object_id.model', '=', 'crm.fundraising')]</field>
<field name="context">{'object_id':'crm.fundraising'}</field>
</record>
<menuitem action="crm_fundraising_stage_act" id="menu_crm_fundraising_stage_act" parent="crm.menu_crm_case_stage"/>
# ------------------------------------------------------
#Fund Resource Type
# ------------------------------------------------------
<menuitem action="crm_fundraising_stage_act"
id="menu_crm_fundraising_stage_act"
parent="crm.menu_crm_case_stage" />
<!-- Fund Resource Type Form View -->
<record id="crm_fundraising_resource_act" model="ir.actions.act_window">
<field name="name">Fundraising Resource Type</field>
<field name="res_model">crm.case.resource.type</field>
@ -38,35 +42,51 @@
<field name="domain">[('object_id.model', '=', 'crm.fundraising')]</field>
<field name="context">{'object_id':'crm.fundraising'}</field>
</record>
<menuitem action="crm_fundraising_resource_act" id="menu_crm_fundraising_resource_act" parent="crm.menu_crm_case_resource_type"/>
<menuitem action="crm_fundraising_resource_act"
id="menu_crm_fundraising_resource_act"
parent="crm.menu_crm_case_resource_type" />
# ------------------------------------------------------
# Fund Raising
# ------------------------------------------------------
<!-- Fund Raising Tree View -->
<record model="ir.ui.view" id="crm_case_tree_view_fund">
<field name="name">CRM - Funds Tree</field>
<field name="model">crm.fundraising</field>
<field name="type">tree</field>
<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="Fund Description"/>
<field name="categ_id"/>
<field name="type_id" string="Payment Mode"/>
<field name="planned_cost" string="Amount"/>
<field name="probability"/>
<field name="user_id"/>
<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"/>
<button name="case_cancel" string="Cancel" states="draft,open,pending" type="object" icon="gtk-cancel"/>
<button name="case_pending" string="Pending" states="draft,open" type="object" icon="gtk-media-pause"/>
<button name="case_escalate" string="Escalate" states="open,draft,pending" type="object" icon="gtk-go-up"/>
<button name="case_reset" string="Reset to Draft" states="done,cancel" type="object" icon="gtk-convert"/>
<tree string="Funds Tree"
colors="red:state=='open';black:state in ('draft', 'cancel','done','pending')">
<field name="id" />
<field name="name" string="Fund Description" />
<field name="categ_id" />
<field name="type_id" string="Payment Mode" />
<field name="planned_cost" string="Amount" />
<field name="probability" />
<field name="user_id" />
<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" />
<button name="case_cancel" string="Cancel"
states="draft,open,pending" type="object"
icon="gtk-cancel" />
<button name="case_pending" string="Pending"
states="draft,open" type="object" icon="gtk-media-pause" />
<button name="case_escalate" string="Escalate"
states="open,draft,pending" type="object"
icon="gtk-go-up" />
<button name="case_reset" string="Reset to Draft"
states="done,cancel" type="object" icon="gtk-convert" />
</tree>
</field>
</record>
<!-- Fund Raising Form View -->
<record model="ir.ui.view" id="crm_case_form_view_fund">
<field name="name">CRM - Funds Form</field>
<field name="model">crm.fundraising</field>
@ -74,7 +94,7 @@
<field name="arch" type="xml">
<form string="Funds Form">
<group colspan="4" col="4">
<field name="name" select="1" string="Name"/>
<field name="name" select="1" string="Name"/>
<field name="type_id" string="Payment Mode" select="1" widget="selection"
domain="[('object_id.model', '=', 'crm.fundraising')]" />
</group>
@ -82,8 +102,13 @@
<page string="Funds">
<separator colspan="4" string="Communication"/>
<group colspan="4" col="4">
<field name="partner_id" select="1" on_change="onchange_partner_id(partner_id, email_from)" colspan="2"/>
<field name="partner_address_id" string="Contact" on_change="onchange_partner_address_id(partner_address_id, email_from)" colspan="1"/>
<field name="partner_id" select="1"
on_change="onchange_partner_id(partner_id, email_from)"
colspan="2" />
<field name="partner_address_id"
string="Contact"
on_change="onchange_partner_address_id(partner_address_id, email_from)"
colspan="1" />
<field name="email_from" colspan="2"/>
</group>
<separator colspan="4" string="Estimates"/>
@ -105,12 +130,24 @@
<separator colspan="4"/>
<group col="8" colspan="4">
<field name="state" select="2"/>
<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"/>
<button name="case_cancel" string="Cancel" states="draft,open,pending" type="object" icon="gtk-cancel"/>
<button name="case_pending" string="Pending" states="draft,open" type="object" icon="gtk-media-pause"/>
<button name="case_escalate" string="Escalate" states="open,draft,pending" type="object" icon="gtk-go-up"/>
<button name="case_reset" string="Reset to Draft" states="done,cancel" type="object" icon="gtk-convert"/>
<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" />
<button name="case_cancel" string="Cancel"
states="draft,open,pending" type="object"
icon="gtk-cancel" />
<button name="case_pending" string="Pending"
states="draft,open" type="object"
icon="gtk-media-pause" />
<button name="case_escalate" string="Escalate"
states="open,draft,pending" type="object"
icon="gtk-go-up" />
<button name="case_reset"
string="Reset to Draft" states="done,cancel"
type="object" icon="gtk-convert" />
</group>
</page>
<page string="History" groups="base.group_extended">
@ -177,6 +214,9 @@
</form>
</field>
</record>
<!-- Fund Raising Calendar View -->
<record model="ir.ui.view" id="crm_case_calendar_view_fund">
<field name="name">CRM - Funds Calendar</field>
<field name="model">crm.fundraising</field>
@ -189,6 +229,9 @@
</calendar>
</field>
</record>
<!-- Fund Raising Graph View -->
<record model="ir.ui.view" id="crm_case_graph_view_fund">
<field name="name">CRM - Funds Graph</field>
<field name="model">crm.fundraising</field>
@ -202,6 +245,8 @@
</field>
</record>
<!-- Fund Raising Search View -->
<record id="view_crm_case_fund_filter" model="ir.ui.view">
<field name="name">CRM - Funds Search</field>
<field name="model">crm.fundraising</field>
@ -214,20 +259,32 @@
separator="1"
help="Funds Related to Current User"
/>
<filter icon="gtk-new" string="Current Funds" domain="[('state','in',('draft', 'open'))]" help="Current Funds" />
<filter icon="gtk-yes" string="Open Funds" domain="[('state','=','open')]" help="Open Funds"/>
<filter icon="gtk-media-pause" string="Pending Funds" domain="[('state','=','pending')]" help="Pending Funds"/>
<separator orientation="vertical"/>
<filter icon="gtk-new" string="Current Funds"
domain="[('state','in',('draft', 'open'))]"
help="Current Funds" />
<filter icon="gtk-yes" string="Open Funds"
domain="[('state','=','open')]"
help="Open Funds" />
<filter icon="gtk-media-pause"
string="Pending Funds"
domain="[('state','=','pending')]"
help="Pending Funds" />
<separator orientation="vertical" />
<field name="state" select="1" />
<field name="name" select='1' string="Fund Description"/>
<field name="user_id" select="1" widget="selection">
<filter icon="terp-partner" domain="[('user_id','=', False)]" help="Unassigned" />
<field name="name" select='1'
string="Fund Description" />
<field name="user_id" select="1"
widget="selection">
<filter icon="terp-partner"
domain="[('user_id','=', False)]"
help="Unassigned" />
</field>
<field name="section_id" select="1" widget="selection" string="Section" default="context.get('section_id', False)">
<filter icon="terp-crm"
domain="[('section_id','=',context.get('section_id',False))]"
help="My section"
/>
<field name="section_id" select="1"
widget="selection" string="Section"
default="context.get('section_id', False)">
<filter icon="terp-crm"
domain="[('section_id','=',context.get('section_id',False))]"
help="My section" />
</field>
</group>
</search>

View File

@ -23,40 +23,54 @@ from osv import fields,osv,orm
import crm
class crm_fundraising(osv.osv):
""" Fund Raising Cases """
_name = "crm.fundraising"
_description = "Fund Raising Cases"
_order = "id desc"
_inherit ='crm.case'
_columns = {
_columns = {
'date_closed': fields.datetime('Closed', readonly=True),
'date': fields.datetime('Date'),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'categ_id': fields.many2one('crm.case.categ','Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]"),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'categ_id': fields.many2one('crm.case.categ','Category', \
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.fundraising')]"),
'planned_revenue': fields.float('Planned Revenue'),
'planned_cost': fields.float('Planned Costs'),
'probability': fields.float('Probability (%)'),
'probability': fields.float('Probability (%)'),
'partner_name': fields.char("Employee's Name", size=64),
'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),('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')]"),
'partner_mobile': fields.char('Mobile', size=32),
'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),
'canal_id': fields.many2one('res.partner.canal', 'Channel',help="The channels represent the different communication modes available with the customer." \
" With each commercial opportunity, you can indicate the canall which is this opportunity source."),
'som': fields.many2one('res.partner.som', 'State of Mind', help="The minds states allow to define a value scale which represents" \
"the partner mentality in relation to our services.The scale has" \
"to be created with a factor for each level from 0 (Very dissatisfied) to 10 (Extremely satisfied)."),
'ref': fields.reference('Reference', selection=crm._links_get, size=128),
'ref2': fields.reference('Reference 2', selection=crm._links_get, size=128),
'canal_id': fields.many2one('res.partner.canal', 'Channel',\
help="The channels represent the different communication \
modes available with the customer." \
" With each commercial opportunity, you can indicate\
the canall which is this opportunity source."),
'som': fields.many2one('res.partner.som', 'State of Mind',\
help="The minds states allow to define a value scale which represents" \
"the partner mentality in relation to our services.The scale has" \
"to be created with a factor for each level from 0 \
(Very dissatisfied) to 10 (Extremely satisfied)."),
}
_defaults = {
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
'probability':lambda *a:0.0,
'planned_cost':lambda *a:0.0,
'planned_revenue':lambda *a:0.0,
'probability':lambda *a:0.0,
'planned_cost':lambda *a:0.0,
'planned_revenue':lambda *a:0.0,
}
crm_fundraising()
crm_fundraising()

View File

@ -23,27 +23,38 @@ from osv import fields,osv,orm
import crm
class crm_helpdesk(osv.osv):
""" Helpdesk Cases """
_name = "crm.helpdesk"
_description = "Helpdesk Cases"
_order = "id desc"
_inherit = 'crm.case'
_columns = {
'date_closed': fields.datetime('Closed', readonly=True),
'date': fields.datetime('Date'),
'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
'canal_id': fields.many2one('res.partner.canal', 'Channel',help="The channels represent the different communication modes available with the customer." \
" With each commercial opportunity, you can indicate the canall which is this opportunity source."),
'canal_id': fields.many2one('res.partner.canal', 'Channel',\
help="The channels represent the different communication \
modes available with the customer." \
" With each commercial opportunity, you can indicate\
the canall which is this opportunity source."),
'planned_revenue': fields.float('Planned Revenue'),
'planned_cost': fields.float('Planned Costs'),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'probability': fields.float('Probability (%)'),
'som': fields.many2one('res.partner.som', 'State of Mind', help="The minds states allow to define a value scale which represents" \
"the partner mentality in relation to our services.The scale has" \
"to be created with a factor for each level from 0 (Very dissatisfied) to 10 (Extremely satisfied)."),
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.helpdesk')]"),
'som': fields.many2one('res.partner.som', 'State of Mind', \
help="The minds states allow to define a value scale which represents" \
"the partner mentality in relation to our services.The scale has" \
"to be created with a factor for each level from 0 \
(Very dissatisfied) to 10 (Extremely satisfied)."),
'categ_id': fields.many2one('crm.case.categ', 'Category',\
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.helpdesk')]"),
'duration': fields.float('Duration'),
}
_defaults = {
'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.helpdesk', context=c),
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
@ -51,5 +62,5 @@ class crm_helpdesk(osv.osv):
crm_helpdesk()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,36 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<menuitem id="base.menu_aftersale" name="After-Sale Services" parent="base.menu_base_partner" sequence="6"/>
<menuitem id="base.menu_aftersale" name="After-Sale Services"
parent="base.menu_base_partner" sequence="6" />
<!-- Help Desk (menu) -->
######################## Help Desk (menu) ###########################
<record model="ir.actions.act_window" id="crm_case_helpdesk_act111">
<field name="name">Helpdesk Requests</field>
<field name="res_model">crm.helpdesk</field>
<field name="view_mode">tree,calendar,form</field>
<field name="view_id" ref="crm_case_tree_view_helpdesk"/>
<field name="view_id" ref="crm_case_tree_view_helpdesk"/>
<field name="search_view_id" ref="crm.view_crm_case_helpdesk_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_sec_tree_view_act111">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm_case_tree_view_helpdesk"/>
<field name="act_window_id" ref="crm_case_helpdesk_act111"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_sec_calendar_view_act111">
<field name="sequence" eval="2"/>
<field name="view_mode">calendar</field>
<field name="view_id" ref="crm_case_helpdesk_calendar_view"/>
<field name="act_window_id" ref="crm_case_helpdesk_act111"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_sec_form_view_act111">
<field name="sequence" eval="3"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_case_form_view_helpdesk"/>
<field name="act_window_id" ref="crm_case_helpdesk_act111"/>
</record>
<menuitem name="Helpdesk and Support" id="menu_help_support_main" parent="base.menu_aftersale" action="crm_case_helpdesk_act111"/>
</data>
<menuitem name="Helpdesk and Support" id="menu_help_support_main"
parent="base.menu_aftersale" action="crm_case_helpdesk_act111" />
</data>
</openerp>

View File

@ -2,9 +2,8 @@
<openerp>
<data>
# ------------------------------------------------------
# Helpdesk Support Categories
# ------------------------------------------------------
<!-- Helpdesk Support Categories Form View -->
<record id="crm_helpdesk_categ_action" model="ir.actions.act_window">
<field name="name">Helpdesk Categories</field>
<field name="res_model">crm.case.categ</field>
@ -13,11 +12,11 @@
<field name="domain">[('object_id.model', '=', 'crm.helpdesk')]</field>
<field name="context">{'object_id':'crm.helpdesk'}</field>
</record>
<menuitem action="crm_helpdesk_categ_action" id="menu_crm_case_helpdesk-act" parent="crm.menu_crm_case_categ"/>
# ------------------------------------------------------
# Helpdesk Support
# ------------------------------------------------------
<menuitem action="crm_helpdesk_categ_action"
id="menu_crm_case_helpdesk-act" parent="crm.menu_crm_case_categ" />
<!-- Helpdesk Support Form View -->
<record model="ir.ui.view" id="crm_case_form_view_helpdesk">
<field name="name">CRM - Helpdesk Support Form</field>
@ -34,11 +33,18 @@
<page string="General">
<separator colspan="4" string="Communication"/>
<group col="7" colspan="4">
<field name="partner_id" on_change="onchange_partner_id(partner_id, email_from)" select="1"/>
<field name="partner_address_id" on_change="onchange_partner_address_id(partner_address_id, email_from)" select="2"/>
<field name="partner_id"
on_change="onchange_partner_id(partner_id, email_from)"
select="1" />
<field name="partner_address_id"
on_change="onchange_partner_address_id(partner_address_id, email_from)"
select="2" />
<field name="email_from" select="2"/>
<button name="remind_partner" states="open,pending" string="Send Reminder" type="object" icon="gtk-go-forward"/>
<field name="email_from" select="2" />
<button name="remind_partner"
states="open,pending"
string="Send Reminder" type="object"
icon="gtk-go-forward" />
</group>
<separator colspan="4" string="Categorization"/>
@ -46,7 +52,10 @@
<field name="priority"/>
<field name="section_id" widget="selection"/>
<field name="user_id" select="1"/>
<button name="remind_user" states="open,pending" string="Send Reminder" type="object" icon="gtk-go-forward"/>
<button name="remind_user"
states="open,pending"
string="Send Reminder" type="object"
icon="gtk-go-forward" />
</group>
<separator colspan="4" string="Details"/>
@ -55,12 +64,26 @@
<separator colspan="4"/>
<group col="8" colspan="4">
<field name="state" select="1"/>
<button name="case_close" states="open,draft,pending" string="Close" type="object" icon="gtk-close"/>
<button name="case_open" states="draft,pending" string="Open" type="object" icon="gtk-go-forward"/>
<button name="case_cancel" states="draft,open,pending" string="Cancel" type="object" icon="gtk-cancel"/>
<button name="case_pending" states="draft,open" string="Pending" type="object" icon="gtk-media-pause"/>
<button name="case_escalate" states="open,draft,pending" string="Escalate" type="object" icon="gtk-go-up"/>
<button name="case_reset" states="done,cancel" string="Reset to Draft" type="object" icon="gtk-convert"/>
<button name="case_close"
states="open,draft,pending" string="Close"
type="object" icon="gtk-close" />
<button name="case_open"
states="draft,pending" string="Open"
type="object" icon="gtk-go-forward" />
<button name="case_cancel"
states="draft,open,pending" string="Cancel"
type="object" icon="gtk-cancel" />
<button name="case_pending"
states="draft,open" string="Pending"
type="object" icon="gtk-media-pause" />
<button name="case_escalate"
states="open,draft,pending"
string="Escalate" type="object"
icon="gtk-go-up" />
<button name="case_reset"
states="done,cancel"
string="Reset to Draft" type="object"
icon="gtk-convert" />
</group>
</page>
<page string="History" groups="base.group_extended">
@ -125,6 +148,9 @@
</form>
</field>
</record>
<!-- Helpdesk Support Tree View -->
<record model="ir.ui.view" id="crm_case_tree_view_helpdesk">
<field name="name">CRM - Helpdesk Support Tree</field>
<field name="model">crm.helpdesk</field>
@ -140,16 +166,29 @@
<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"/>
<button name="case_cancel" string="Cancel" states="draft,open,pending" type="object" icon="gtk-cancel"/>
<button name="case_pending" string="Pending" states="draft,open" type="object" icon="gtk-media-pause"/>
<button name="case_escalate" string="Escalate" states="open,draft,pending" type="object" icon="gtk-go-up"/>
<button name="case_reset" string="Reset to Draft" states="done,cancel" type="object" icon="gtk-convert"/>
<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" />
<button name="case_cancel" string="Cancel"
states="draft,open,pending" type="object"
icon="gtk-cancel" />
<button name="case_pending" string="Pending"
states="draft,open" type="object"
icon="gtk-media-pause" />
<button name="case_escalate" string="Escalate"
states="open,draft,pending" type="object"
icon="gtk-go-up" />
<button name="case_reset" string="Reset to Draft"
states="done,cancel" type="object" icon="gtk-convert" />
</tree>
</field>
</record>
<!-- Helpdesk Support Calendar View -->
<record model="ir.ui.view" id="crm_case_helpdesk_calendar_view">
<field name="name">CRM - Helpdesk Support Calendar</field>
<field name="model">crm.helpdesk</field>
@ -164,6 +203,8 @@
</field>
</record>
<!-- Helpdesk Support Search View -->
<record id="view_crm_case_helpdesk_filter" model="ir.ui.view">
<field name="name">CRM - Helpdesk Search</field>
<field name="model">crm.helpdesk</field>
@ -184,18 +225,25 @@
<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"/>
<filter icon="terp-partner"
domain="[('user_id','=',uid)]"
help="My Helpdesk Requests" 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))]"
help="My section"/>
<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))]"
help="My section" />
</field>
<newline/>
<group expand="1" string="Group By..." colspan="12" col="20">
<filter string="Customer" icon="terp-crm" domain="[]" context="{'group_by':'partner_id'}"/>
<filter string="State" icon="terp-crm" domain="[]" context="{'group_by':'state'}"/>
<filter string="Priority" icon="terp-crm" domain="[]" context="{'group_by':'priority'}"/>
<filter string="Customer" icon="terp-crm"
domain="[]" context="{'group_by':'partner_id'}" />
<filter string="State" icon="terp-crm" domain="[]"
context="{'group_by':'state'}" />
<filter string="Priority" icon="terp-crm"
domain="[]" context="{'group_by':'priority'}" />
</group>
</search>
</field>

View File

@ -25,12 +25,23 @@ import crm
import math
class crm_lead(osv.osv):
""" CRm Lead Case """
_name = "crm.lead"
_description = "Leads Cases"
_order = "priority desc, id desc"
_inherit = ['res.partner.address', 'crm.case']
def _compute_openday(self, cr, uid, ids, name, args, context={}):
"""
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of Opendays IDs
@return: difference between current date and log date
@param context: A standard dictionary for contextual values
"""
result = {}
for r in self.browse(cr, uid, ids , context):
result[r.id] = 0
@ -51,9 +62,19 @@ class crm_lead(osv.osv):
return result
def _compute_closeday(self, cr, uid, ids, name, args, context={}):
"""
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of closedays IDs
@return: difference between current date and closed date
@param context: A standard dictionary for contextual values
"""
result = {}
for r in self.browse(cr, uid, ids , context):
result[r.id] = 0
if r.date_closed:
date_create = datetime.strptime(r.create_date, "%Y-%m-%d %H:%M:%S")
date_close = datetime.strptime(r.date_closed, "%Y-%m-%d %H:%M:%S")
@ -63,27 +84,36 @@ class crm_lead(osv.osv):
return result
_columns = {
'categ_id': fields.many2one('crm.case.categ', 'Lead Source', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
'type_id': fields.many2one('crm.case.resource.type', 'Lead Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]"),
'partner_name': fields.char("Contact Name", size=64),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'date_closed': fields.datetime('Closed', readonly=True),
'stage_id': fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]"),
'opportunity_id': fields.many2one('crm.opportunity', 'Opportunity'),
'categ_id': fields.many2one('crm.case.categ', 'Lead Source', \
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.opportunity')]"),
'type_id': fields.many2one('crm.case.resource.type', 'Lead Type',\
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.lead')]"),
'partner_name': fields.char("Contact Name", size=64),
'user_id': fields.many2one('res.users', 'Salesman'),
'referred': fields.char('Referred By', size=32),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'date_closed': fields.datetime('Closed', readonly=True),
'stage_id': fields.many2one('crm.case.stage', 'Stage',\
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.lead')]"),
'opportunity_id': fields.many2one('crm.opportunity', 'Opportunity'),
'user_id': fields.many2one('res.users', 'Salesman'),
'referred': fields.char('Referred By', size=32),
'day_open': fields.function(_compute_openday, string='Days to Open', \
method=True, type="integer", store=True),
method=True, type="integer", store=True),
'day_close': fields.function(_compute_closeday, string='Days to Close', \
method=True, type="integer", store=True),
method=True, type="integer", store=True),
'function_name' : fields.char('Function', size=64),
}
_defaults = {
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.lead', context=c),
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.lead', context=c),
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
}
crm_lead()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,9 +1,6 @@
<?xml version="1.0"?>
<openerp>
<data noupdate="1">
<!-- <menuitem id="menu_presale" name="Sales" parent="crm.menu_crm" sequence="4"/>-->
<!-- MENU -->
<record model="ir.actions.act_window" id="crm_case_category_act_leads_all">
<field name="name">Leads</field>
@ -24,8 +21,12 @@
<field name="view_id" ref="crm_case_form_view_leads"/>
<field name="act_window_id" ref="crm_case_category_act_leads_all"/>
</record>
<menuitem id="base.menu_sales" name="Sales" parent="base.menu_base_partner" sequence="1"/>
<menuitem parent="base.menu_sales" name="Leads" id="menu_crm_case_categ0_act_leads" action="crm_case_category_act_leads_all" sequence="1"/>
<menuitem id="base.menu_sales" name="Sales"
parent="base.menu_base_partner" sequence="1" />
<menuitem parent="base.menu_sales" name="Leads"
id="menu_crm_case_categ0_act_leads"
action="crm_case_category_act_leads_all" sequence="1" />
</data>
</openerp>

View File

@ -2,11 +2,8 @@
<openerp>
<data>
<!--Lead Stage Form view -->
# ------------------------------------------------------
# Stage
# ------------------------------------------------------
<record id="crm_lead_stage_act" model="ir.actions.act_window">
<field name="name">Lead Stages</field>
<field name="res_model">crm.case.stage</field>
@ -15,11 +12,11 @@
<field name="domain">[('object_id.model', '=', 'crm.lead')]</field>
<field name="context">{'object_id':'crm.lead'}</field>
</record>
<menuitem action="crm_lead_stage_act" id="menu_crm_lead_stage_act" parent="crm.menu_crm_case_stage"/>
# ------------------------------------------------------
Resource Type
# ------------------------------------------------------
<menuitem action="crm_lead_stage_act" id="menu_crm_lead_stage_act"
parent="crm.menu_crm_case_stage" />
<!-- Resource Type Form View -->
<record id="crm_lead_resource_act" model="ir.actions.act_window">
<field name="name">Lead Resource Type</field>
<field name="res_model">crm.case.resource.type</field>
@ -28,14 +25,13 @@
<field name="domain">[('object_id.model', '=', 'crm.lead')]</field>
<field name="context">{'object_id':'crm.lead'}</field>
</record>
<menuitem action="crm_lead_resource_act" id="menu_crm_lead_resource_act" parent="crm.menu_crm_case_resource_type"/>
<menuitem action="crm_lead_resource_act"
id="menu_crm_lead_resource_act"
parent="crm.menu_crm_case_resource_type" />
<!-- CRM Lead Form View -->
# ------------------------------------------------------
# Leads
# ------------------------------------------------------
<record model="ir.ui.view" id="crm_case_form_view_leads">
<record model="ir.ui.view" id="crm_case_form_view_leads">
<field name="name">CRM - Leads Form</field>
<field name="model">crm.lead</field>
<field name="type">form</field>
@ -46,19 +42,26 @@
<field name="priority"/>
<field name="date_deadline"/>
<button
name="%(wizard_crm_lead_opportunity_set)d"
name="%(wizard_crm_lead_opportunity_set)d"
string="Convert"
help="Convert into Opportunity"
icon="gtk-index"
icon="gtk-index"
type="action"
attrs="{'invisible':[('opportunity_id','!=',False)]}"/>
<newline/>
<field name="section_id" colspan="1" widget="selection"/>
<field name="user_id"/>
<field name="stage_id" widget="selection" readonly="1" domain="[('object_id.model', '=', 'crm.lead')]"/>
<newline />
<field name="section_id" colspan="1"
widget="selection" />
<field name="user_id" />
<field name="stage_id" widget="selection"
readonly="1"
domain="[('object_id.model', '=', 'crm.lead')]" />
<group col="2" colspan="1">
<button name="stage_previous" string="Previous" states="open,pending" type="object" icon="gtk-go-back"/>
<button name="stage_next" string="Next" states="open,pending" type="object" icon="gtk-go-forward"/>
<button name="stage_previous" string="Previous"
states="open,pending" type="object"
icon="gtk-go-back" />
<button name="stage_next" string="Next"
states="open,pending" type="object"
icon="gtk-go-forward" />
</group>
</group>
<notebook colspan="4">
@ -89,23 +92,35 @@
<separator string="Links" colspan="4" col="3"/>
<field name="partner_id"/>
<button
name="%(action_crm_lead2partner)d"
name="%(action_crm_lead2partner)d"
icon="gtk-index" type="action"
string="Create"
attrs="{'invisible':[('partner_id','!=',False)]}"/>
<field name="opportunity_id"/>
<field name="opportunity_id"/>
</group>
<separator colspan="4" string="Notes"/>
<field name="description" nolabel="1" colspan="4"/>
<separator colspan="4"/>
<group col="8" colspan="4">
<field name="state" select="2"/>
<button name="case_close" string="Close" states="open,draft,pending" type="object" icon="gtk-close"/>
<button name="case_open" string="Open" states="draft,pending" type="object" icon="gtk-go-forward"/>
<button name="case_cancel" string="Cancel" states="draft,open,pending" type="object" icon="gtk-cancel"/>
<button name="case_pending" string="Pending" states="draft,open" type="object" icon="gtk-media-pause"/>
<button name="case_escalate" string="Escalate" states="open,draft,pending" type="object" icon="gtk-go-up"/>
<button name="case_reset" string="Reset to Draft" states="done,cancel" type="object" icon="gtk-convert"/>
<button name="case_close" string="Close"
states="open,draft,pending" type="object"
icon="gtk-close" />
<button name="case_open" string="Open"
states="draft,pending" type="object"
icon="gtk-go-forward" />
<button name="case_cancel" string="Cancel"
states="draft,open,pending" type="object"
icon="gtk-cancel" />
<button name="case_pending" string="Pending"
states="draft,open" type="object"
icon="gtk-media-pause" />
<button name="case_escalate" string="Escalate"
states="open,draft,pending" type="object"
icon="gtk-go-up" />
<button name="case_reset"
string="Reset to Draft" states="done,cancel"
type="object" icon="gtk-convert" />
</group>
</page>
<page string="Emails" groups="base.group_extended">
@ -146,7 +161,9 @@
<page string="Extra Info" groups="base.group_extended">
<group colspan="2" col="2">
<separator string="Categories" colspan="2" col="2"/>
<field name="company_id" groups="base.group_multi_company" widget="selection" colspan="2"/>
<field name="company_id"
groups="base.group_multi_company"
widget="selection" colspan="2" />
<field name="categ_id"
widget="selection"
domain="[('object_id.model', '=', 'crm.opportunity')]" />
@ -170,6 +187,8 @@
</field>
</record>
<!-- CRM Lead Tree View -->
<record model="ir.ui.view" id="crm_case_tree_view_leads">
<field name="name">CRM - Leads Tree</field>
<field name="model">crm.lead</field>
@ -187,33 +206,54 @@
<field name="referred" invisible="1"/>
<field name="stage_id"/>
<button name="stage_previous" string="Previous" states="open,pending" type="object" icon="gtk-go-back"/>
<button name="stage_next" string="Next" states="open,pending" type="object" icon="gtk-go-forward"/>
<field name="section_id" invisible="context.get('invisible_section', True)"/>
<field name="user_id"/>
<field name="state"/>
<button name="case_open" string="Open" states="draft,pending" type="object" icon="gtk-go-forward"/>
<button name="case_close" string="Close" states="open,draft,pending" type="object" icon="gtk-close"/>
<button string="Convert to Opportunity" name="%(action_crm_lead2opportunity)d" states="draft,open,pending" icon="gtk-index" type="action"/>
<button name="case_escalate" string="Escalate" states="open,draft,pending" type="object" icon="gtk-go-up"/>
<button name="case_cancel" string="Cancel" states="draft,open,pending" type="object" icon="gtk-cancel"/>
<button name="stage_previous" string="Previous"
states="open,pending" type="object" icon="gtk-go-back" />
<button name="stage_next" string="Next"
states="open,pending" type="object"
icon="gtk-go-forward" />
<field name="section_id"
invisible="context.get('invisible_section', True)" />
<field name="user_id" />
<field name="state" />
<button name="case_open" string="Open"
states="draft,pending" type="object"
icon="gtk-go-forward" />
<button name="case_close" string="Close"
states="open,draft,pending" type="object"
icon="gtk-close" />
<button string="Convert to Opportunity"
name="%(action_crm_lead2opportunity)d"
states="draft,open,pending" icon="gtk-index"
type="action" />
<button name="case_escalate" string="Escalate"
states="open,draft,pending" type="object"
icon="gtk-go-up" />
<button name="case_cancel" string="Cancel"
states="draft,open,pending" type="object"
icon="gtk-cancel" />
</tree>
</field>
</record>
<!-- CRM Lead Calendar View -->
<record model="ir.ui.view" id="crm_case_calendar_view_leads">
<field name="name">CRM - Leads Calendar</field>
<field name="model">crm.lead</field>
<field name="type">calendar</field>
<field name="priority" eval="2"/>
<field name="arch" type="xml">
<calendar string="Meeting For Leads Generation" date_start="create_date" color="user_id" date_delay="duration">
<field name="name"/>
<field name="partner_name"/>
<field name="partner_contact"/>
<calendar string="Meeting For Leads Generation"
date_start="create_date" color="user_id"
date_delay="duration">
<field name="name" />
<field name="partner_name" />
<field name="partner_contact" />
</calendar>
</field>
</record>
<!-- CRM Lead Search View -->
<record id="view_crm_case_leads_filter" model="ir.ui.view">
<field name="name">CRM - Leads Search</field>
@ -234,12 +274,13 @@
<separator orientation="vertical"/>
<filter icon="gtk-home" string="Today"
domain="[('create_date','&lt;', time.strftime('%%Y-%%m-%%d 23:59:59')), ('create_date','&gt;=', time.strftime('%%Y-%%m-%%d 23:59:59'))]"
help="Todays' Opportunities"
/>
domain="[('create_date','&lt;', time.strftime('%%Y-%%m-%%d 23:59:59')), \
('create_date','&gt;=', time.strftime('%%Y-%%m-%%d 23:59:59'))]"
help="Todays' Opportunities" />
<filter icon="gtk-media-rewind" string="7 Days"
help="Opportunities during last 7 days"
domain="[('create_date','&lt;', time.strftime('%%Y-%%m-%%d')), ('create_date','&gt;=',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
domain="[('create_date','&lt;', time.strftime('%%Y-%%m-%%d')),\
('create_date','&gt;=',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
/>
<separator orientation="vertical"/>
<field name="partner_name"/>
@ -265,14 +306,15 @@
<group expand="1" string="Group By..." colspan="14">
<filter string="Stage" icon="terp-crm" domain="[]" context="{'group_by':'stage_id'}"/>
<filter string="State" icon="terp-crm" domain="[]" context="{'group_by':'state'}"/>
<filter string="Source" icon="terp-crm" domain="[]" context="{'group_by':'categ_id'}"/>
<filter string="Type" icon="terp-crm" domain="[]" context="{'group_by':'type'}"/>
<filter string="Source" icon="terp-crm" domain="[]" context="{'group_by':'categ_id'}"/>
<filter string="Type" icon="terp-crm" domain="[]" context="{'group_by':'type'}"/>
<separator orientation="vertical"/>
<filter string="Team" icon="terp-crm" domain="[]" context="{'group_by':'section_id'}"/>
<filter string="Salesman" icon="terp-crm" domain="[]" context="{'group_by':'user_id'}"/>
<filter string="Referrer" icon="terp-crm" domain="[]" context="{'group_by':'referred'}"/>
<separator orientation="vertical"/>
<filter string="Creation" icon="terp-project" domain="[]" context="{'group_by':'create_date'}"/>
<filter string="Creation" icon="terp-project"
domain="[]" context="{'group_by':'create_date'}" />
</group>
</search>
</field>

View File

@ -33,43 +33,57 @@ from osv import fields,osv,orm
from osv.orm import except_orm
class crm_cases(osv.osv):
""" crm cases """
_name = "crm.case"
_inherit = "crm.case"
def msg_new(self, cr, uid, msg):
def msg_new(self, cr, uid, msg):
""" @param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks
"""
mailgate_obj = self.pool.get('mail.gateway')
msg_body = mailgate_obj.msg_body_get(msg)
data = {
'name': msg['Subject'],
data = {
'name': msg['Subject'],
'email_from': msg['From'],
'email_cc': msg['Cc'],
'email_cc': msg['Cc'],
'user_id': False,
'description': msg_body['body'],
'description': msg_body['body'],
}
res = mailgate_obj.partner_get(cr, uid, msg['From'])
if res:
data.update(res)
res = self.create(cr, uid, data)
cases = self.browse(cr, uid, [res])
res = self.create(cr, uid, data)
cases = self.browse(cr, uid, [res])
self._history(cr, uid, cases, _('Receive'), history=True, email=msg['From'])
return res
def msg_update(self, cr, uid, ids, msg, data={}, default_act='pending'):
""" @param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of update mails IDs """
if isinstance(ids, (str, int, long)):
select = [ids]
else:
select = ids
select = ids
mailgate_obj = self.pool.get('mail.gateway')
msg_actions, body_data = mailgate_obj.msg_act_get(msg)
msg_actions, body_data = mailgate_obj.msg_act_get(msg)
data.update({
'description': body_data,
'description': body_data,
})
act = 'case_'+default_act
if 'state' in msg_actions:
if msg_actions['state'] in ['draft','close','cancel','open','pending']:
act = 'case_' + msg_actions['state']
for k1,k2 in [('cost','planned_cost'),('revenue','planned_revenue'),('probability','probability')]:
for k1,k2 in [('cost','planned_cost'),('revenue','planned_revenue'),('probability','probability')]:
if k1 in msg_actions:
data[k2] = float(msg_actions[k1])
@ -78,15 +92,24 @@ class crm_cases(osv.osv):
data['priority'] = msg_actions['priority']
if 'partner' in msg_actions:
data['email_from'] = msg_actions['partner'][:128]
data['email_from'] = msg_actions['partner'][:128]
res = self.write(cr, uid, select, data)
cases = self.browse(cr, uid, select)
self._history(cr, uid, cases, _('Receive'), history=True, email=msg['From'])
cases = self.browse(cr, uid, select)
self._history(cr, uid, cases, _('Receive'), history=True, email=msg['From'])
getattr(self,act)(cr, uid, select)
return res
def emails_get(self, cr, uid, ids, context={}):
def emails_get(self, cr, uid, ids, context={}):
""" Get Emails
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of emails IDs
@param context: A standard dictionary for contextual values
"""
res = []
if isinstance(ids, (str, int, long)):
select = [ids]
@ -96,10 +119,19 @@ class crm_cases(osv.osv):
user_email = (case.user_id and case.user_id.address_id and case.user_id.address_id.email) or False
res += [(user_email, case.email_from, case.email_cc, getattr(case,'priority') and case.priority or False)]
if isinstance(ids, (str, int, long)):
return len(res) and res[0] or False
return len(res) and res[0] or False
return res
def msg_send(self, cr, uid, id, *args, **argv):
return True
""" Send The Message
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of emails IDs
@param *args: Return Tuple Value
@param **args: Return Dictionary of Keyword Value
"""
return True
crm_cases()

View File

@ -26,63 +26,84 @@ from datetime import datetime, timedelta
class crm_opportunity(osv.osv):
_name = 'crm.opportunity'
crm_opportunity()
crm_opportunity()
class crm_phonecall(osv.osv):
""" CRM Phonecall """
_name = 'crm.phonecall'
crm_phonecall()
class crm_meeting(osv.osv):
""" CRM Meeting Cases """
_name = 'crm.meeting'
_description = "Meeting Cases"
_order = "id desc"
_inherit = ["crm.case", "calendar.event"]
_inherit = ["crm.case", "calendar.event"]
_columns = {
_columns = {
'categ_id': fields.many2one('crm.case.categ', 'Meeting Type', \
domain="[('object_id.model', '=', 'crm.meeting')]", \
),
'phonecall_id':fields.many2one ('crm.phonecall', 'Phonecall'),
'opportunity_id':fields.many2one ('crm.opportunity', 'Opportunity'),
'attendee_ids': fields.many2many('calendar.attendee', 'event_attendee_rel', 'event_id', 'attendee_id', 'Attendees'),
'date_closed': fields.datetime('Closed', readonly=True),
'date_deadline': fields.datetime('Deadline'),
'state': fields.selection([('open', 'Confirmed'),
('draft', 'Unconfirmed'),
('cancel', 'Cancelled'),
),
'phonecall_id': fields.many2one ('crm.phonecall', 'Phonecall'),
'opportunity_id': fields.many2one ('crm.opportunity', 'Opportunity'),
'attendee_ids': fields.many2many('calendar.attendee', 'event_attendee_rel',\
'event_id', 'attendee_id', 'Attendees'),
'date_closed': fields.datetime('Closed', readonly=True),
'date_deadline': fields.datetime('Deadline'),
'state': fields.selection([('open', 'Confirmed'),
('draft', 'Unconfirmed'),
('cancel', 'Cancelled'),
('done', 'Done')], 'State', \
size=16, readonly=True)
}
_defaults = {
'state': lambda *a: 'draft',
}
crm_meeting()
class calendar_attendee(osv.osv):
""" Calendar Attendee """
_inherit = 'calendar.attendee'
_description = 'Calendar Attendee'
def _compute_data(self, cr, uid, ids, name, arg, context):
name = name[0]
result = super(calendar_attendee, self)._compute_data(cr, uid, ids, name, arg, context)
def _compute_data(self, cr, uid, ids, name, arg, context):
for attdata in self.browse(cr, uid, ids, context=context):
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of compute datas IDs
@param context: A standard dictionary for contextual values
"""
name = name[0]
result = super(calendar_attendee, self)._compute_data(cr, uid, ids, name, arg, context)
for attdata in self.browse(cr, uid, ids, context=context):
id = attdata.id
result[id] = {}
if name == 'categ_id':
if attdata.ref:
result[id][name] = (attdata.ref.categ_id.id,attdata.ref.categ_id.name,)
result[id][name] = (attdata.ref.categ_id.id, attdata.ref.categ_id.name,)
else:
result[id][name] = False
return result
return result
_columns = {
'categ_id': fields.function(_compute_data, method=True, \
string='Event Type', type="many2one", \
relation="crm.case.categ", multi='categ_id'),
}
calendar_attendee()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -85,7 +85,7 @@
<field name="res_model">crm.meeting</field>
<field name="view_mode">calendar,tree,form,gantt</field>
<field name="view_id" ref="crm_case_calendar_view_meet"/>
<field name="search_view_id" ref="view_crm_case_meetings_filter"/>
<field name="search_view_id" ref="view_crm_case_meetings_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_calendar_meet">
<field name="sequence" eval="1"/>
@ -111,13 +111,15 @@
<field name="view_id" ref="crm_case_gantt_view_meet"/>
<field name="act_window_id" ref="crm_case_categ_meet"/>
</record>
<!-- <menuitem parent="crm.menu_crm" name="Calendar" id="menu_crm_case_category_act_meetings"/>-->
<!--
ALL MEETINGS
-->
<menuitem name="Meetings" id="menu_meeting_sale" parent="base.menu_base_partner" sequence="3"/>
<menuitem name="Meetings" id="menu_crm_case_categ_meet" action="crm_case_categ_meet" parent="menu_meeting_sale" sequence="1"/>
<!-- ALL MEETINGS -->
<menuitem name="Meetings" id="menu_meeting_sale"
parent="base.menu_base_partner" sequence="3" />
<menuitem name="Meetings" id="menu_crm_case_categ_meet"
action="crm_case_categ_meet" parent="menu_meeting_sale"
sequence="1" />
<record id="action_view_attendee_form" model="ir.actions.act_window">
<field name="name">Meeting Invitations</field>
@ -125,15 +127,15 @@
<field name="res_model">calendar.attendee</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="base_calendar.base_calendar_attendee_tree_view" />
<field name="view_id" ref="base_calendar.base_calendar_attendee_tree_view" />
<field name="domain">[('ref','like','crm.meeting,')]</field>
<field name="context">{'default_sent_by_uid': uid}</field>
</record>
<menuitem id="menu_attendee_invitations"
name="Meeting Invitations" parent="crm.menu_meeting_sale"
sequence="10" action="action_view_attendee_form" />
sequence="10" action="action_view_attendee_form" />
<record model="ir.actions.act_window" id="crm_case_category_act_meetall3">
<field name="name">Next Meetings</field>
@ -141,26 +143,31 @@
<field name="view_type">form</field>
<field name="view_mode">tree,calendar,form,gantt</field>
<field name="view_id" ref="crm_case_calendar_view_meet"/>
<field name="domain" eval="[('state','in',('pending','draft','open')),('date','>=',time.strftime('%Y-%m-%d'))]"/>
<field name="domain"
eval="[('state','in',('pending','draft','open')),('date','>=',time.strftime('%Y-%m-%d'))]" />
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_calendar_view_meetall3">
<field name="sequence" eval="2"/>
<field name="view_mode">calendar</field>
<field name="view_id" ref="crm_case_calendar_view_meet"/>
<field name="act_window_id" ref="crm_case_category_act_meetall3"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_view_meetall3">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm_case_tree_view_meet"/>
<field name="act_window_id" ref="crm_case_category_act_meetall3"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_form_view_meetall3">
<field name="sequence" eval="3"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_case_form_view_meet"/>
<field name="act_window_id" ref="crm_case_category_act_meetall3"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_gantt_view_meetall3">
<field name="sequence" eval="2"/>
<field name="view_mode">gantt</field>

View File

@ -1,9 +1,8 @@
<?xml version="1.0"?>
<openerp>
<data>
# ------------------------------------------------------
# Meetings Categories
# ------------------------------------------------------
<!-- CRM Meetings Categories Form View -->
<record id="crm_meeting_categ_action" model="ir.actions.act_window">
<field name="name">Meeting Categories</field>
@ -13,11 +12,11 @@
<field name="domain">[('object_id.model', '=', 'crm.meeting')]</field>
<field name="context">{'object_id':'crm.meeting'}</field>
</record>
<menuitem action="crm_meeting_categ_action" id="menu_crm_case_meeting-act" parent="crm.menu_crm_case_categ"/>
# ------------------------------------------------------
# Meetings
# ------------------------------------------------------
<menuitem action="crm_meeting_categ_action"
id="menu_crm_case_meeting-act" parent="crm.menu_crm_case_categ" />
<!-- CRM Meetings Form View -->
<record model="ir.ui.view" id="crm_case_form_view_meet">
<field name="name">CRM - Meetings Form</field>
@ -28,18 +27,28 @@
<group col="6" colspan="4">
<field name="name" select="1" string="Summary"
colspan="4" />
<field name="categ_id" widget="selection" string="Meeting Type" domain="[('object_id.model', '=', 'crm.meeting')]"/>
<field name="date" string="Start Date" required="1" on_change="onchange_dates(date,duration,False)"/>
<field name="duration" widget="float_time" on_change="onchange_dates(date,duration,False)"/>
<field name="date_deadline" string="End Date" required="1" on_change="onchange_dates(date,False,date_deadline)"/>
<field name="categ_id" widget="selection"
string="Meeting Type"
domain="[('object_id.model', '=', 'crm.meeting')]" />
<field name="date" string="Start Date" required="1"
on_change="onchange_dates(date,duration,False)" />
<field name="duration" widget="float_time"
on_change="onchange_dates(date,duration,False)" />
<field name="date_deadline" string="End Date"
required="1"
on_change="onchange_dates(date,False,date_deadline)" />
<field name="location" />
<field name="alarm_id" string="Reminder" widget="selection" />
<field name="alarm_id" string="Reminder"
widget="selection" />
<group colspan="2" col="4" >
<field name="rrule_type" string="Recurrency"
colspan="1" attrs="{'readonly':[('recurrent_uid','!=',False)]}"/>
<button string="Edit All" help="Edit all Ourrences of recurrent Meeting" attrs="{'invisible':[('rrule_type','in', ('none', False))]}"
name="%(base_calendar.action_calendar_event_edit_all)d" icon="gtk-edit"
type="action" context="{'model' : 'crm.meeting', 'date': date, 'date_deadline': date_deadline}" />
<button string="Edit All"
help="Edit all Ourrences of recurrent Meeting"
attrs="{'invisible':[('rrule_type','in', ('none', False))]}"
name="%(base_calendar.action_calendar_event_edit_all)d"
icon="gtk-edit" type="action"
context="{'model' : 'crm.meeting', 'date': date, 'date_deadline': date_deadline}" />
</group>
</group>
@ -151,19 +160,29 @@
<separator colspan="4" string="" />
<group col="6" colspan="4">
<field name="state" select="2" />
<button name="do_tentative" states="needs-action,declined,accepted"
string="Uncertain" type="object"
icon="terp-crm" />
<button name="do_accept" string="Accept" states="needs-action,tentative,declined"
type="object" icon="gtk-apply" />
<button name="do_decline" string="Decline" states="needs-action,tentative,accepted"
type="object" icon="gtk-cancel" />
<button name="do_tentative"
states="needs-action,declined,accepted"
string="Uncertain"
type="object"
icon="terp-crm" />
<button name="do_accept"
string="Accept"
states="needs-action,tentative,declined"
type="object"
icon="gtk-apply" />
<button name="do_decline"
string="Decline"
states="needs-action,tentative,accepted"
type="object"
icon="gtk-cancel" />
<button
name="%(base_calendar.action_view_calendar_invite_attendee_wizard)d"
string="Delegate" type="action"
icon="gtk-sort-descending" states="needs-action,tentative,declined,accepted"
context="{'model' : 'calendar.attendee', 'attendee_field' : 'child_ids'}" />
</group>
name="%(base_calendar.action_view_calendar_invite_attendee_wizard)d"
string="Delegate"
type="action"
icon="gtk-sort-descending"
states="needs-action,tentative,declined,accepted"
context="{'model' : 'calendar.attendee', 'attendee_field' : 'child_ids'}" />
</group>
</page>
<page string="Other">
<field name="user_id"/>
@ -179,23 +198,29 @@
</field>
</record>
<!-- CRM Meeting Tree View -->
<record model="ir.ui.view" id="crm_case_tree_view_meet">
<field name="name">CRM - Meetings Tree</field>
<field name="model">crm.meeting</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Meetings" colors="red:state=='open';black:state in ('draft', 'cancel','done','pending')">
<field name="id" widget="char"/>
<field name="name" string="Subject"/>
<field name="partner_id" string="Partner"/>
<field name="section_id" />
<field name="date" string="Meeting Date"/>
<field name="categ_id"/>
<field name="user_id"/>
<field name="state"/>
<tree string="Meetings"
colors="red:state=='open';black:state in ('draft', 'cancel','done','pending')">
<field name="id" widget="char" />
<field name="name" string="Subject" />
<field name="partner_id" string="Partner" />
<field name="section_id" />
<field name="date" string="Meeting Date" />
<field name="categ_id" />
<field name="user_id" />
<field name="state" />
</tree>
</field>
</record>
<!-- CRM Meeting Calendar -->
<record model="ir.ui.view" id="crm_case_calendar_view_meet">
<field name="name">CRM - Meetings Calendar</field>
<field name="model">crm.meeting</field>
@ -210,6 +235,8 @@
</field>
</record>
<!-- CRM Meeting Gantt -->
<record id="crm_case_gantt_view_meet" model="ir.ui.view">
<field name="name">CRM - Meetings Gantt</field>
<field name="model">crm.meeting</field>
@ -223,6 +250,9 @@
</gantt>
</field>
</record>
<!-- CRM Meeting Search View -->
<record id="view_crm_case_meetings_filter" model="ir.ui.view">
<field name="name">CRM - Meetings Search</field>
<field name="model">crm.meeting</field>
@ -230,24 +260,33 @@
<field name="arch" type="xml">
<search string="Search Meetings">
<group col="12" colspan="4">
<filter icon="terp-crm" string="My Meetings" domain="[('user_id','=',uid)]" help="My Meetings"/>
<filter icon="terp-crm" string="Current" domain="[('state','in',('draft', 'open'))]" default="1" help="Current Meetings"/>
<filter icon="terp-crm" string="Confirmed" domain="[('state','=','done')]" help="Confirmed Meetings"/>
<filter icon="terp-crm" string="My Meetings"
domain="[('user_id','=',uid)]"
help="My Meetings" />
<filter icon="terp-crm" string="Current"
domain="[('state','in',('draft', 'open'))]"
default="1" help="Current Meetings" />
<filter icon="terp-crm" string="Confirmed"
domain="[('state','=','done')]"
help="Confirmed Meetings" />
<separator orientation="vertical"/>
<field name="name" select="1" string="Subject"/>
<field name="partner_id" select="1"/>
<field name="section_id" default="context.get('section_id', False)" select="1" widget="selection">
<filter icon="terp-crm"
domain="[('section_id','=',context.get('section_id',False))]"
help="My section"
/>
</field>
<field name="partner_id" select="1" />
<field name="section_id"
default="context.get('section_id', False)"
select="1" widget="selection">
<filter icon="terp-crm"
domain="[('section_id','=',context.get('section_id',False))]"
help="My section" />
</field>
<field name="user_id" select="1" widget="selection"/>
</group>
</search>
</field>
</record>
<!-- Calendar Attendee Form View -->
<record id="attendee_form_view_inherit" model="ir.ui.view">
<field name="name">calendar.attendee.form.inherit</field>
<field name="model">calendar.attendee</field>
@ -260,6 +299,8 @@
</field>
</record>
<!-- Calendar Attendee Tree View -->
<record id="attendee_tree_view_inherit" model="ir.ui.view">
<field name="name">calendar.attendee.tree.inherit</field>
<field name="model">calendar.attendee</field>

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@ -15,13 +15,18 @@
# 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/>.
#
##############################################################################
import time
def som(cr, uid, partner_id, args):
"""
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks
"""
result = args['som_interval_default']
max = args['som_interval_max'] or 4
factor = args['som_interval_decrease']
@ -32,8 +37,8 @@ def som(cr, uid, partner_id, args):
'''
select s.factor from res_partner_event e
left join res_partner_som s
on (e.som=s.id) where partner_id=%s and date>=%s and date<%s''',
(partner_id,
on (e.som=s.id) where partner_id=%s and date>=%s and date<%s''',
(partner_id,
time.strftime('%Y-%m-%d', time.gmtime(date_start)),
time.strftime('%Y-%m-%d', time.gmtime(next_date))))

View File

@ -32,12 +32,22 @@ AVAILABLE_STATES = [
]
class crm_opportunity(osv.osv):
""" Opportunity Cases """
_name = "crm.opportunity"
_description = "Opportunity Cases"
_order = "id desc"
_inherit = 'crm.case'
def _compute_openday(self, cr, uid, ids, name, args, context={}):
"""
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of Opendays IDs
@return: difference between current date and log date
@param context: A standard dictionary for contextual values
"""
result = {}
for r in self.browse(cr, uid, ids , context):
result[r.id] = 0
@ -58,9 +68,18 @@ class crm_opportunity(osv.osv):
return result
def _compute_closeday(self, cr, uid, ids, name, args, context={}):
"""
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of closedays IDs
@return: difference between current date and closed date
@param context: A standard dictionary for contextual values
"""
result = {}
for r in self.browse(cr, uid, ids , context):
result[r.id] = 0
if r.date_closed:
date_create = datetime.strptime(r.create_date, "%Y-%m-%d %H:%M:%S")
date_close = datetime.strptime(r.date_closed, "%Y-%m-%d %H:%M:%S")
@ -70,14 +89,19 @@ class crm_opportunity(osv.osv):
return result
_columns = {
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
'type_id': fields.many2one('crm.case.resource.type', 'Resource Type', 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')]"),
'categ_id': fields.many2one('crm.case.categ', 'Category', \
domain="[('section_id','=',section_id), \
('object_id.model', '=', 'crm.opportunity')]"),
'type_id': fields.many2one('crm.case.resource.type', 'Resource Type',\
domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'probability': fields.float('Probability (%)'),
'planned_revenue': fields.float('Expected Revenue'),
'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
'ref': fields.reference('Reference', selection=crm._links_get, size=128),
'ref2': fields.reference('Reference 2', selection=crm._links_get, size=128),
'date_closed': fields.datetime('Closed', readonly=True),
'user_id': fields.many2one('res.users', 'Salesman'),
'phone': fields.char("Phone", size=64),
@ -94,14 +118,29 @@ class crm_opportunity(osv.osv):
}
def onchange_stage_id(self, cr, uid, ids, stage_id, context={}):
""" @param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of stages IDs
@stage_id: change state id on run time """
if not stage_id:
return {'value':{}}
stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context)
if not stage.on_change:
return {'value':{}}
return {'value':{'probability':stage.probability}}
def stage_next(self, cr, uid, ids, context={}):
""" @param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of stage nexts IDs
@param context: A standard dictionary for contextual values """
res = super(crm_opportunity, self).stage_next(cr, uid, ids, context=context)
for case in self.browse(cr, uid, ids, context):
if case.stage_id and case.stage_id.on_change:
@ -109,6 +148,13 @@ class crm_opportunity(osv.osv):
return res
def stage_previous(self, cr, uid, ids, context={}):
""" @param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of stage previouss IDs
@param context: A standard dictionary for contextual values """
res = super(crm_opportunity, self).stage_previous(cr, uid, ids, context=context)
for case in self.browse(cr, uid, ids, context):
if case.stage_id and case.stage_id.on_change:

View File

@ -1,8 +1,7 @@
<?xml version="1.0"?>
<openerp>
<data noupdate="1">
<!-- <menuitem id="menu_presale" name="Sales" parent="crm.menu_crm" sequence="4"/>-->
<act_window
id="act_crm_opportunity_crm_meeting_new"
name="Meetings"
@ -21,8 +20,8 @@
view_mode="calendar,tree,form"
context="{'default_duration': 1.0}"
domain="[('user_id','=',uid)]"
view_type="form"/>
view_type="form"/>
<record model="ir.actions.act_window" id="crm_case_category_act_oppor11">
<field name="name">Opportunities</field>
<field name="res_model">crm.opportunity</field>
@ -48,58 +47,11 @@
<field name="view_id" ref="crm_case_graph_view_opportunity"/>
<field name="act_window_id" ref="crm_case_category_act_oppor11"/>
</record>
<menuitem id="base.menu_sales" name="Sales" parent="base.menu_base_partner" sequence="1"/>
<menuitem name="Opportunities" id="menu_crm_case_opp" parent="base.menu_sales" action="crm_case_category_act_oppor11" sequence="2"/><!--
<menuitem id="base.menu_sales" name="Sales"
parent="base.menu_base_partner" sequence="1" />
<menuitem name="Opportunities" id="menu_crm_case_opp"
parent="base.menu_sales" action="crm_case_category_act_oppor11"
sequence="2" />
MENU
REPORTS
<record model="ir.actions.act_window" id="action_report_crm_case_oppor_user">
<field name="res_model">report.crm.case.user</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support3)+')]'"/>
<field name="context" eval="{'default_state':'open'}"/>
</record>
<menuitem id="next_id_64" name="Reporting" parent="crm.menu_crm" sequence="50"/>
<menuitem name="Opportunity" parent="next_id_64" id="menu_action_report_crm_case_oppor"/>
<menuitem name="Cases by Opportunities and User" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_user" id="menu_action_report_crm_case_oppor_user"/>
<record model="ir.actions.act_window" id="action_report_crm_case_oppor_categ">
<field name="res_model">report.crm.case.section.categ2</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="context" eval="{'default_state':'open'}"/>
</record>
<menuitem name="Cases by Opportunities and Type" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_categ" id="menu_action_report_crm_case_oppor_categ"/>
<record model="ir.actions.act_window" id="action_report_crm_case_oppor_stage">
<field name="res_model">report.crm.case.section.stage</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="context" eval="{'default_state':'open'}"/>
</record>
<menuitem name="Cases by Opportunities and Stage" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_stage" id="menu_action_report_crm_case_oppor_stage"/>
<record model="ir.actions.act_window" id="action_report_crm_case_oppor_categ_stage">
<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="context" eval="{'default_state':'open'}"/>
</record>
<menuitem name="Cases by Opportunities, Category and Stage" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_categ_stage" id="menu_action_report_crm_case_oppor_categ_stage"/>
<record model="ir.actions.act_window" id="action_report_crm_case_oppor_categ_categ2">
<field name="res_model">report.crm.case.section.categ.categ2</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="context" eval="{'default_state':'open'}"/>
</record>
<menuitem name="Cases by Opportunities, Category and Type" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_categ_categ2" id="menu_action_report_crm_case_oppor_categ_categ2"/>
--></data>
</data>
</openerp>

View File

@ -2,9 +2,7 @@
<openerp>
<data>
# ------------------------------------------------------
# Opportunity Categories
# ------------------------------------------------------
<!-- Opportunity Categories Form View -->
<record id="crm_opportunity_categ_action" model="ir.actions.act_window">
<field name="name">Opportunity Categories</field>
@ -14,10 +12,13 @@
<field name="domain">[('object_id.model', '=', 'crm.opportunity')]</field>
<field name="context">{'object_id':'crm.opportunity'}</field>
</record>
<menuitem action="crm_opportunity_categ_action" id="menu_crm_case_opportunity-act" parent="crm.menu_crm_case_categ"/>
# ------------------------------------------------------
# Stage
# ------------------------------------------------------
<menuitem action="crm_opportunity_categ_action"
id="menu_crm_case_opportunity-act"
parent="crm.menu_crm_case_categ" />
<!-- Opportunity Stages Form View-->
<record id="crm_opportunity_stage_act" model="ir.actions.act_window">
<field name="name">Opportunity Stages</field>
<field name="res_model">crm.case.stage</field>
@ -26,11 +27,13 @@
<field name="domain">[('object_id.model', '=', 'crm.opportunity')]</field>
<field name="context">{'object_id':'crm.opportunity'}</field>
</record>
<menuitem action="crm_opportunity_stage_act" id="menu_crm_opportunity_stage_act" parent="crm.menu_crm_case_stage"/>
# ------------------------------------------------------
Resource Type
# ------------------------------------------------------
<menuitem action="crm_opportunity_stage_act"
id="menu_crm_opportunity_stage_act"
parent="crm.menu_crm_case_stage" />
<!-- Opportunity Resource Type Form View -->
<record id="crm_opportunity_resource_act" model="ir.actions.act_window">
<field name="name">Opportunity Resource Type</field>
<field name="res_model">crm.case.resource.type</field>
@ -39,14 +42,13 @@
<field name="domain">[('object_id.model', '=', 'crm.opportunity')]</field>
<field name="context">{'object_id':'crm.opportunity'}</field>
</record>
<menuitem action="crm_opportunity_resource_act" id="menu_crm_opportunity_resource_act" parent="crm.menu_crm_case_resource_type"/>
# ------------------------------------------------------
# Opportunities
# ------------------------------------------------------
<menuitem action="crm_opportunity_resource_act"
id="menu_crm_opportunity_resource_act"
parent="crm.menu_crm_case_resource_type" />
<!-- Opportunities Form View -->
<record model="ir.ui.view" id="crm_case_form_view_oppor">
<field name="name">Opportunities</field>
@ -58,9 +60,15 @@
<field name="name" string="Opportunity"/>
<label string="Stage:" align="1.0"/>
<group colspan="1" col="4">
<field name="stage_id" nolabel="1" on_change="onchange_stage_id(stage_id)" widget="selection" domain="[('object_id.model', '=', 'crm.opportunity')]"/>
<button name="stage_previous" states="open,pending" type="object" icon="gtk-go-back" string=""/>
<button name="stage_next" states="open,pending" type="object" icon="gtk-go-forward" string=""/>
<field name="stage_id" nolabel="1"
on_change="onchange_stage_id(stage_id)"
widget="selection"
domain="[('object_id.model', '=', 'crm.opportunity')]" />
<button name="stage_previous"
states="open,pending" type="object"
icon="gtk-go-back" string="" />
<button name="stage_next" states="open,pending"
type="object" icon="gtk-go-forward" string="" />
</group>
<field name="user_id"/>
<button string="Schedule Meeting"
@ -75,9 +83,14 @@
<page string="Opportunity">
<group col="3" colspan="2">
<separator colspan="3" string="Contacts"/>
<field name="partner_id" select="1" on_change="onchange_partner_id(partner_id, email_from)" colspan="2"/>
<field name="partner_address_id" string="Contact" on_change="onchange_partner_address_id(partner_address_id, email_from)" colspan="1"/>
<field name="email_from" string="Email"/>
<field name="partner_id" select="1"
on_change="onchange_partner_id(partner_id, email_from)"
colspan="2" />
<field name="partner_address_id"
string="Contact"
on_change="onchange_partner_address_id(partner_address_id, email_from)"
colspan="1" />
<field name="email_from" string="Email" />
<field name="phone"/>
</group>
<group col="2" colspan="2">
@ -85,7 +98,9 @@
<field name="type_id" select="1" string="Campaign"/>
<field name="section_id" colspan="1" widget="selection"/>
<field name="priority" string="Priority"/>
<field name="categ_id" select="1" string="Category" widget="selection" domain="[('object_id.model', '=', 'crm.opportunity')]"/>
<field name="categ_id" select="1"
string="Category" widget="selection"
domain="[('object_id.model', '=', 'crm.opportunity')]" />
</group>
<separator colspan="4" string="Details"/>
@ -94,12 +109,24 @@
<separator colspan="4"/>
<group col="8" colspan="4">
<field name="state" select="2"/>
<button name="case_open" string="Open" states="draft,pending" type="object" icon="gtk-go-forward"/>
<button name="case_escalate" string="Escalate" states="open,draft,pending" type="object" icon="gtk-go-up"/>
<button name="case_pending" string="Pending" states="draft,open" type="object" icon="gtk-media-pause"/>
<button name="case_close" string="Mark Won" states="open,draft,pending" type="object" icon="gtk-close"/>
<button name="case_cancel" string="Mark Lost" states="draft,open,pending" type="object" icon="gtk-cancel"/>
<button name="case_reset" string="Reset to New" states="done,cancel" type="object" icon="gtk-convert"/>
<button name="case_open" string="Open"
states="draft,pending" type="object"
icon="gtk-go-forward" />
<button name="case_escalate" string="Escalate"
states="open,draft,pending" type="object"
icon="gtk-go-up" />
<button name="case_pending" string="Pending"
states="draft,open" type="object"
icon="gtk-media-pause" />
<button name="case_close" string="Mark Won"
states="open,draft,pending" type="object"
icon="gtk-close" />
<button name="case_cancel" string="Mark Lost"
states="draft,open,pending" type="object"
icon="gtk-cancel" />
<button name="case_reset" string="Reset to New"
states="done,cancel" type="object"
icon="gtk-convert" />
</group>
</page>
@ -169,6 +196,9 @@
</form>
</field>
</record>
<!-- Opportunities Tree View -->
<record model="ir.ui.view" id="crm_case_tree_view_oppor">
<field name="name">Opportunities Tree</field>
<field name="model">crm.opportunity</field>
@ -181,21 +211,35 @@
<field name="stage_id"/>
<field name="categ_id" invisible="1"/>
<field name="type_id" invisible="1"/>
<button name="stage_previous" string="Previous" states="open,pending" type="object" icon="gtk-go-back"/>
<button name="stage_next" string="Next" states="open,pending" type="object" icon="gtk-go-forward"/>
<button name="stage_previous" string="Previous"
states="open,pending" type="object" icon="gtk-go-back" />
<button name="stage_next" string="Next"
states="open,pending" type="object"
icon="gtk-go-forward" />
<field name="planned_revenue" sum="Total of Planned Revenue"/>
<field name="probability" widget="progressbar" avg="Avg. of Probability"/>
<field name="date_deadline" string="Excepted Closing"/>
<field name="section_id"/>
<field name="user_id"/>
<field name="state"/>
<button name="case_open" string="Open" states="draft,pending" type="object" icon="gtk-go-forward"/>
<button name="case_close" string="Won" states="open,draft,pending" type="object" icon="gtk-close"/>
<button name="case_pending" string="Pending" states="open,draft" type="object" icon="gtk-media-pause"/>
<button name="case_cancel" string="Lost" states="draft,open,pending" type="object" icon="gtk-cancel"/>
<button name="case_open" string="Open"
states="draft,pending" type="object"
icon="gtk-go-forward" />
<button name="case_close" string="Won"
states="open,draft,pending" type="object"
icon="gtk-close" />
<button name="case_pending" string="Pending"
states="open,draft" type="object"
icon="gtk-media-pause" />
<button name="case_cancel" string="Lost"
states="draft,open,pending" type="object"
icon="gtk-cancel" />
</tree>
</field>
</record>
<!-- Opportunities Graph View -->
<record model="ir.ui.view" id="crm_case_graph_view_opportunity">
<field name="name">CRM - Opportunity Graph</field>
<field name="model">crm.opportunity</field>
@ -209,6 +253,8 @@
</field>
</record>
<!-- Opportunities Search View -->
<record id="view_crm_case_opportunities_filter" model="ir.ui.view">
<field name="name">CRM - Opportunities Search</field>
<field name="model">crm.opportunity</field>
@ -217,11 +263,12 @@
<search string="Search Opportunities">
<filter icon="gtk-home" string="Today"
domain="[('create_date','&lt;', time.strftime('%%Y-%%m-%%d 23:59:59')), ('create_date','&gt;=', time.strftime('%%Y-%%m-%%d 23:59:59'))]"
help="Todays' Opportunities"
/>
help="Todays' Opportunities" />
<filter icon="gtk-media-rewind" string="7 Days"
help="Opportunities during last 7 days"
domain="[('create_date','&lt;', time.strftime('%%Y-%%m-%%d')), ('create_date','&gt;=',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
domain="[('create_date','&lt;', time.strftime('%%Y-%%m-%%d')),\
('create_date','&gt;=',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
/>
<separator orientation="vertical"/>
<field name="name" string="Opportunity"/>
@ -232,10 +279,12 @@
help="My Opportunities" default="1"
/>
</field>
<field name="section_id" default="context.get('section_id', False)" select="1" widget="selection">
<filter icon="terp-crm"
domain="[('section_id','=',context.get('section_id',False))]"
help="My section"/>
<field name="section_id"
default="context.get('section_id', False)" select="1"
widget="selection">
<filter icon="terp-crm"
domain="[('section_id','=',context.get('section_id',False))]"
help="My section" />
</field>
<field name="state">
<filter icon="gtk-media-rewind"
@ -245,15 +294,28 @@
</field>
<newline/>
<group expand="1" string="Group By..." colspan="4">
<filter string="Stage" icon="terp-crm" domain="[]" context="{'group_by':'stage_id'}"/>
<filter string="Category" icon="terp-crm" domain="[]" context="{'group_by':'categ_id'}"/>
<filter string="Campaign" icon="terp-crm" domain="[]" context="{'group_by':'type_id'}"/>
<separator orientation="vertical"/>
<filter string="Partner" icon="terp-crm" domain="[]" context="{'group_by':'partner_id'}"/>
<filter string="Salesman" icon="terp-crm" domain="[]" context="{'group_by':'user_id'}"/>
<separator orientation="vertical"/>
<filter string="Creation" icon="terp-project" domain="[]" context="{'group_by':'create_date'}"/>
<filter string="Exp.Closing" icon="terp-project" domain="[]" context="{'group_by':'date_deadline'}"/>
<filter string="Stage" icon="terp-crm" domain="[]"
context="{'group_by':'stage_id'}" />
<filter string="Category" icon="terp-crm"
domain="[]" context="{'group_by':'categ_id'}" />
<filter string="Campaign" icon="terp-crm"
domain="[]" context="{'group_by':'type_id'}" />
<separator orientation="vertical" />
<filter string="Partner" icon="terp-crm" domain="[]"
context="{'group_by':'partner_id'}" />
<filter string="Salesman" icon="terp-crm"
domain="[]" context="{'group_by':'user_id'}" />
<separator orientation="vertical" />
<filter string="Creation" icon="terp-project"
domain="[]" context="{'group_by':'create_date'}" />
<filter string="Exp.Closing" icon="terp-project"
domain="[]" context="{'group_by':'date_deadline'}" />
</group>
</search>
</field>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard
id="wizard_partner_create_opportunity"
keyword="client_action_multi"
model="res.partner"
name="crm.case.opportunity.partner_opportunity"
menu="False"
string="Create Opportunity"/>
</data>
</openerp>

View File

@ -24,26 +24,38 @@ import crm
import time
class crm_phonecall(osv.osv):
""" Phonecall Cases """
_name = "crm.phonecall"
_description = "Phonecall Cases"
_order = "id desc"
_inherit = 'crm.case'
_columns = {
'duration': fields.float('Duration'),
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.phonecall')]"),
'categ_id': fields.many2one('crm.case.categ', 'Category', \
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.phonecall')]"),
'partner_phone': fields.char('Phone', size=32),
'partner_contact': fields.related('partner_address_id', 'name', type="char", string="Contact", size=128),
'partner_contact': fields.related('partner_address_id', 'name',\
type="char", string="Contact", size=128),
'partner_mobile': fields.char('Mobile', size=32),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'canal_id': fields.many2one('res.partner.canal', 'Channel',help="The channels represent the different communication modes available with the customer." \
" With each commercial opportunity, you can indicate the canall which is this opportunity source."),
'canal_id': fields.many2one('res.partner.canal', 'Channel',\
help="The channels represent the different communication\
modes available with the customer." \
" With each commercial opportunity, you can indicate\
the canall which is this opportunity source."),
'date_closed': fields.datetime('Closed', readonly=True),
'date': fields.datetime('Date'),
'opportunity_id':fields.many2one ('crm.opportunity', 'Opportunity'),
}
_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
}
crm_phonecall()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -12,8 +12,8 @@
domain="[('partner_id', '=', active_id)]"
/>
<!-- PHONE CALLS (menu) -->
######################## PHONE CALLS (menu) ###########################
<record model="ir.actions.act_window" id="crm_case_categ_phone0">
<field name="name">Phone Calls</field>
<field name="res_model">crm.phonecall</field>
@ -22,26 +22,30 @@
<field name="view_id" ref="crm_case_phone_tree_view"/>
<field name="search_view_id" ref="crm.view_crm_case_phonecalls_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_phone0">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm_case_phone_tree_view"/>
<field name="act_window_id" ref="crm_case_categ_phone0"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_calendar_phone0">
<field name="sequence" eval="2"/>
<field name="view_mode">calendar</field>
<field name="view_id" ref="crm_case_phone_calendar_view"/>
<field name="act_window_id" ref="crm_case_categ_phone0"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_form_phone0">
<field name="sequence" eval="3"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_case_phone_form_view"/>
<field name="act_window_id" ref="crm_case_categ_phone0"/>
</record>
<menuitem name="Phone Calls" id="menu_crm_case_phone" parent="base.menu_base_partner" sequence="5"/>
<menuitem name="Phone Calls" id="menu_crm_case_phone"
parent="base.menu_base_partner" sequence="5" />
<record model="ir.actions.act_window" id="crm_case_categ_phone_incoming0">
<field name="name">Inbound</field>
@ -53,25 +57,32 @@
<field name="context">{'set_editable':True,'default_state':'open'}</field>
<field name="search_view_id" ref="crm.view_crm_case_phonecalls_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_phone_incoming0">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm_case_phone_tree_view"/>
<field name="act_window_id" ref="crm_case_categ_phone_incoming0"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_calendar_phone_incoming0">
<field name="sequence" eval="2"/>
<field name="view_mode">calendar</field>
<field name="view_id" ref="crm_case_phone_calendar_view"/>
<field name="act_window_id" ref="crm_case_categ_phone_incoming0"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_form_phone_incoming0">
<field name="sequence" eval="3"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_case_phone_form_view"/>
<field name="act_window_id" ref="crm_case_categ_phone_incoming0"/>
</record>
<menuitem name="Inbound" id="menu_crm_case_phone_inbound" parent="crm.menu_crm_case_phone" action="crm_case_categ_phone_incoming0"/>
<menuitem name="Inbound" id="menu_crm_case_phone_inbound"
parent="crm.menu_crm_case_phone"
action="crm_case_categ_phone_incoming0" />
<record model="ir.actions.act_window" id="crm_case_categ_phone_outgoing0">
<field name="name">Outbound</field>
<field name="res_model">crm.phonecall</field>
@ -82,18 +93,21 @@
<field name="context">{'default_state':'open'}</field>
<field name="search_view_id" ref="crm.view_crm_case_phonecalls_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_phone_outgoing0">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm_case_phone_tree_view"/>
<field name="act_window_id" ref="crm_case_categ_phone_outgoing0"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_calendar_phone_outgoing0">
<field name="sequence" eval="2"/>
<field name="view_mode">calendar</field>
<field name="view_id" ref="crm_case_phone_calendar_view"/>
<field name="act_window_id" ref="crm_case_categ_phone_outgoing0"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_form_phone_outgoing0">
<field name="sequence" eval="3"/>
<field name="view_mode">form</field>
@ -101,7 +115,9 @@
<field name="act_window_id" ref="crm_case_categ_phone_outgoing0"/>
</record>
<menuitem name="Outbound" id="menu_crm_case_phone_outbound" parent="crm.menu_crm_case_phone" action="crm_case_categ_phone_outgoing0"/>
<menuitem name="Outbound" id="menu_crm_case_phone_outbound"
parent="crm.menu_crm_case_phone"
action="crm_case_categ_phone_outgoing0" />
</data>
</openerp>

View File

@ -2,9 +2,7 @@
<openerp>
<data>
# ------------------------------------------------------
# Phonecall Categories
# ------------------------------------------------------
<!-- Phonecall Categories Form View -->
<record id="crm_phonecall_categ_action" model="ir.actions.act_window">
<field name="name">Phonecall Categories</field>
@ -15,12 +13,12 @@
<field name="context">{'object_id':'crm.phonecall'}</field>
</record>
<menuitem action="crm_phonecall_categ_action" id="menu_crm_case_phonecall-act" parent="crm.menu_crm_case_categ"/>
<menuitem action="crm_phonecall_categ_action"
id="menu_crm_case_phonecall-act" parent="crm.menu_crm_case_categ" />
# ------------------------------------------------------
Resource Type
# ------------------------------------------------------
<record id="crm_phonecall_resource_act" model="ir.actions.act_window">
<!-- ResourceType Form View -->
<record id="crm_phonecall_resource_act" model="ir.actions.act_window">
<field name="name">Phonecall Resource Type</field>
<field name="res_model">crm.case.resource.type</field>
<field name="view_type">form</field>
@ -28,27 +26,28 @@
<field name="domain">[('object_id.model', '=', 'crm.phonecall')]</field>
<field name="context">{'object_id':'crm.phonecall'}</field>
</record>
<menuitem action="crm_phonecall_resource_act" id="menu_crm_phonecall_resource_act" parent="crm.menu_crm_case_resource_type"/>
<menuitem action="crm_phonecall_resource_act"
id="menu_crm_phonecall_resource_act"
parent="crm.menu_crm_case_resource_type" />
# ------------------------------------------------------
# Phone Calls
# ------------------------------------------------------
<!-- PhoneCalls Tree View -->
<record model="ir.ui.view" id="crm_case_phone_tree_view">
<field name="name">CRM - Phone Calls Tree</field>
<field name="model">crm.phonecall</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Phone Calls" colors="grey:state in ('cancel','done');blue:state in ('pending',)">
<field name="date" string="Date"/>
<field name="name" string="Call Summary"/>
<field name="partner_id" string="Partner"/>
<field name="partner_contact"/>
<field name="partner_phone"/>
<field name="partner_phone"/>
<field name="user_id"/>
<button string="Opportunity"
<button string="Opportunity"
name="%(phonecall2opportunity_act)d"
states="draft,open,pending"
type="action" attrs="{'invisible':[('opportunity_id','!=',False)]}" />
@ -64,6 +63,8 @@
</field>
</record>
<!-- Phonecalls Form View -->
<record model="ir.ui.view" id="crm_case_phone_form_view">
<field name="name">CRM - Phone Call Form</field>
<field name="model">crm.phonecall</field>
@ -85,12 +86,12 @@
name="%(phonecall2opportunity_act)d"
icon="gtk-index" type="action"
attrs="{'invisible':[('opportunity_id','!=',False)]}" />
<label colspan="6" string=""/>
<button string="Schedule Other Call"
<label colspan="6" string=""/>
<button string="Schedule Other Call"
icon="gtk-redo"
name="%(phonecall_to_phonecall_act)d"
type="action" />
</group>
<group col="3" colspan="2">
<separator colspan="3" string="Contacts" />
@ -115,16 +116,27 @@
<separator colspan="4" />
<group col="8" colspan="4">
<field name="state" select="1" />
<button name="case_cancel" string="Cancel" states="draft,open,pending" type="object" icon="gtk-cancel"/>
<button name="case_open" string="Open" states="draft,pending" type="object" icon="gtk-go-forward"/>
<button name="case_pending" string="Not Held" states="open" type="object" icon="gtk-undo"/>
<button name="case_close" string="Held" states="open,draft,pending" type="object" icon="gtk-jump-to"/>
<button name="case_reset" string="Reset to Draft" states="done,cancel" type="object" icon="gtk-convert"/>
<button name="case_cancel" string="Cancel"
states="draft,open,pending" type="object"
icon="gtk-cancel" />
<button name="case_open" string="Open"
states="draft,pending" type="object"
icon="gtk-go-forward" />
<button name="case_pending" string="Not Held"
states="open" type="object" icon="gtk-undo" />
<button name="case_close" string="Held"
states="open,draft,pending" type="object"
icon="gtk-jump-to" />
<button name="case_reset" string="Reset to Draft"
states="done,cancel" type="object"
icon="gtk-convert" />
</group>
</form>
</field>
</record>
<!-- Phonecalls Calendar View -->
<record model="ir.ui.view" id="crm_case_phone_calendar_view">
<field name="name">CRM - Phone Calls Calendar</field>
<field name="model">crm.phonecall</field>
@ -133,11 +145,13 @@
<field name="arch" type="xml">
<calendar string="Phone Calls" date_start="date" color="user_id" date_delay="duration">
<field name="name"/>
<field name="partner_id"/>
<field name="partner_id"/>
</calendar>
</field>
</record>
<!-- Phonecalls Search View -->
<record id="view_crm_case_phonecalls_filter" model="ir.ui.view">
<field name="name">CRM - Phone Calls Search</field>
<field name="model">crm.phonecall</field>
@ -145,36 +159,50 @@
<field name="arch" type="xml">
<search string="Search Phonecalls">
<filter icon="gtk-home" string="Today"
domain="[('date','&lt;', time.strftime('%%Y-%%m-%%d 23:59:59')), ('date','&gt;=',datetime.strftime('%%Y-%%m-%%d 00:00:00'))]"
domain="[('date','&lt;', time.strftime('%%Y-%%m-%%d 23:59:59')),\
('date','&gt;=',datetime.strftime('%%Y-%%m-%%d 00:00:00'))]"
help="Todays's Phonecalls"
/>
<filter icon="gtk-media-rewind"
string="7 Days"
help="Phonecalls during last 7 days"
domain="[('date','&lt;', time.strftime('%%Y-%%m-%%d')), ('date','&gt;=',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
domain="[('date','&lt;', time.strftime('%%Y-%%m-%%d')),\
('date','&gt;=',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
/>
<separator orientation="vertical"/>
<field name="name" string="Call Summary"/>
<field name="partner_id"/>
<field name="user_id" widget="selection">
<filter icon="terp-partner" domain="[('user_id','=',uid)]" help="My Phonecalls" default="1"/>
<filter icon="terp-partner" domain="[('user_id','=',False)]" help="Unassigned Phonecalls"/>
<filter icon="terp-partner"
domain="[('user_id','=',uid)]" help="My Phonecalls"
default="1" />
<filter icon="terp-partner"
domain="[('user_id','=',False)]"
help="Unassigned Phonecalls" />
</field>
<field name="state">
<filter icon="gtk-index" domain="[('state','in',('open','draft' ))]" help="Current" default="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))]"
help="My section"/>
<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))]"
help="My section" />
</field>
<newline/>
<group expand="1" string="Group By..." colspan="4">
<filter string="Partner" icon="terp-crm" domain="[]" context="{'group_by':'partner_id'}"/>
<filter string="Responsible" icon="terp-crm" domain="[]" context="{'group_by':'user_id'}"/>
<separator orientation="vertical"/>
<filter string="Creation" icon="terp-project" domain="[]" context="{'group_by':'create_date'}"/>
<filter string="Date" icon="terp-project" domain="[]" context="{'group_by':'date'}"/>
<filter string="Partner" icon="terp-crm" domain="[]"
context="{'group_by':'partner_id'}" />
<filter string="Responsible" icon="terp-crm"
domain="[]" context="{'group_by':'user_id'}" />
<separator orientation="vertical" />
<filter string="Creation" icon="terp-project"
domain="[]" context="{'group_by':'create_date'}" />
<filter string="Date" icon="terp-project" domain="[]"
context="{'group_by':'date'}" />
</group>
</search>
</field>

View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard
id="wizard_crm_phonecall_meeting_set"
keyword="client_action_multi"
model="crm.phonecall"
name="crm.phonecall.meeting_set"
multi="True"
string="Schedule Meeting"/>
<wizard
id="wizard_crm_phonecall_partner_create"
keyword="client_action_multi"
model="crm.phonecall"
name="crm.phonecall.partner_create"
multi="True"
string="Create Partner"/>
<wizard
id="wizard_crm_phonecall_opportunity_set"
keyword="client_action_multi"
model="crm.phonecall"
name="crm.phonecall.opportunity_set"
multi="True"
string="Convert To Opportunity"/>
</data>
</openerp>

View File

@ -2,9 +2,7 @@
<openerp>
<data>
#
# Cases by section and category2 of case
#
<!-- Cases by section and category2 of case Tree View -->
<record model="ir.ui.view" id="view_crm_case_section_categ_tree">
<field name="name">CRM Report - Sections and Type(Tree)</field>
@ -25,6 +23,9 @@
</tree>
</field>
</record>
<!-- Cases by section and category2 of case Form View -->
<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.categ2</field>
@ -44,6 +45,9 @@
</form>
</field>
</record>
<!-- Cases by section and category2 of case Graph View -->
<record model="ir.ui.view" id="view_crm_case_section_categ_graph">
<field name="name">CRM Report - Sections and Type(Graph)</field>
<field name="model">report.crm.case.section.categ2</field>
@ -57,6 +61,8 @@
</field>
</record>
<!-- Cases by section and category2 of case Search View -->
<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.categ2</field>
@ -64,11 +70,17 @@
<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.localtime()[1])]" help="Cases by Section and Type for this month"/>
<separator orientation="vertical"/>
<field name="section_id" default="context.get('section_id', False)" select="1" widget="selection"/>
<field name="category2_id" select="1"/>
<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.localtime()[1])]"
help="Cases by Section and Type for this month" />
<separator orientation="vertical"/>
<field name="section_id"
default="context.get('section_id', False)"
select="1" widget="selection" />
<field name="category2_id" select="1"/>
<field name="nbr" select="1"/>
<field name="state" select="1"/>
</group>
@ -76,17 +88,16 @@
</field>
</record>
<!-- Cases by section and category2 of case Action -->
<record model="ir.actions.act_window" id="action_report_crm_case_section_categ_tree">
<field name="res_model">report.crm.case.section.categ2</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="search_view_id" ref="view_crm_case_section_categ_filter"/>
</record>
<!-- <menuitem parent="next_id_64" name="Cases by Section and Type" action="action_report_crm_case_section_categ_tree" id="menu_crm_case_section_categ_tree"/>-->
#
# Cases by section and stage
#
<!-- Cases by section and stage Tree View -->
<record model="ir.ui.view" id="view_crm_case_section_stage_tree">
<field name="name">CRM Report - Sections and Stage(Tree)</field>
@ -106,6 +117,9 @@
</tree>
</field>
</record>
<!-- Cases by section and stage Form View -->
<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>
@ -124,6 +138,9 @@
</form>
</field>
</record>
<!-- Cases by section and stage Graph View -->
<record model="ir.ui.view" id="view_crm_case_section_stage_graph">
<field name="name">CRM Report - Sections and Stage(Graph)</field>
<field name="model">report.crm.case.section.stage</field>
@ -136,6 +153,9 @@
</graph>
</field>
</record>
<!-- Cases by section and stage Search View -->
<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>
@ -143,9 +163,13 @@
<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.localtime()[1])]" help="Cases by Section and Stage for this month"/>
<separator orientation="vertical"/>
<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.localtime()[1])]"
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"/>
@ -154,6 +178,8 @@
</field>
</record>
<!-- Cases by section and stage Action -->
<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>
@ -161,9 +187,7 @@
<field name="search_view_id" ref="view_crm_case_section_stage_filter"/>
</record>
#
# Cases by section, category and stage
#
<!-- Cases by section, category and stage Tree View -->
<record model="ir.ui.view" id="view_crm_case_section_categ_stage_tree">
<field name="name">CRM Report - Section, Category and Stage(Tree)</field>
@ -183,6 +207,9 @@
</tree>
</field>
</record>
<!-- Cases by section, category and stage Form View -->
<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>
@ -202,6 +229,8 @@
</field>
</record>
<!-- Cases by section, category and stage Search View -->
<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>
@ -224,6 +253,9 @@
</search>
</field>
</record>
<!-- Cases by section, category and stage Graph View -->
<record model="ir.ui.view" id="view_crm_case_section_categ_stage_graph">
<field name="name">CRM Report - Section, Category and Stage(Select)</field>
<field name="model">report.crm.case.section.categ.stage</field>
@ -236,6 +268,9 @@
</graph>
</field>
</record>
<!-- Cases by section, category and stage Action -->
<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>
@ -243,9 +278,7 @@
<field name="search_view_id" ref="view_crm_case_section_categ_stage_filter"/>
</record>
#
# Cases by section, category and category2
#
<!-- Cases by section, category and category2 Tree View -->
<record model="ir.ui.view" id="view_crm_case_section_categ_categ2_tree">
<field name="name">CRM Report - Section, Category and Type(Tree)</field>
@ -266,6 +299,9 @@
</tree>
</field>
</record>
<!-- Cases by section, category and category2 Form View -->
<record model="ir.ui.view" id="view_crm_case_section_categ_categ2_form">
<field name="name">CRM Report - Section, Category and Type(Form)</field>
<field name="model">report.crm.case.section.categ.categ2</field>
@ -286,6 +322,8 @@
</field>
</record>
<!-- Cases by section, category and category2 Search View -->
<record id="view_crm_case_section_categ_categ2_filter" model="ir.ui.view">
<field name="name">CRM Report - Section, Category and Type(Select)</field>
<field name="model">report.crm.case.section.categ.categ2</field>
@ -308,6 +346,8 @@
</field>
</record>
<!-- Cases by section, category and category2 Graph View -->
<record model="ir.ui.view" id="view_crm_case_section_categ_categ2_graph">
<field name="name">CRM Report - Section, Category and Type(Select)</field>
<field name="model">report.crm.case.section.categ.categ2</field>
@ -320,6 +360,9 @@
</graph>
</field>
</record>
<!-- Cases by section, category and category2 Action -->
<record model="ir.actions.act_window" id="action_report_crm_case_section_categ_categ2_tree">
<field name="res_model">report.crm.case.section.categ.categ2</field>
<field name="view_type">form</field>

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/>.
#
##############################################################################
@ -31,19 +31,45 @@ class crm_segmentation(osv.osv):
'''
_name = "crm.segmentation"
_description = "Partner Segmentation"
_columns = {
'name': fields.char('Name', size=64, required=True, help='The name of the segmentation.'),
'description': fields.text('Description'),
'categ_id': fields.many2one('res.partner.category', 'Partner Category', required=True, help='The partner category that will be added to partners that match the segmentation criterions after computation.'),
'exclusif': fields.boolean('Exclusive', help='Check if the category is limited to partners that match the segmentation criterions. If checked, remove the category from partners that doesn\'t match segmentation criterions'),
'state': fields.selection([('not running','Not Running'),('running','Running')], 'Execution Status', readonly=True),
'categ_id': fields.many2one('res.partner.category', 'Partner Category',\
required=True, help='The partner category that will be \
added to partners that match the segmentation criterions after computation.'),
'exclusif': fields.boolean('Exclusive', help='Check if the category is \
limited to partners that match the segmentation criterions.\
If checked, remove the category from partners that doesn\'t \
match segmentation criterions'),
'state': fields.selection([('not running','Not Running'),\
('running','Running')], 'Execution Status', readonly=True),
'partner_id': fields.integer('Max Partner ID processed'),
'segmentation_line': fields.one2many('crm.segmentation.line', 'segmentation_id', 'Criteria', required=True),
'som_interval': fields.integer('Days per Periode', help="A period is the average number of days between two cycle of sale or purchase for this segmentation. It's mainly used to detect if a partner has not purchased or buy for a too long time, so we suppose that his state of mind has decreased because he probably bought goods to another supplier. Use this functionality for recurring businesses."),
'som_interval_max': fields.integer('Max Interval', help="The computation is made on all events that occured during this interval, the past X periods."),
'som_interval_decrease': fields.float('Decrease (0>1)', help="If the partner has not purchased (or bought) during a period, decrease the state of mind by this factor. It\'s a multiplication"),
'som_interval_default': fields.float('Default (0=None)', help="Default state of mind for period preceeding the 'Max Interval' computation. This is the starting state of mind by default if the partner has no event."),
'sales_purchase_active': fields.boolean('Use The Sales Purchase Rules', help='Check if you want to use this tab as part of the segmentation rule. If not checked, the criteria beneath will be ignored')
'segmentation_line': fields.one2many('crm.segmentation.line', \
'segmentation_id', 'Criteria', required=True),
'som_interval': fields.integer('Days per Periode', help="A period is the \
average number of days between two cycle of sale or\
purchase for this segmentation. It's mainly used to\
detect if a partner has not purchased or buy for a too \
long time, so we suppose that his state of mind has \
decreased because he probably bought goods to another \
supplier. Use this functionality for recurring businesses."),
'som_interval_max': fields.integer('Max Interval', help="The computation \
is made on all events that occured during this \
interval, the past X periods."),
'som_interval_decrease': fields.float('Decrease (0>1)', help="If the \
partner has not purchased (or bought) \
during a period, decrease the state of \
mind by this factor. It\'s a multiplication"),
'som_interval_default': fields.float('Default (0=None)', help="Default \
state of mind for period preceeding the \
'Max Interval' computation. This is the \
starting state of mind by default if the \
partner has no event."),
'sales_purchase_active': fields.boolean('Use The Sales Purchase Rules',\
help='Check if you want to use this tab as\
part of the segmentation rule. If not \
checked, the criteria beneath will be ignored')
}
_defaults = {
'partner_id': lambda *a: 0,
@ -54,11 +80,19 @@ class crm_segmentation(osv.osv):
}
def process_continue(self, cr, uid, ids, start=False):
categs = self.read(cr,uid,ids,['categ_id','exclusif','partner_id', 'sales_purchase_active', 'profiling_active'])
""" @param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of Process continues IDs"""
categs = self.read(cr, uid, ids, ['categ_id', 'exclusif', 'partner_id',\
'sales_purchase_active', 'profiling_active'])
for categ in categs:
if start:
if categ['exclusif']:
cr.execute('delete from res_partner_category_rel where category_id=%s', (categ['categ_id'][0],))
cr.execute('delete from res_partner_category_rel \
where category_id=%s', (categ['categ_id'][0],))
id = categ['id']
@ -77,7 +111,8 @@ class crm_segmentation(osv.osv):
partners.remove(pid)
for partner_id in partners:
cr.execute('insert into res_partner_category_rel (category_id,partner_id) values (%s,%s)', (categ['categ_id'][0],partner_id))
cr.execute('insert into res_partner_category_rel (category_id,partner_id) \
values (%s,%s)', (categ['categ_id'][0], partner_id))
cr.commit()
self.write(cr, uid, [id], {'state':'not running', 'partner_id':0})
@ -85,23 +120,39 @@ class crm_segmentation(osv.osv):
return True
def process_stop(self, cr, uid, ids, *args):
""" @param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of Process stops IDs"""
return self.write(cr, uid, ids, {'state':'not running', 'partner_id':0})
def process_start(self, cr, uid, ids, *args):
""" @param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of Process starts IDs """
self.write(cr, uid, ids, {'state':'running', 'partner_id':0})
return self.process_continue(cr, uid, ids, start=True)
crm_segmentation()
class crm_segmentation_line(osv.osv):
""" Segmentation line """
_name = "crm.segmentation.line"
_description = "Segmentation line"
_columns = {
'name': fields.char('Rule Name', size=64, required=True),
'segmentation_id': fields.many2one('crm.segmentation', 'Segmentation'),
'expr_name': fields.selection([('sale','Sale Amount'),('som','State of Mind'),('purchase','Purchase Amount')], 'Control Variable', size=64, required=True),
'expr_name': fields.selection([('sale','Sale Amount'),('som','State of Mind'),\
('purchase','Purchase Amount')], 'Control Variable', size=64, required=True),
'expr_operator': fields.selection([('<','<'),('=','='),('>','>')], 'Operator', required=True),
'expr_value': fields.float('Value', required=True),
'operator': fields.selection([('and','Mandatory Expression'),('or','Optional Expression')],'Mandatory / Optional', required=True),
'operator': fields.selection([('and','Mandatory Expression'),\
('or','Optional Expression')],'Mandatory / Optional', required=True),
}
_defaults = {
'expr_name': lambda *a: 'sale',
@ -109,6 +160,12 @@ class crm_segmentation_line(osv.osv):
'operator': lambda *a: 'and'
}
def test(self, cr, uid, ids, partner_id):
""" @param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of Tests IDs """
expression = {'<': lambda x,y: x<y, '=':lambda x,y:x==y, '>':lambda x,y:x>y}
ok = False
lst = self.read(cr, uid, ids)
@ -117,7 +174,8 @@ class crm_segmentation_line(osv.osv):
if cr.fetchone():
if l['expr_name']=='som':
datas = self.pool.get('crm.segmentation').read(cr, uid, [l['segmentation_id'][0]],
['som','som_interval','som_interval_max','som_interval_default', 'som_interval_decrease'])
['som','som_interval','som_interval_max',\
'som_interval_default', 'som_interval_decrease'])
value = crm_operators.som(cr, uid, partner_id, datas[0])
elif l['expr_name']=='sale':
cr.execute('SELECT SUM(l.price_unit * l.quantity) ' \
@ -155,10 +213,8 @@ class crm_segmentation_line(osv.osv):
if res:
return True
return True
crm_segmentation_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- <menuitem icon="terp-crm" id="menu_crm" name="CRM &amp; SRM"/>-->
<menuitem id="menu_crm_configuration" name="Cases" parent="base.menu_base_config" sequence="0"/>
<!-- Case Sections -->
<!-- Case Sections Form View -->
<record id="crm_case_section_view_form" model="ir.ui.view">
<field name="name">crm.case.section.form</field>
<field name="model">crm.case.section</field>
@ -25,6 +25,9 @@
</form>
</field>
</record>
<!-- Case Sections Tree View -->
<record id="crm_case_section_view_tree" model="ir.ui.view">
<field name="name">crm.case.section.tree</field>
<field name="model">crm.case.section</field>
@ -38,6 +41,9 @@
</tree>
</field>
</record>
<!-- Case Sections Action -->
<record id="crm_case_section_act" model="ir.actions.act_window">
<field name="name">Sections</field>
<field name="res_model">crm.case.section</field>
@ -45,9 +51,8 @@
<field name="view_id" ref="crm_case_section_view_tree"/>
</record>
# ------------------------------------------------------
# Stage
# ------------------------------------------------------
<!-- CRM Stage Tree View -->
<record model="ir.ui.view" id="crm_case_stage_tree">
<field name="name">crm.case.stage.tree</field>
<field name="model">crm.case.stage</field>
@ -62,6 +67,9 @@
</tree>
</field>
</record>
<!-- CRM Stage Form View -->
<record model="ir.ui.view" id="crm_case_stage_form">
<field name="name">crm.case.stage.form</field>
<field name="model">crm.case.stage</field>
@ -80,16 +88,21 @@
</form>
</field>
</record>
<!-- CRM Stage Action -->
<record id="crm_case_stage_act" model="ir.actions.act_window">
<field name="name">Stages</field>
<field name="res_model">crm.case.stage</field>
<field name="view_type">form</field>
<field name="view_id" ref="crm_case_stage_tree"/>
</record>
<menuitem id="menu_crm_case_stage" name="Stages" parent="crm.menu_crm_configuration"/>
<!-- Case Categories -->
<!-- Case Categories Form View -->
<record id="crm_case_categ-view" model="ir.ui.view">
<field name="name">crm.case.categ.form</field>
<field name="model">crm.case.categ</field>
@ -102,6 +115,9 @@
</form>
</field>
</record>
<!-- Case Categories Tree View -->
<record id="crm_case_categ_tree-view" model="ir.ui.view">
<field name="name">crm.case.categ.tree</field>
<field name="model">crm.case.categ</field>
@ -114,6 +130,8 @@
</field>
</record>
<!-- Case Categories Action -->
<record id="crm_case_categ-act" model="ir.actions.act_window">
<field name="name">Categories</field>
<field name="res_model">crm.case.categ</field>
@ -122,12 +140,13 @@
</record>
<menuitem id="menu_crm_case_categ" name="Categories" parent="crm.menu_crm_configuration"/>
<menuitem action="crm_case_section_act" id="menu_crm_case_section_act" parent="crm.menu_crm_configuration"/>
<menuitem action="crm_case_section_act"
id="menu_crm_case_section_act"
parent="crm.menu_crm_configuration" />
# ------------------------------------------------------
# Resource Type of case
# ------------------------------------------------------
<!-- Resource Type of case Tree View -->
<record model="ir.ui.view" id="crm_case_resource_type_tree">
<field name="name">crm.case.resource.type.tree</field>
<field name="model">crm.case.resource.type</field>
@ -140,6 +159,9 @@
</tree>
</field>
</record>
<!-- Resource Type of case Form View -->
<record model="ir.ui.view" id="crm_case_resource_type_form">
<field name="name">crm.case.resource.type.form</field>
<field name="model">crm.case.resource.type</field>
@ -153,18 +175,17 @@
</field>
</record>
<!-- Resource Type of case Action -->
<record id="crm_case_resource_type_act" model="ir.actions.act_window">
<field name="name">Resource Type</field>
<field name="res_model">crm.case.resource.type</field>
<field name="view_type">form</field>
<field name="view_id" ref="crm_case_resource_type_tree"/>
</record>
<menuitem id="menu_crm_case_resource_type" name="Resource Type" parent="crm.menu_crm_configuration"/>
<menuitem id="menu_crm_case_resource_type" name="Resource Type"
parent="crm.menu_crm_configuration" />
<!--<menuitem action="crm_case_resource_type_act" id="menu_crm_case_resource_act" parent="menu_crm_case_resource_type"/>-->
<!-- <menuitem id="next_id_52" name="All Cases" parent="crm.menu_crm" sequence="1"/>-->
<record id="crm_case_section_act_tree" model="ir.actions.act_window">
<field name="name">Cases by section</field>
<field name="res_model">crm.case.section</field>
@ -172,8 +193,8 @@
<field name="view_type">tree</field>
<field name="view_id" ref="crm_case_section_view_tree"/>
</record>
<!-- <menuitem action="crm_case_section_act_tree" id="menu_crm_case_section_act_tree" parent="next_id_52"/>-->
<!-- CRM Email Add CC Form View -->
<record id="view_crm_email_add_cc_wizard" model="ir.ui.view">
<field name="name">Add CC</field>
@ -197,6 +218,8 @@
</field>
</record>
<!-- CRM Email Add CC Action -->
<record id="action_view_crm_email_add_cc_wizard" model="ir.actions.act_window">
<field name="name">Add CC</field>
<field name="type">ir.actions.act_window</field>
@ -206,9 +229,8 @@
<field name="target">new</field>
</record>
<!-- Cases Tree View -->
<!-- Cases -->
<record id="crm_case_log_tree-view" model="ir.ui.view">
<field name="name">crm.case.log.tree</field>
<field name="model">crm.case.log</field>
@ -225,6 +247,7 @@
</field>
</record>
<!--Case History Tree View -->
<record id="crm_case_history_tree-view" model="ir.ui.view">
<field name="name">crm.case.history.tree</field>
@ -241,19 +264,24 @@
</field>
</record>
<!-- Case Calendar View -->
<record id="crm_case_calendar-view" model="ir.ui.view">
<field name="name">crm.case.calendar</field>
<field name="model">crm.case</field>
<field name="type">calendar</field>
<field name="arch" type="xml">
<calendar color="user_id" date_start="create_date" date_stop="date_deadline" day_length="12" string="Cases">
<field name="name"/>
<field name="partner_id"/>
<field name="state"/>
<calendar color="user_id" date_start="create_date"
date_stop="date_deadline" day_length="12"
string="Cases">
<field name="name" />
<field name="partner_id" />
<field name="state" />
</calendar>
</field>
</record>
<!-- Case Tree View -->
<record id="crm_case_tree-view" model="ir.ui.view">
<field name="name">crm.case.tree</field>
@ -269,16 +297,29 @@
<field name="partner_id"/>
<field name="user_id"/>
<field name="state"/>
<button name="case_close" states="open,draft,pending" string="Close" type="object" icon="gtk-close"/>
<button name="case_open" states="draft,pending" string="Open" type="object" icon="gtk-go-forward"/>
<button name="case_cancel" states="draft,open,pending" string="Cancel" type="object" icon="gtk-cancel"/>
<button name="case_pending" states="draft,open" string="Pending" type="object" icon="gtk-media-pause"/>
<button name="case_escalate" states="open,draft,pending" string="Escalate" type="object" icon="gtk-go-up"/>
<button name="case_reset" states="done,cancel" string="Reset to Draft" type="object" icon="gtk-convert"/>
<button name="case_close"
states="open,draft,pending" string="Close"
type="object" icon="gtk-close" />
<button name="case_open" states="draft,pending"
string="Open" type="object" icon="gtk-go-forward" />
<button name="case_cancel"
states="draft,open,pending" string="Cancel"
type="object" icon="gtk-cancel" />
<button name="case_pending" states="draft,open"
string="Pending" type="object"
icon="gtk-media-pause" />
<button name="case_escalate"
states="open,draft,pending" string="Escalate"
type="object" icon="gtk-go-up" />
<button name="case_reset" states="done,cancel"
string="Reset to Draft" type="object"
icon="gtk-convert" />
</tree>
</field>
</record>
<!-- Case Form View -->
<record id="crm_case-view" model="ir.ui.view">
<field name="name">crm.case.form</field>
<field name="model">crm.case</field>
@ -294,25 +335,53 @@
<notebook colspan="4">
<page string="General">
<group col="8" colspan="4">
<field colspan="4" name="partner_id" on_change="onchange_partner_id(partner_id, email_from)" select="1"/>
<field colspan="3" name="partner_address_id" on_change="onchange_partner_address_id(partner_address_id, email_from)" select="2"/>
<newline/>
<field colspan="3" name="email_from" select="2"/>
<button name="remind_partner" states="open,pending" string="Send Reminder" type="object" icon="gtk-go-forward"/>
<field name="user_id" select="1"/>
<button name="remind_user" states="open,pending" string="Send Reminder" type="object" icon="gtk-go-forward"/>
<field colspan="4" name="partner_id"
on_change="onchange_partner_id(partner_id, email_from)"
select="1" />
<field colspan="3"
name="partner_address_id"
on_change="onchange_partner_address_id(partner_address_id, email_from)"
select="2" />
<newline />
<field colspan="3" name="email_from"
select="2" />
<button name="remind_partner"
states="open,pending"
string="Send Reminder" type="object"
icon="gtk-go-forward" />
<field name="user_id" select="1" />
<button name="remind_user"
states="open,pending"
string="Send Reminder" type="object"
icon="gtk-go-forward" />
</group>
<separator colspan="4" string="Description"/>
<field name="description" colspan="4" nolabel="1"/>
<separator colspan="4"/>
<group col="8" colspan="4">
<field name="state" select="1"/>
<button name="case_close" states="open,draft,pending" string="Close" type="object" icon="gtk-close"/>
<button name="case_open" states="draft,pending" string="Open" type="object" icon="gtk-go-forward"/>
<button name="case_cancel" states="draft,open,pending" string="Cancel" type="object" icon="gtk-cancel"/>
<button name="case_pending" states="draft,open" string="Pending" type="object" icon="gtk-media-pause"/>
<button name="case_escalate" states="open,draft,pending" string="Escalate" type="object" icon="gtk-go-up"/>
<button name="case_reset" states="done,cancel" string="Reset to Draft" type="object" icon="gtk-convert"/>
<button name="case_close"
states="open,draft,pending"
string="Close" type="object"
icon="gtk-close" />
<button name="case_open"
states="draft,pending" string="Open"
type="object" icon="gtk-go-forward" />
<button name="case_cancel"
states="draft,open,pending"
string="Cancel" type="object"
icon="gtk-cancel" />
<button name="case_pending"
states="draft,open" string="Pending"
type="object" icon="gtk-media-pause" />
<button name="case_escalate"
states="open,draft,pending"
string="Escalate" type="object"
icon="gtk-go-up" />
<button name="case_reset"
states="done,cancel"
string="Reset to Draft" type="object"
icon="gtk-convert" />
</group>
</page>
<page string="History" groups="base.group_extended">
@ -370,28 +439,37 @@
</field>
</record>
<!-- Case Search View -->
<record id="view_crm_case_filter" model="ir.ui.view">
<field name="name">crm.case.select</field>
<field name="model">crm.case</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Case">
<group col='6' colspan='4'>
<filter icon="terp-partner" string="My Cases"
domain="[('user_id','=',uid)]" separator="1"
default="1" help="Cases Related to Current User"
/>
<field name="state" select="1">
<filter icon="gtk-new" domain="[('state','in',('draft', 'open'))]" help="Current Cases"/>
<filter icon="gtk-yes" domain="[('state','=','open')]" help="Open Cases"/>
<filter icon="gtk-media-pause" domain="[('state','=','pending')]" help="Pending Cases"/>
</field>
<separator orientation="vertical"/>
<field name="name" select='1'/>
<field name="user_id" select="1" widget="selection"/>
</group>
<field name="section_id" default="context.get('section_id', False)" select="1" widget="selection" string="Section"/>
</search>
<group col='6' colspan='4'>
<filter icon="terp-partner" string="My Cases"
domain="[('user_id','=',uid)]" separator="1"
default="1" help="Cases Related to Current User" />
<field name="state" select="1">
<filter icon="gtk-new"
domain="[('state','in',('draft', 'open'))]"
help="Current Cases" />
<filter icon="gtk-yes"
domain="[('state','=','open')]" help="Open Cases" />
<filter icon="gtk-media-pause"
domain="[('state','=','pending')]"
help="Pending Cases" />
</field>
<separator orientation="vertical" />
<field name="name" select='1' />
<field name="user_id" select="1"
widget="selection" />
</group>
<field name="section_id"
default="context.get('section_id', False)" select="1"
widget="selection" string="Section" />
</search>
</field>
</record>
@ -402,13 +480,14 @@
<field name="view_id" ref="crm_case_tree-view"/>
<field name="search_view_id" ref="view_crm_case_filter"/>
</record>
<!-- <menuitem action="crm_case_categ0-act" id="menu_crm_case_categ0-act" parent="crm.next_id_52"/>-->
<record id="crm_case_categ0-act_open" model="ir.actions.act_window">
<field name="name">Open Cases</field>
<field name="res_model">crm.case</field>
<field name="view_type">form</field>
<field name="domain">[('state','&lt;&gt;','done'),('state','&lt;&gt;','cancel'),('state','&lt;&gt;','pending')]</field>
<field name="domain">
[('state','&lt;&gt;','done'),('state','&lt;&gt;','cancel'),('state','&lt;&gt;','pending')]
</field>
<field name="search_view_id" ref="view_crm_case_filter"/>
</record>
@ -427,6 +506,8 @@
<field eval="True" name="object"/>
</record>
<!--Case History Form View -->
<record id="crm_case_history-view" model="ir.ui.view">
<field name="name">crm.case.history.form</field>
<field name="model">crm.case.history</field>
@ -445,23 +526,32 @@
</form>
</field>
</record>
<!--Case History Search View -->
<record id="crm_case_history_search" model="ir.ui.view">
<field name="name">crm.case.history.select</field>
<field name="model">crm.case.history</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Histories">
<filter icon="terp-crm" string="My Histories" domain="[('user_id','=',uid)]" help="My Histories"/>
<filter icon="terp-crm" string="My Histories"
domain="[('user_id','=',uid)]"
help="My Histories" />
<separator orientation="vertical"/>
<group col="6" colspan="2">
<field name="date" select="1"/>
<field name="user_id" select="1" widget="selection"/>
<field name="section_id" default="context.get('section_id', False)" select="1" widget="selection" string="Section"/>
</group>
<field name="section_id"
default="context.get('section_id', False)"
select="1" widget="selection" string="Section" />
</group>
</search>
</field>
</record>
<!--Case History Action -->
<record id="crm_case_history-act" model="ir.actions.act_window">
<field name="name">Histories</field>
<field name="res_model">crm.case.history</field>
@ -470,7 +560,8 @@
<field name="view_id" ref="crm_case_history_tree-view"/>
<field name="search_view_id" ref="crm_case_history_search"/>
</record>
<!-- <menuitem action="crm_case_history-act" id="menu_crm_case_history-act_main" name="Cases Histories" parent="crm.next_id_52"/>-->
<!-- Segmentation line Tree View -->
<record id="crm_segmentation_line_tree-view" model="ir.ui.view">
<field name="name">crm.segmentation.line.tree</field>
@ -487,6 +578,8 @@
</field>
</record>
<!-- Segmentation line Form View -->
<record id="crm_segmentation_line-view" model="ir.ui.view">
<field name="name">crm.segmentation.line.form</field>
<field name="model">crm.segmentation.line</field>
@ -505,6 +598,8 @@
</field>
</record>
<!-- CRM Segmentation Form View -->
<record id="crm_segmentation-view" model="ir.ui.view">
<field name="name">crm.segmentation.form</field>
<field name="model">crm.segmentation</field>
@ -533,13 +628,23 @@
</notebook>
<field name="state"/>
<group col="3" colspan="2">
<button name="process_start" states="not running" string="Compute Segmentation" type="object" icon="gtk-execute"/>
<button name="process_stop" states="running" string="Stop Process" type="object" icon="gtk-cancel"/>
<button name="process_continue" states="running" string="Continue Process" type="object" icon="gtk-go-forward"/>
<button name="process_start"
states="not running"
string="Compute Segmentation" type="object"
icon="gtk-execute" />
<button name="process_stop" states="running"
string="Stop Process" type="object"
icon="gtk-cancel" />
<button name="process_continue" states="running"
string="Continue Process" type="object"
icon="gtk-go-forward" />
</group>
</form>
</field>
</record>
<!-- CRM Segmentation Tree View -->
<record id="crm_segmentation_tree-view" model="ir.ui.view">
<field name="name">crm.segmentation.tree</field>
<field name="model">crm.segmentation</field>
@ -566,18 +671,9 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem action="crm_segmentation_tree-act" id="menu_crm_segmentation-act" parent="crm.menu_crm_configuration"/>
<!---->
<!-- <act_window domain="[('section_id', '=', active_id),('state','&lt;&gt;','done'),('state','&lt;&gt;','cancel'),('state','&lt;&gt;','pending')]" id="act_crm_case_section_crm_case_opened" name="Open cases" res_model="crm.case" src_model="crm.case.section" view_mode="tree,form,calendar" view_type="form"/>-->
<!---->
<!-- <act_window domain="[('categ_id', '=', active_id),('state','&lt;&gt;','done'),('state','&lt;&gt;','cancel'),('state','&lt;&gt;','pending')]" id="act_crm_case_categ_crm_case_opened" name="Open cases" res_model="crm.case" src_model="crm.case.categ" view_mode="tree,form,calendar" view_type="form"/>-->
<!---->
<!-- <act_window domain="[('partner_id', '=', active_id),('state','&lt;&gt;','done'),('state','&lt;&gt;','cancel'),('state','&lt;&gt;','pending')]" id="act_res_partner_2_crm_case_opened" name="Open cases" res_model="crm.case" src_model="res.partner" view_mode="tree,form,calendar" view_type="form"/>-->
<!---->
<!-- <act_window domain="[('canal_id', '=', active_id),('state','&lt;&gt;','done'),('state','&lt;&gt;','cancel'),('state','&lt;&gt;','pending')]" id="act_res_partner_canal_2_crm_case_opened" name="Open cases" res_model="crm.case" src_model="res.partner.canal" view_mode="tree,form,calendar" view_type="form"/>-->
<!---->
<!-- <act_window domain="[('user_id', '=', active_id),('state','&lt;&gt;','done'),('state','&lt;&gt;','cancel'),('state','&lt;&gt;','pending')]" id="act_res_users_2_crm_case_opened" name="Open cases" res_model="crm.case" src_model="res.users" view_mode="tree,form,calendar" view_type="form"/>-->
<menuitem action="crm_segmentation_tree-act"
id="menu_crm_segmentation-act"
parent="crm.menu_crm_configuration" />
<record model="ir.ui.view" id="view_users_form_simple_modif_inherited1">
<field name="name">view.users.form.crm.modif.inherited1</field>
@ -586,7 +682,9 @@
<field name="type">form</field>
<field name="arch" type="xml">
<page string="Current Activity" position="inside">
<field name="context_section_id" completion="1" widget="selection" context="{'user_prefence':True}"/>
<field name="context_section_id" completion="1"
widget="selection"
context="{'user_prefence':True}" />
</page>
</field>
</record>
@ -604,6 +702,8 @@
</field>
</record>
<!-- Inherit View From Partner -->
<record id="view_partners_form_crm1" model="ir.ui.view">
<field name="name">view.res.partner.form.crm.inherited1</field>
<field name="model">res.partner</field>

View File

@ -42,3 +42,4 @@
"access_crm_phonecall2opportunity","crm.phonecall2opportunity","model_crm_phonecall2opportunity","crm.group_crm_user",1,1,1,1
"access_report_crm_helpdesk","report.crm.helpdesk","model_crm_helpdesk_report","crm.group_crm_user",1,1,1,1
"access_crm_send_mail","crm.send.mail","model_crm_send_mail","crm.group_crm_user",1,1,1,1
"access_crm_partner2opportunity","crm.partner2opportunity","model_crm_partner2opportunity","crm.group_crm_user",1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
42 access_crm_phonecall2opportunity crm.phonecall2opportunity model_crm_phonecall2opportunity crm.group_crm_user 1 1 1 1
43 access_report_crm_helpdesk report.crm.helpdesk model_crm_helpdesk_report crm.group_crm_user 1 1 1 1
44 access_crm_send_mail crm.send.mail model_crm_send_mail crm.group_crm_user 1 1 1 1
45 access_crm_partner2opportunity crm.partner2opportunity model_crm_partner2opportunity crm.group_crm_user 1 1 1 1

View File

@ -1,9 +1,9 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- Opportunity to Phonecall view -->
<record model="ir.ui.view" id="opportunity2phonecall_view">
<field name="name">crm.opportunity2phonecall.form</field>
<field name="model">crm.opportunity2phonecall</field>
@ -25,9 +25,9 @@
</form>
</field>
</record>
<!-- Opportunity to Phonecall action -->
<record model="ir.actions.act_window" id="opportunity2phonecall_act">
<field name="name">Schedule Call</field>
<field name="res_model">crm.opportunity2phonecall</field>
@ -35,8 +35,7 @@
<field name="view_mode">form</field>
<field name="view_id" ref="opportunity2phonecall_view"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
</data>
</openerp>
</openerp>

View File

@ -1,264 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from mx.DateTime import now
import wizard
import netsvc
import ir
import pooler
import time
from tools.translate import _
class opportunity2phonecall(wizard.interface):
case_form = """<?xml version="1.0"?>
<form string="Schedule Phone Call">
<separator string="Phone Call Description" colspan="4" />
<newline />
<field name='user_id' />
<field name='deadline' />
<newline />
<field name='note' colspan="4"/>
<newline />
<field name='section_id' />
<field name='category_id' domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.phonecall')]"/>
</form>"""
case_fields = {
'user_id' : {'string' : 'Assign To', 'type' : 'many2one', 'relation' : 'res.users'},
'deadline' : {'string' : 'Planned Date', 'type' : 'datetime' ,'required' :True},
'note' : {'string' : 'Goals', 'type' : 'text'},
'category_id' : {'string' : 'Category', 'type' : 'many2one', 'relation' : 'crm.case.categ', 'required' :True},
'section_id' : {'string' : 'Section', 'type' : 'many2one', 'relation' : 'crm.case.section'},
}
def _default_values(self, cr, uid, data, context):
case_obj = pooler.get_pool(cr.dbname).get('crm.opportunity')
categ_id = pooler.get_pool(cr.dbname).get('crm.case.categ').search(cr, uid, [('name','=','Outbound')])
case = case_obj.browse(cr, uid, data['id'])
if case.state != 'open':
raise wizard.except_wizard(_('Warning !'),
_('Opportunity should be in \'Open\' state before converting to Phone Call.'))
return {}
return {
'user_id' : case.user_id and case.user_id.id,
'category_id' : categ_id and categ_id[0] or case.categ_id and case.categ_id.id,
'section_id' : case.section_id and case.section_id.id or False,
'note' : case.description
}
def _doIt(self, cr, uid, data, context):
form = data['form']
pool = pooler.get_pool(cr.dbname)
mod_obj = pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'crm', 'view_crm_case_phonecalls_filter')
res = mod_obj.read(cr, uid, result, ['res_id'])
phonecall_case_obj = pool.get('crm.phonecall')
opportunity_case_obj = pool.get('crm.opportunity')
# Select the view
data_obj = pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_phone_tree_view')
id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_phone_form_view')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
if id3:
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
opportunites = opportunity_case_obj.browse(cr, uid, data['ids'])
for opportunity in opportunites:
new_case = phonecall_case_obj.create(cr, uid, {
'name' : opportunity.name,
'case_id' : opportunity.id,
'user_id' : form['user_id'],
'categ_id' : form['category_id'],
'description' : form['note'],
'date' : form['deadline'],
'section_id' : form['section_id'],
'partner_id': opportunity.partner_id and opportunity.partner_id.id or False,
'partner_address_id':opportunity.partner_address_id and opportunity.partner_address_id.id or False,
'description': data['form']['note'] or opportunity.description,
'partner_phone' : opportunity.phone or (opportunity.partner_address_id and opportunity.partner_address_id.phone or False),
'partner_mobile' : opportunity.partner_address_id and opportunity.partner_address_id.mobile or False,
'priority': opportunity.priority,
'opportunity_id':opportunity.id
}, context=context)
vals = {}
phonecall_case_obj.case_open(cr, uid, [new_case])
value = {
'name': _('Phone Call'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'crm.phonecall',
'res_id' : new_case,
'views': [(id3,'form'),(id2,'tree'),(False,'calendar'),(False,'graph')],
'type': 'ir.actions.act_window',
'search_view_id': res['res_id']
}
return value
states = {
'init': {
'actions': [_default_values],
'result': {'type': 'form', 'arch': case_form, 'fields': case_fields,
'state' : [('end', 'Cancel','gtk-cancel'),('order', 'Schedule Phone Call','gtk-go-forward')]}
},
'order': {
'actions': [],
'result': {'type': 'action', 'action': _doIt, 'state': 'end'}
}
}
opportunity2phonecall('crm.opportunity.reschedule_phone_call')
class opportunity2meeting(wizard.interface):
def _makeMeeting(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
opportunity_case_obj = pool.get('crm.opportunity')
data_obj = pool.get('ir.model.data')
result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_meetings_filter')
id = data_obj.read(cr, uid, result, ['res_id'])
id1 = data_obj._get_id(cr, uid, 'crm', 'crm_case_calendar_view_meet')
id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_meet')
id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_meet')
if id1:
id1 = data_obj.browse(cr, uid, id1, context=context).res_id
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
if id3:
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
opportunity = opportunity_case_obj.browse(cr, uid, data['id'], context=context)
partner_id = opportunity.partner_id and opportunity.partner_id.id or False
name = opportunity.name
email = opportunity.email_from
section_id = opportunity.section_id and opportunity.section_id.id or False
return {
'name': _('Meetings'),
'domain' : "[('user_id','=',%s)]"%(uid),
'context': {'default_partner_id': partner_id, 'default_section_id': section_id, 'default_email_from': email, 'default_state':'open', 'default_name':name},
'view_type': 'form',
'view_mode': 'calendar,form,tree',
'res_model': 'crm.meeting',
'view_id': False,
'views': [(id1,'calendar'),(id2,'form'),(id3,'tree')],
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
states = {
'init': {
'actions': [],
'result': {'type': 'action', 'action': _makeMeeting, 'state': 'order'}
},
'order': {
'actions': [],
'result': {'type': 'state', 'state': 'end'}
}
}
opportunity2meeting('crm.opportunity.meeting_set')
class partner_opportunity(wizard.interface):
case_form = """<?xml version="1.0"?>
<form string="Create Opportunity">
<field name="name"/>
<field name="partner_id" readonly="1"/>
<newline/>
<field name="planned_revenue"/>
<field name="probability"/>
</form>"""
case_fields = {
'name' : {'type' :'char', 'size' :64, 'string' :'Opportunity Name', 'required' :True},
'planned_revenue' : {'type' :'float', 'digits' :(16, 2), 'string' : 'Expected Revenue'},
'probability' : {'type' :'float', 'digits' :(16, 2), 'string' : 'Success Probability'},
'partner_id' : {'type' :'many2one', 'relation' :'res.partner', 'string' :'Partner'},
}
def _select_data(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
part_obj = pool.get('res.partner')
part = part_obj.read(cr, uid, data['id' ], ['name'])
return {'partner_id' : data['id'], 'name' : part['name'] }
def _make_opportunity(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
data_obj = pool.get('ir.model.data')
result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_opportunities_filter')
res = data_obj.read(cr, uid, result, ['res_id'])
id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_oppor')
id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_oppor')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
if id3:
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
part_obj = pool.get('res.partner')
address = part_obj.address_get(cr, uid, data['ids' ])
categ_obj = pool.get('crm.case.categ')
categ_ids = categ_obj.search(cr, uid, [('name','ilike','Part%')])
case_obj = pool.get('crm.opportunity')
opp_id = case_obj.create(cr, uid, {
'name' : data['form']['name'],
'planned_revenue' : data['form']['planned_revenue'],
'probability' : data['form']['probability'],
'partner_id' : data['form']['partner_id'],
'partner_address_id' : address['default'],
'categ_id' : categ_ids[0],
'state' :'draft',
})
value = {
'name' : _('Opportunity'),
'view_type' : 'form',
'view_mode' : 'form,tree',
'res_model' : 'crm.opportunity',
'res_id' : opp_id,
'view_id' : False,
'views' : [(id2, 'form'), (id3, 'tree'), (False, 'calendar'), (False, 'graph')],
'type' : 'ir.actions.act_window',
'search_view_id' : res['res_id']
}
return value
states = {
'init' : {
'actions' : [_select_data],
'result' : {'type' : 'form', 'arch' : case_form, 'fields' : case_fields,
'state' : [('end', 'Cancel', 'gtk-cancel'), ('confirm', 'Create Opportunity', 'gtk-go-forward')]}
},
'confirm' : {
'actions' : [],
'result' : {'type' : 'action', 'action' : _make_opportunity, 'state' : 'end'}
}
}
partner_opportunity('crm.case.opportunity.partner_opportunity')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -56,7 +56,7 @@ class crm_phonecall2phonecall(osv.osv_memory):
if record_id:
data_obj = self.pool.get('ir.model.data')
# Get Phonecall views
result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_phonecalls_filter')
res = data_obj.read(cr, uid, result, ['res_id'])
@ -71,16 +71,16 @@ class crm_phonecall2phonecall(osv.osv_memory):
for this in self.browse(cr, uid, ids, context=context):
values = {
'name': this.name,
'user_id': this.user_id and this.user_id.id,
'categ_id': phonecall.categ_id and phonecall.categ_id.id or False,
'section_id': phonecall.section_id and phonecall.section_id.id,
'description': phonecall.description or '',
'partner_id': phonecall.partner_id.id,
'partner_address_id': phonecall.partner_address_id.id,
'partner_mobile': phonecall.partner_mobile or False,
'priority': phonecall.priority,
'partner_phone': phonecall.partner_phone or False,
'name': this.name,
'user_id': this.user_id and this.user_id.id,
'categ_id': phonecall.categ_id and phonecall.categ_id.id or False,
'section_id': phonecall.section_id and phonecall.section_id.id,
'description': phonecall.description or '',
'partner_id': phonecall.partner_id.id,
'partner_address_id': phonecall.partner_address_id.id,
'partner_mobile': phonecall.partner_mobile or False,
'priority': phonecall.priority,
'partner_phone': phonecall.partner_phone or False,
'date': this.date
}
phonecall_id = phonecall_obj.create(cr, uid, values, context=context)
@ -103,7 +103,7 @@ class crm_phonecall2phonecall(osv.osv_memory):
'date': fields.datetime('Date'),
'section_id':fields.many2one('crm.case.section','Sales Team'),
}
def default_get(self, cr, uid, fields, context=None):
"""
This function gets default values
@ -117,8 +117,10 @@ class crm_phonecall2phonecall(osv.osv_memory):
"""
res = super(crm_phonecall2phonecall, self).default_get(cr, uid, fields, context=context)
record_id = context and context.get('active_id', False) or False
if record_id:
phonecall = self.pool.get('crm.phonecall').browse(cr, uid, record_id, context=context)
if 'name' in fields:
res.update({'name': phonecall.name})
if 'user_id' in fields: