[FIX][CLEAN] crm: next actions form view + code

The display of next actions has been slightly cleaned. Indeed some links were
displayed only in edit mode, and the order was strange.

Also moved code beloging to crm.team into the right file instead of having
2 overrides in the same module. Also cleaned its code.
This commit is contained in:
Thibault Delavallée
2015-09-29 12:01:22 +02:00
parent 8475ee13d6
commit b626bdc68d
3 changed files with 52 additions and 51 deletions
-40
View File
@@ -1235,43 +1235,3 @@ class crm_lost_reason(osv.Model):
_defaults = {
'active': True,
}
class crm_team(osv.Model):
_inherit = "crm.team"
def action_your_pipeline(self, cr, uid, context={}):
imd = self.pool.get('ir.actions.act_window')
imd2 = self.pool.get('ir.model.data')
action = imd.for_xml_id(cr, uid, 'crm', "crm_lead_opportunities_tree_view", context=context)
view_form = imd2.xmlid_lookup(cr, uid, 'crm.crm_case_form_view_oppor')[2]
view_tree = imd2.xmlid_lookup(cr, uid, 'crm.crm_case_tree_view_oppor')[2]
view_kanban = imd2.xmlid_lookup(cr, uid, 'crm.crm_case_kanban_view_leads')[2]
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
team_id = user.sale_team_id.id
if not team_id:
team_id = self.search(cr, uid, [], context=context, limit=1)
team_id = team_id and team_id[0]
action['help'] = """
<p class='oe_view_nocontent_create'>Click here to add new opportunities</p><p>
Looks like you are not a member of a sales team. You should add yourself
as a member of one of the sales team.
</p>"""
if team_id:
action['help'] += "<p>As you don't belong to any sales team, Odoo opens the first one by default.</p>"
newcontext = eval(action['context'], {'uid': uid})
if team_id:
newcontext.update({
'default_team_id': team_id,
'search_default_team_id': team_id
})
result = {
'name': action['name'],
'help': action['help'],
'type': action['type'],
'views': [[view_kanban, 'kanban'], [view_tree, 'tree'], [view_form, 'form'], [False, 'graph'], [False, 'calendar'], [False, 'pivot']],
'target': action['target'],
'context': newcontext,
'res_model': action['res_model'],
}
return result
+10 -11
View File
@@ -471,39 +471,38 @@
</group>
<group>
<field name="last_activity_id" invisible="1"/>
<label for="next_activity_id"/>
<div>
<field name="last_activity_id" invisible="1"/>
<div class="o_row">
<field name="next_activity_id"
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 attrs="{'invisible': ['|', ('last_activity_id','=',False), ('next_activity_id', '&lt;&gt;', False)]}" class="oe_edit_only">
<span class="oe_form_field"
attrs="{'invisible': ['|', ('next_activity_id', '=', False), ('date_action', '=', False)]}">&#160;on&#160;</span>
<field name="date_action" attrs="{'invisible': [('next_activity_id', '=', False)]}" placeholder="Choose a date..."/>
<div 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" readonly="1"/>
</button>
<span attrs="{'invisible': [('next_activity_2','=',False)]}">|</span>
<button name="log_next_activity_2" type="object" class="btn-link" attrs="{'invisible': [('next_activity_2','=',False)]}">
<field name="next_activity_2" readonly="1"/>
</button>
<span attrs="{'invisible': [('next_activity_3','=',False)]}">|</span>
<button name="log_next_activity_3" type="object" class="btn-link" attrs="{'invisible': [('next_activity_3','=',False)]}">
<field name="next_activity_3" readonly="1"/>
</button>
</span>
<span class="oe_read_only oe_form_field"
attrs="{'invisible': ['|', ('next_activity_id', '=', False), ('date_action', '=', False)]}">&#160;on&#160;</span>
<field name="date_action" attrs="{'invisible': [('next_activity_id', '=', False)]}" placeholder="Choose a date..."/>
<span class="oe_read_only oe_form_field"
attrs="{'invisible': ['|', ('next_activity_id', '=', False), ('title_action', '=', False)]}">:&#160;</span>
</div>
</div>
<div class="o_row">
<field name="title_action" placeholder="e.g. Discuss proposal"
attrs="{'invisible': [('next_activity_id', '=', False)]}"/>
<span class="oe_edit_only" 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"/>
</span>
</div>
</div>
</div>
<field name="date_deadline"/>
+42
View File
@@ -119,3 +119,45 @@ class crm_team(osv.Model):
res = super(crm_team, self).unlink(cr, uid, ids, context=context)
mail_alias.unlink(cr, uid, alias_ids, context=context)
return res
def action_your_pipeline(self, cr, uid, context=None):
IrModelData = self.pool['ir.model.data']
action = IrModelData.xmlid_to_object(cr, uid, 'crm.crm_lead_opportunities_tree_view').read(['name', 'help', 'res_model', 'target', 'context', 'type'])
if not action:
action = {}
else:
action = action[0]
user_team_id = self.pool['res.users'].browse(cr, uid, uid, context=context).sale_team_id.id
if not user_team_id:
user_team_id = self.search(cr, uid, [], context=context, limit=1)
user_team_id = user_team_id and user_team_id[0] or False
action['help'] = """<p class='oe_view_nocontent_create'>Click here to add new opportunities</p><p>
Looks like you are not a member of a sales team. You should add yourself
as a member of one of the sales team.
</p>"""
if user_team_id:
action['help'] += "<p>As you don't belong to any sales team, Odoo opens the first one by default.</p>"
action_context = eval(action['context'], {'uid': uid})
if user_team_id:
action_context.update({
'default_team_id': user_team_id,
'search_default_team_id': user_team_id
})
tree_view_id = IrModelData.xmlid_to_res_id(cr, uid, 'crm.crm_case_tree_view_oppor')
form_view_id = IrModelData.xmlid_to_res_id(cr, uid, 'crm.crm_case_form_view_oppor')
kanb_view_id = IrModelData.xmlid_to_res_id(cr, uid, 'crm.crm_case_kanban_view_leads')
action.update({
'views': [
[kanb_view_id, 'kanban'],
[tree_view_id, 'tree'],
[form_view_id, 'form'],
[False, 'graph'],
[False, 'calendar'],
[False, 'pivot']
],
'context': action_context,
})
return action