Odoo Help


How to paste code into forum without losing return characters?

on 2/25/15, 6:25 AM 1,175 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?

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.

OdooTec, Hesham ELMAHDY
on 2/25/15, 8:38 PM

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

on 12/17/16, 5:51 AM
Larry Marshall
On 2/25/15, 11:00 AM

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

OdooTec, Hesham ELMAHDY
on 2/25/15, 8:37 PM

It is the same here.

on 3/3/17, 2:49 PM
On 2/25/15, 8:36 PM

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?

Larry Marshall
on 2/25/15, 10:02 PM

Chrome on Ubuntu

OdooTec, Hesham ELMAHDY
on 2/25/15, 10:33 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 2/25/15, 6:25 AM
Seen: 1175 times
Last updated: 3/3/17, 2:49 PM