This question has been flagged
2 Replies
3472 Views

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?

Avatar
Discard
Author

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.

Best Answer

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))

Avatar
Discard
Author

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.

Author Best Answer

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

Avatar
Discard

What browser are you using and what OS?

Author

Chrome on Ubuntu