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

when I try to include code into a question in his forum I lose all carriage returns so the code block apprears to be all in one line.

 

How to paste code into forum without losing return characters?

아바타
취소
작성자

I am sorry, it seems I was not clear enough. the block quote used to work well but not anymore. please see my reply below.

I have the same behaviour, latest Firefox and Windows 10 here. It is really annoying and impacts posts quality.

베스트 답변

Hesham, when creating your post, notice the bar above beginning with "B". Hover over each of the choices in the bar to see the explanation of each. The fifth one from the left is "Block Quote". Position your cursor anywhere in this reply box where you want your code to go and press the "Block Quote" button. As a result you'll see an indented vertical bar on the left, with the cursor positioned just to the right of that bar and in the middle of its vertical height. Then paste your code. That should do it.

def translate_state_code_to_database_id(state_code):
    state_dict = {'AL': '1',
                  'AK': '2',
                  'AZ': '3',
                  'AR': '4',
                  'CA': '5',
                  'CO': '6',
                  'CT': '7',
                  'DE': '8',
                  'DC': '9',
                  'FL': '10',
                  'GA': '11',
                  'HI': '12',
                  'ID': '13',
                  'IL': '14',
                  'IN': '15',
                  'IA': '16',
                  'KS': '17',
                  'KY': '18',
                  'LA': '19',
                  'ME': '20',
                  'MT': '21',
                  'NE': '22',
                  'NV': '23',
                  'NH': '24',
                  'NJ': '25',
                  'NM': '26',
                  'NY': '27',
                  'NC': '28',
                  'ND': '29',
                  'OH': '30',
                  'OK': '31',
                  'OR': '32',
                  'MD': '33',
                  'MA': '34',
                  'MI': '35',
                  'MN': '36',
                  'MS': '37',
                  'MO': '38',
                  'PA': '39',
                  'RI': '40',
                  'SC': '41',
                  'SD': '42',
                  'TN': '43',
                  'TX': '44',
                  'UT': '45',
                  'VT': '46',
                  'VA': '47',
                  'WA': '48',
                  'WV': '49',
                  'WI': '50',
                  'WY': '51'}

    return 'base.state_us_{}'.format(state_dict.get(state_code))

아바타
취소
작성자

Thank you Larry. I already do that and this is the result. It used to work well but not anymore. Please see next reply

It is the same here.

작성자 베스트 답변

Thanks. I already do that and this is the result:

 

@api.constrains('name') # this means the following method defines constraint(s). in our case: duplication. argument passed is the field which you want make it unique def check_duplicate_rec(self): students = self.search([('name', '=', self.name)]) if len(students) > 1: # if only 1 record is found means we are ok. we just found the record we are creating. raise Warning("The student record is already exists!") # if raise XXX is called the method will exit from here and will not continue return True print "students :::::::::::", students

아바타
취소

What browser are you using and what OS?

작성자

Chrome on Ubuntu

관련 게시물 답글 화면 활동
3
7월 25
2103
0
9월 23
4334
8
3월 15
10326
0
2월 25
1113
2
12월 24
2462