[IMP] crm_stage: added a 'fold' boolean value, stating whether this stage should be folded or not (for example in kanban view, or in statusbar). crm_lead: updated group_by_full, to fetch stages related to the section_id in context, if any. Also added in context when searching for a particular sales team.
bzr revid: tde@openerp.com-20120522141127-3b3owsdu880c1keq
This commit is contained in:
parent
1fcb9ca114
commit
7364f5a356
|
@ -77,12 +77,14 @@ class crm_case_stage(osv.osv):
|
|||
help="Link between stages and sales teams. When set, this limitate the current stage to the selected sales teams."),
|
||||
'state': fields.selection(AVAILABLE_STATES, 'State', required=True, help="The related state for the stage. The state of your document will automatically change regarding the selected stage. Example, a stage is related to the state 'Close', when your document reach this stage, it will be automatically closed."),
|
||||
'case_default': fields.boolean('Common to All Teams', help="If you check this field, this stage will be proposed by default on each sales team. It will not assign this stage to existing teams."),
|
||||
'fold': fields.boolean('Hide in views if empty', help="This stage is not visible, for example in status bar or kanban view, when there are no records in that stage to display."),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'sequence': lambda *args: 1,
|
||||
'probability': lambda *args: 0.0,
|
||||
'state': 'draft',
|
||||
'fold': False,
|
||||
}
|
||||
|
||||
class crm_case_section(osv.osv):
|
||||
|
|
|
@ -41,6 +41,16 @@ class crm_lead(crm_case, osv.osv):
|
|||
_order = "priority,date_action,id desc"
|
||||
_inherit = ['ir.needaction_mixin', 'mail.thread','res.partner']
|
||||
|
||||
def _resolve_section_id_from_context(self, cr, uid, context=None):
|
||||
""" Returns ID of section based on the value of 'section_id'
|
||||
context key, or None if it cannot be resolved to a single project
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
if type(context.get('default_project_id')) in (int, long):
|
||||
return context.get('default_project_id')
|
||||
return None
|
||||
|
||||
def _read_group_stage_ids(self, cr, uid, ids, domain, read_group_order=None, access_rights_uid=None, context=None):
|
||||
access_rights_uid = access_rights_uid or uid
|
||||
stage_obj = self.pool.get('crm.case.stage')
|
||||
|
@ -48,11 +58,19 @@ class crm_lead(crm_case, osv.osv):
|
|||
if read_group_order == 'stage_id desc':
|
||||
# lame hack to allow reverting search, should just work in the trivial case
|
||||
order = "%s desc" % order
|
||||
stage_ids = stage_obj._search(cr, uid, ['|', ('id','in',ids),('case_default','=',1)], order=order,
|
||||
access_rights_uid=access_rights_uid, context=context)
|
||||
# retrieve section_id from the context
|
||||
section_id = self._resolve_section_id_from_context(cr, uid, context=context)
|
||||
# write domain
|
||||
search_domain = []
|
||||
if section_id:
|
||||
search_domain += ['|', '&', ('section_ids', '=', section_id), ('fold', '=', True)]
|
||||
search_domain += ['|', ('id', 'in', ids), '&', ('case_default', '=', 1), ('fold', '=', False)]
|
||||
# perform search
|
||||
stage_ids = stage_obj._search(cr, uid, search_domain, order=order, access_rights_uid=access_rights_uid, context=context)
|
||||
result = stage_obj.name_get(cr, access_rights_uid, stage_ids, context=context)
|
||||
# restore order of the search
|
||||
result.sort(lambda x,y: cmp(stage_ids.index(x[0]), stage_ids.index(y[0])))
|
||||
print result
|
||||
return result
|
||||
|
||||
_group_by_full = {
|
||||
|
|
|
@ -584,7 +584,7 @@
|
|||
help="Unassigned Opportunities" />
|
||||
</field>
|
||||
<field name="section_id"
|
||||
context="{'invisible_section': False}"
|
||||
context="{'invisible_section': False, 'section_id': self}"
|
||||
widget="selection">
|
||||
<filter icon="terp-personal+"
|
||||
domain="['|', ('section_id.user_id','=',uid), ('section_id.member_ids', 'in', [uid])]"
|
||||
|
|
Loading…
Reference in New Issue