看板中有个分组,我要实现的效果是拖动任务到一个分组,这个分组的颜色都为一个色,kanban默认的颜色是鼠标点击改变,我要实现的效果是拖动到某个分组,看板背景色自动设置为这个分组的颜色。并且把拖动经过的分组追加到一个字符串,这个字符串显示在看板上,可以看见那些是已经拖动过的。
上代码
<li><span class="loan_record_span loan_record_key">
完成进度:</span>
<field name="probability"/>
</li>
color = fields.Integer('Color Index',compute='_compute_color')
priority = fields.Selection([('0', 'Low'), ('1', 'Normal'), ('2', 'High')], 'Priority', default='1')
kanban_state = fields.Selection(
[('normal', '进行中'), ('blocked', '阻塞'), ('done', '已完成')], 'Kanban State',
default='normal')
stage_id = fields.Many2one('loan.record.stage', u'阶段', group_expand='_read_group_stage_ids', default=1,track_visibility='onchange')
@api.onchange('stage_id')
def _compute_color(self):
for x in self:
x.color = x.stage_id.id
@api.multi
def write(self,vals):
probability_o = self.probability
if vals.has_key('stage_id'):
probability = self.stage_id.name
if probability_o==False:
vals['probability']=str(probability)
else:
vals['probability'] = str(probability_o) + '->' + str(probability)
if vals and 'kanban_state' not in vals and 'stage_id' in vals:
vals['kanban_state'] = 'normal'
return super(LoanRecord, self).write(vals)
网友评论