Skip to Content
Menu
This question has been flagged

I am trying to categorize something using Roman numerals from I to VI and use those to group_by in kanban and tree view. However sorting happens in alphabetical order.


I tried use a selection field, but the classification depicted by the Roman numeral is computed and needs to be assigned in python.

I tried storing the index of the list item, tuples and a dictionary but I cannot get it to work. I am not sure which value needs to be stored in the database to represent the correct selection.


I would also be open to different approaches.


RATING = [
(1,'I'),
(2,'II'),
(3,'III'),
(4,'IV'),
(5,'V'),
(6,'VI')
]

rating = fields.Selection( # Selection field?
selection=RATING,
compute='_compute_rating',
store=True,
string="Klasse"
)


@api.multi
@api.depends('probability', 'impact')
def _compute_rating(self):
for risk in self:
risk.probclass = risk.probability + risk.impact

risk.risk_history = True

if risk.probability == 50:
risk.rating = 5
elif risk.probclass in (31,42,41):
risk.rating = 4
elif risk.probclass in (21,32,43):
risk.rating = 3
elif risk.probclass in (11,22,33,44):
risk.rating = 2
elif risk.probclass in (12,23,34):
risk.rating = 1
elif risk.probclass in (14,13,24):
risk.rating = 0



Avatar
Discard
Related Posts Replies Views Activity
2
Oct 24
7608
2
Apr 18
6609
3
Jan 20
7870
0
May 24
499
4
Dec 23
20435