Avik Samaddar
Avik Samaddar

Reputation: 431

how to add a new field in res.partner.bank in base module of odoo v8?

I am trying to add a new field in res.partner.bank model in odoo. which will be populated by the value of a field in res.bank (by onchange). I have added a field in res.bank which works perfectly

    'bic': fields.char('Bank Identifier Code', size=64,
        help="Sometimes called BIC or Swift."),
    'ifsc': fields.char('IFSC', size=64),
}

now I have added a similar field in res.partner.bank

    'bank_bic': fields.char('Bank Identifier Code', size=16),
    'bank_name': fields.char('Bank Name'),
    'bank_ifsc': fields.char('Bank Ifsc'),
    'owner_name': fields.char('Account Owner Name'),
    'street': fields.char('Street'),

now when I open the corresponding menu I get a OpenERP Server Error:

File "d:\Program Files\ERP\server\.\openerp\sql_db.py", line 158, in wrapper
File "d:\Program Files\ERP\server\.\openerp\sql_db.py", line 234, in execute
ProgrammingError: column res_partner_bank.bank_ifsc does not exist
LINE 1: ...partner_bank."owner_name",res_partner_bank."city",res_partne...
                                                         ^

however I have also tried to change the onchange definition which results in internal server error:

def onchange_bank_id(self, cr, uid, ids, bank_id, context=None):
    result = {}
    if bank_id:
        bank = self.pool.get('res.bank').browse(cr, uid, bank_id, context=context)
        result['bank_name'] = bank.name
        result['bank_bic'] = bank.bic
        result['bank_ifsc'] = bank.ifsc
    return {'value': result}

any clue might help, thanks in advance.

Upvotes: 0

Views: 2482

Answers (3)

Osmani
Osmani

Reputation: 45

I had the same error. What i did was, added the new field manually in the database, restarted the server and then it worked.

Upvotes: 0

Avik Samaddar
Avik Samaddar

Reputation: 431

OMG! i never imagined what a silly issue it could be. since I was using notepad++ my added definition line was using 5 spaces in front and others were 4 spaces though it is not necessarily a crime to add an extra space but it was raising error during compilation.

thanks to the odoo.py it mentioned about the indentation error, while i was trying to scaffold another module. lesson learned, how even the smallest possible thing can give you a big-bugging issue, when it comes to code.

Upvotes: 1

Mariusz Mizgier
Mariusz Mizgier

Reputation: 537

This line:

ProgrammingError: column res_partner_bank.bank_ifsc does not exist

is pointing at your error - did you update your module after adding that column to your code? Seems like database was not updated, column not added to related table and that causes Odoo to crash.

Upvotes: 0

Related Questions