[REV] project_issue: state is now a related, removing the function field.
bzr revid: tde@openerp.com-20120523092456-g6e25n32vllba1n3
This commit is contained in:
parent
23d8090ff9
commit
7c5fd29785
|
@ -159,31 +159,6 @@ class project_issue(crm.crm_case, osv.osv):
|
|||
if work.task_id:
|
||||
issues += issue_pool.search(cr, uid, [('task_id','=',work.task_id.id)])
|
||||
return issues
|
||||
|
||||
def _get_state(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
for issue in self.browse(cr, uid, ids, context=context):
|
||||
if issue.type_id:
|
||||
res[issue.id] = issue.type_id.state
|
||||
return res
|
||||
|
||||
def _get_stage(self, cr, uid, ids, context=None):
|
||||
issue_obj = self.pool.get('project.issue')
|
||||
result = {}
|
||||
for stage in self.browse(cr, uid, ids, context=context):
|
||||
if stage.state:
|
||||
issue_ids = issue_obj.search(cr, uid, [('state', '=', stage.state)], context=context)
|
||||
for issue in issue_obj.browse(cr, uid, issue_ids, context=context):
|
||||
result[issue.id] = True
|
||||
return result.keys()
|
||||
|
||||
def _save_state(self, cr, uid, issue_id, field_name, field_value, arg, context=None):
|
||||
stage_ids = self.pool.get('project.task.type').search(cr, uid, [('state', '=', field_value)], context=context)
|
||||
if stage_ids:
|
||||
self.write(cr, uid, [issue_id], {'type_id': stage_ids[0]}, context=context)
|
||||
else:
|
||||
cr.execute("""UPDATE project_issue SET state=%s WHERE id=%s""", (field_value, issue_id, ))
|
||||
return True
|
||||
|
||||
_columns = {
|
||||
'id': fields.integer('ID', readonly=True),
|
||||
|
@ -200,14 +175,13 @@ class project_issue(crm.crm_case, osv.osv):
|
|||
'partner_id': fields.many2one('res.partner', 'Partner', select=1),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'description': fields.text('Description'),
|
||||
'state': fields.function(_get_state, fnct_inv=_save_state, type='selection', selection=_ISSUE_STATE, string="State", readonly=True,
|
||||
store = {
|
||||
'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['type_id'], 10),
|
||||
'project.task.type': (_get_stage, ['state'], 10)
|
||||
}, help='The state is set to \'Draft\', when a case is created.\
|
||||
\nIf the case is in progress the state is set to \'Open\'.\
|
||||
\nWhen the case is over, the state is set to \'Done\'.\
|
||||
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
|
||||
'state': fields.related('type_id', 'state', type="selection", store=True,
|
||||
selection=_ISSUE_STATE, string="State", readonly=True,
|
||||
help='The state is set to \'Draft\', when a case is created.\
|
||||
If the case is in progress the state is set to \'Open\'.\
|
||||
When the case is over, the state is set to \'Done\'.\
|
||||
If the case needs to be reviewed then the state is \
|
||||
set to \'Pending\'.'),
|
||||
'email_from': fields.char('Email', size=128, help="These people will receive email.", select=1),
|
||||
'email_cc': fields.char('Watchers Emails', size=256, help="These email addresses will be added to the CC field of all inbound and outbound emails for this record before being sent. Separate multiple email addresses with a comma"),
|
||||
'date_open': fields.datetime('Opened', readonly=True,select=True),
|
||||
|
|
Loading…
Reference in New Issue