콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
10857 화면

Hello, Odoo community! 

I have a text field that fills with a list of a product like below, how can I write each product in a separate line.

food = ['Gouda Cheese', 'Pizza Italiana']

I want :

food = ['Gouda Cheese',

              'Pizza Italiana']

my python code:

food = fields.Text(string = 'food')

@api.onchange('date')
def _onchange_food(self):
d= datetime.datetime.strptime(self.date , "%Y-%m-%d").strftime('%A')
self.food =self.env['lunch.menu'].search([('day', '=', d)]).mapped('product.name')


아바타
취소

Could you please explain more?

베스트 답변

You can go with Join like this

self.food ='\n '.join(self.env['lunch.menu'].search([('day', '=', d)]).mapped('product.name'))



아바타
취소
작성자

thanks a lot.

베스트 답변

I normally use the Html field, but you can use the html widget for the field in the view. I use this method for logging while importing data in custom wizards. you can use ordered list or whatever you want and it shows the data line by line. 

I then normally just do

def display_log(self, log_list):
  tmp_text = ''
  for item in list:
     tmp_text + = '<p>{}</p>'.format(item)
  self.food = tmp_texp

아바타
취소
관련 게시물 답글 화면 활동
0
3월 15
3588
0
1월 25
1
0
2월 25
1316
0
1월 25
1138
1
12월 24
1466