state = fields.Selection(
[
('screening', 'Screening'),
('forward_to_baseline', 'Baseline'),
('forward_to_screening_failure', 'Screening Failure'),
('intervention_arm', 'Intervention Arm'),
('control_arm', 'Control Arm')
], 'Status', readonly=True, sort=False)
@classmethod
def __setup__(cls):
super().__setup__()
cls._transitions |= set((
('screening', 'forward_to_baseline'),
('screening', 'forward_to_screening_failure'),
('forward_to_baseline', 'control_arm'),
('forward_to_baseline', 'intervention_arm'),
))
cls._buttons.update({
'forward_to_baseline': {
'invisible': ~Eval('state').in_(['screening']),
'readonly': (
(Eval('have_you_had_t1dm_year_more') != 'yes') |
(Eval('your_age_between') != 'yes'
) | (Eval('visit_your_paediatric_healthcare') != 'yes'
) | (Eval('are_you_resident_delhi_ncr') != 'yes') |
(Eval('moveout_delhi_ncr_next') != 'no'
) | (Eval('pregnant_or_you_toget_pregnantin_next') != 'no'
)), 'depends': ['state'],
},
'forward_to_screening_failure': {
'invisible': ~Eval('state').in_(['screening']),
'readonly': (
(Eval('have_you_had_t1dm_year_more') != 'no') &
(Eval('your_age_between') != 'no'
) & (Eval('visit_your_paediatric_healthcare') != 'no'
) & (Eval('are_you_resident_delhi_ncr') != 'no') &
(Eval('moveout_delhi_ncr_next') != 'yes') & (Eval(
'pregnant_or_you_toget_pregnantin_next') != 'yes')),
'depends': ['state'],
},
'randomization': {
'invisible': ~Eval('state').in_(['forward_to_baseline']),
'depends': ['state'],
},
})
@staticmethod
def default_state():
return 'screening'
@classmethod
@ModelView.button
@Workflow.transition((random.choice(['control_arm', 'intervention_arm'])))
def randomization(cls, records):
pass
In above code i have done the code to randomly send records to âcontrol_armâ and âintervention_armâ using random.choice(), but on executing the code record is going in âcontrol_armâ only not in âintervention_armâ.
How can I resolve this issue. Any reference to this code will be highly appreciable!!!