[FIX] code cleanup (addon project_issue)
improves the code of _issue_count (both in partner and in project). This makes the issue_ids field in res_partner useless, so issue_ids is also removed. bzr revid: ged@openerp.com-20140507132949-tbtd4pl33zwhzgwd
This commit is contained in:
parent
626915508d
commit
e83709bdcc
|
@ -490,10 +490,11 @@ class project(osv.Model):
|
||||||
return [('project.task', "Tasks"), ("project.issue", "Issues")]
|
return [('project.task', "Tasks"), ("project.issue", "Issues")]
|
||||||
|
|
||||||
def _issue_count(self, cr, uid, ids, field_name, arg, context=None):
|
def _issue_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||||
res={}
|
Issue = self.pool['project.issue']
|
||||||
for issues in self.browse(cr, uid, ids, context):
|
return {
|
||||||
res[issues.id] = len(issues.issue_ids)
|
project_id: Issue.search_count(cr,uid, [('project_id', '=', project_id), ('stage_id.fold', '=', False)], context=context)
|
||||||
return res
|
for project_id in ids
|
||||||
|
}
|
||||||
_columns = {
|
_columns = {
|
||||||
'project_escalation_id': fields.many2one('project.project', 'Project Escalation',
|
'project_escalation_id': fields.many2one('project.project', 'Project Escalation',
|
||||||
help='If any issue is escalated from the current Project, it will be listed under the project selected here.',
|
help='If any issue is escalated from the current Project, it will be listed under the project selected here.',
|
||||||
|
@ -570,18 +571,15 @@ class project_project(osv.Model):
|
||||||
|
|
||||||
class res_partner(osv.osv):
|
class res_partner(osv.osv):
|
||||||
def _issue_count(self, cr, uid, ids, field_name, arg, context=None):
|
def _issue_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||||
res = dict(map(lambda x: (x,0), ids))
|
Issue = self.pool['project.issue']
|
||||||
try:
|
return {
|
||||||
for partner in self.browse(cr, uid, ids, context=context):
|
partner_id: Issue.search_count(cr,uid, [('partner_id', '=', partner_id)])
|
||||||
res[partner.id] = len(partner.issue_ids)
|
for partner_id in ids
|
||||||
except:
|
}
|
||||||
pass
|
|
||||||
return res
|
|
||||||
|
|
||||||
""" Inherits partner and adds Issue information in the partner form """
|
""" Inherits partner and adds Issue information in the partner form """
|
||||||
_inherit = 'res.partner'
|
_inherit = 'res.partner'
|
||||||
_columns = {
|
_columns = {
|
||||||
'issue_ids': fields.one2many('project.issue', 'partner_id', 'Issues'),
|
|
||||||
'issue_count': fields.function(_issue_count, string='# Issues', type='integer'),
|
'issue_count': fields.function(_issue_count, string='# Issues', type='integer'),
|
||||||
}
|
}
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
Loading…
Reference in New Issue