下面是一个根据条件禁止在任务阶段之间拖拽的例子,任务有几个阶段:
[('draft','Draft'), ('confirm','Confirmed'), ('approved','Approved'),('rejected','Rejected')]
@api.multi
def write(self, values):
if 'state' in values:
previous_state = self.state
new_state = values.get('state')
if (new_state in ['approved','rejected']) and (not self.env.user.has_group('your_module.your_group_xml_id')):
raise ValidationError(_("Only Managers can perform that move !"))
#elif some other_conditions:
#some other logics
return super(YOUR CLASS, self).write(values)