[IMP] Next activities mechanism improved
This commit is contained in:
+26
-20
@@ -200,10 +200,11 @@ class crm_lead(format_address, osv.osv):
|
||||
'phone': fields.char("Phone", size=64),
|
||||
'date_deadline': fields.date('Expected Closing', help="Estimate of the date on which the opportunity will be won."),
|
||||
# CRM Actions
|
||||
'last_activity_id': fields.many2one("crm.activity", "Last Activity", select=True),
|
||||
'next_activity_id': fields.many2one("crm.activity", "Next Activity", select=True),
|
||||
'next_activity_1': fields.related("next_activity_id", "activity_1_id", "name", type="char", string="Next Activity 1"),
|
||||
'next_activity_2': fields.related("next_activity_id", "activity_2_id", "name", type="char", string="Next Activity 2"),
|
||||
'next_activity_3': fields.related("next_activity_id", "activity_3_id", "name", type="char", string="Next Activity 3"),
|
||||
'next_activity_1': fields.related("last_activity_id", "activity_1_id", "name", type="char", string="Next Activity 1"),
|
||||
'next_activity_2': fields.related("last_activity_id", "activity_2_id", "name", type="char", string="Next Activity 2"),
|
||||
'next_activity_3': fields.related("last_activity_id", "activity_3_id", "name", type="char", string="Next Activity 3"),
|
||||
'date_action': fields.date('Next Activity Date', select=True),
|
||||
'title_action': fields.char('Next Activity Summary'),
|
||||
|
||||
@@ -358,13 +359,29 @@ class crm_lead(format_address, osv.osv):
|
||||
case_mark_won = action_set_won
|
||||
|
||||
def log_next_activity_1(self, cr, uid, ids, context=None):
|
||||
return self.log_next_activity_done(cr, uid, ids, next_activity_name='activity_1_id', context=context)
|
||||
return self.set_next_activity(cr, uid, ids, next_activity_name='activity_1_id', context=context)
|
||||
|
||||
def log_next_activity_2(self, cr, uid, ids, context=None):
|
||||
return self.log_next_activity_done(cr, uid, ids, next_activity_name='activity_2_id', context=context)
|
||||
return self.set_next_activity(cr, uid, ids, next_activity_name='activity_2_id', context=context)
|
||||
|
||||
def log_next_activity_3(self, cr, uid, ids, context=None):
|
||||
return self.log_next_activity_done(cr, uid, ids, next_activity_name='activity_3_id', context=context)
|
||||
return self.set_next_activity(cr, uid, ids, next_activity_name='activity_3_id', context=context)
|
||||
|
||||
def set_next_activity(self, cr, uid, ids, next_activity_name, context=None):
|
||||
for lead in self.browse(cr, uid, ids, context=context):
|
||||
if not lead.last_activity_id:
|
||||
continue
|
||||
next_activity = next_activity_name and getattr(lead.last_activity_id, next_activity_name, False) or False
|
||||
if next_activity:
|
||||
date_action = False
|
||||
if next_activity.days:
|
||||
date_action = (datetime.now() + timedelta(days=next_activity.days)).strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
lead.write({
|
||||
'next_activity_id': next_activity.id,
|
||||
'date_action': date_action,
|
||||
'title_action': next_activity.description,
|
||||
})
|
||||
return True
|
||||
|
||||
def log_next_activity_done(self, cr, uid, ids, context=None, next_activity_name=False):
|
||||
to_clear_ids = []
|
||||
@@ -377,20 +394,8 @@ class crm_lead(format_address, osv.osv):
|
||||
%endif"""
|
||||
body_html = self.pool['mail.template'].render_template(cr, uid, body_html, 'crm.lead', lead.id, context=context)
|
||||
msg_id = lead.message_post(body_html, subtype_id=lead.next_activity_id.subtype_id.id)
|
||||
# update subtype after posting NOT SURE
|
||||
|
||||
next_activity = next_activity_name and getattr(lead.next_activity_id, next_activity_name, False) or False
|
||||
if next_activity:
|
||||
date_action = False
|
||||
if next_activity.days:
|
||||
date_action = (datetime.now() + timedelta(days=next_activity.days)).strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
lead.write({
|
||||
'next_activity_id': next_activity.id,
|
||||
'date_action': date_action,
|
||||
'title_action': next_activity.description,
|
||||
})
|
||||
else:
|
||||
to_clear_ids.append(lead.id)
|
||||
to_clear_ids.append(lead.id)
|
||||
self.write(cr, uid, [lead.id], {'last_activity_id': lead.next_activity_id.id}, context=context)
|
||||
|
||||
if to_clear_ids:
|
||||
self.cancel_next_activity(cr, uid, to_clear_ids, context=context)
|
||||
@@ -422,6 +427,7 @@ class crm_lead(format_address, osv.osv):
|
||||
'next_activity_3': activity.activity_3_id and activity.activity_3_id.name or False,
|
||||
'title_action': activity.description,
|
||||
'date_action': date_action,
|
||||
'last_activity_id': False,
|
||||
}}
|
||||
|
||||
def _merge_get_result_type(self, cr, uid, opps, context=None):
|
||||
|
||||
@@ -125,12 +125,11 @@
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box"/>
|
||||
<div class="label label-danger pull-right" attrs="{'invisible': ['|', ('probability', '>', 0), ('active', '=', True)]}">Lost</div>
|
||||
<div class="label label-success pull-right" attrs="{'invisible': [('probability', '<', 100)]}">Won</div>
|
||||
<div class="oe_title">
|
||||
<label for="name" class="oe_edit_only" string="Lead"/>
|
||||
<h1><field name="name" placeholder="Describe the lead..."/></h1>
|
||||
|
||||
<span class="label label-danger" attrs="{'invisible': ['|', ('probability', '>', 0), ('active', '=', True)]}">Lost</span>
|
||||
<span class="label label-success" attrs="{'invisible': [('probability', '<', 100)]}">Won</span>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
@@ -477,17 +476,12 @@
|
||||
<group>
|
||||
<label for="next_activity_id"/>
|
||||
<div>
|
||||
<field name="last_activity_id" invisible="1"/>
|
||||
<field name="next_activity_id"
|
||||
class="oe_inline" options="{'no_create': True, 'no_open': True}"
|
||||
domain="['|',('team_id','=',False),('team_id','=',team_id)]"
|
||||
on_change="onchange_next_activity_id(next_activity_id)"/>
|
||||
<span class="oe_form_field oe_read_only oe_inline"
|
||||
attrs="{'invisible': ['|', ('next_activity_id', '=', False), ('date_action', '=', False)]}"> on </span>
|
||||
<field name="date_action" nolabel="1" attrs="{'invisible': [('next_activity_id', '=', False)]}"/>
|
||||
<field name="title_action" nolabel="1" placeholder="e.g. Discuss proposal"
|
||||
attrs="{'invisible': [('next_activity_id', '=', False)]}"/>
|
||||
<div attrs="{'invisible': [('next_activity_id', '=', False)]}">
|
||||
<button name="log_next_activity_done" string="Done" type="object" class="btn-link"/>
|
||||
<span attrs="{'invisible': ['|', ('last_activity_id','=',False), ('next_activity_id', '<>', False)]}">
|
||||
<button name="log_next_activity_1" type="object" class="btn-link" attrs="{'invisible': [('next_activity_1','=',False)]}">
|
||||
<field name="next_activity_1" class="oe_inline" readonly="1"/>
|
||||
</button>
|
||||
@@ -497,6 +491,14 @@
|
||||
<button name="log_next_activity_3" type="object" class="btn-link" attrs="{'invisible': [('next_activity_3','=',False)]}">
|
||||
<field name="next_activity_3" class="oe_inline" readonly="1"/>
|
||||
</button>
|
||||
</span>
|
||||
<span class="oe_form_field oe_read_only oe_inline"
|
||||
attrs="{'invisible': ['|', ('next_activity_id', '=', False), ('date_action', '=', False)]}"> on </span>
|
||||
<field name="date_action" nolabel="1" attrs="{'invisible': [('next_activity_id', '=', False)]}" placeholder="Choose a date..."/>
|
||||
<field name="title_action" nolabel="1" placeholder="e.g. Discuss proposal"
|
||||
attrs="{'invisible': [('next_activity_id', '=', False)]}"/>
|
||||
<div attrs="{'invisible': [('next_activity_id', '=', False)]}">
|
||||
<button name="log_next_activity_done" string="Done" type="object" class="btn-link"/>
|
||||
<button name="cancel_next_activity" string="Cancel" type="object" class="btn-link"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
<button name="action_quotation_send" string="Send by Email" type="object" groups="base.group_user"
|
||||
class="oe_highlight"
|
||||
attrs="{'invisible': ['|',('quote_viewed','=',False),('state','!=', 'draft')]}"/>
|
||||
<button name="open_quotation" type="object"
|
||||
class="oe_highlight o_open_quotation" string="View Online Quotation"
|
||||
attrs="{'invisible': [('template_id', '=', False)]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//header/button[@name='print_quotation'][1]" position="replace">
|
||||
<button name="print_quotation" string="Print" type="object" states="draft" groups="base.group_user"/>
|
||||
@@ -37,9 +40,6 @@
|
||||
<label for="template_id"/>
|
||||
<div>
|
||||
<field name="template_id" context="{'company_id': company_id}" on_change="onchange_template_id(template_id, partner_id, fiscal_position_id, pricelist_id)"/>
|
||||
<button name="open_quotation" type="object"
|
||||
class="oe_link o_open_quotation" string="View Online Quotation"
|
||||
attrs="{'invisible': [('template_id', '=', False)]}"/>
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='client_order_ref']" position="after">
|
||||
|
||||
Reference in New Issue
Block a user