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?
CodePudding user response:
def _compute_sum_50(self):
x = []
for record in self:
x.append(record.overtime_50)
print(x)
You have to use the append function-