I have a field:
overtime_50 = fields.Char(readonly=True, default='00:00')
I make a list of this field and i get so many lists:
def _compute_sum_50(self):
for record in self:
x = [record.overtime_50]
print(x)
Console print:
['00:00']
['00:00']
['00:00']
['00:00']
['00:00']
['00:00']
['00:00']
['00:00']
['00:00']
['00:00']
['00:00']
I need to get sometinh like this:
['00:00','00:00','00:00','00:00','00:00','00:00','00:00','00:00','00:00']
I try many ways, but i only get results like this:
def _compute_sum_50(self):
for record in self:
x = [record.overtime_50]
print(list(chain.from_iterable(x)))
Console print:
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
What can i do wrong?
def _compute_sum_50(self):
x = [record.overtime_50for record in self] # Use List Comprehension
print(x)
Edit: better solution provided by Dipen Shah