Odoo Help


Error on Form: The record could not be found in the database

jay rawal
on 4/16/13, 6:54 AM 2,495 views

I am getting this error when clicking on form of courier.. I am new to openerp and dont know why these error comes? please provide me some solution of it if possible?

my courier.py file content: class courier_courier(osv.osv):

def on_change(self, cr, uid, ids, routing_id, context={}):
    res = {'deliver_date':False}
    day =0 
    obj = self.pool.get('courier.routing')
    rout = obj.browse(cr, uid, routing_id, context=context)
    day = rout.days
    today = datetime.now()
    date = today + timedelta(days=day)
    f_date = datetime.strftime(date, '%Y-%m-%d %H-%M-%S')
    res['deliver_date'] = f_date
    return {'value' : res}

def set_to_draft(self, cr, uid, ids, context={}):
    wf_service = netsvc.LocalService("workflow")
    self.write(cr, uid, ids, {'state':'draft'}, context=context)
    for obj in self.browse(cr, uid, ids, context=context):
        wf_service.trg_delete(uid, 'result.result', obj.id, cr)
        wf_service.trg_create(uid, 'result.result', obj.id, cr)
    return True

def default_get(self, cr, uid, fields, context=None):
    if context is None: context = {}
    res = super(courier_courier, self).default_get(cr, uid, fields, context=context)
_name = 'courier.courier'
_columns = {
        'name' : fields.char('Name', size=64, required=True),
        'from_id' : fields.many2one('res.partner','From'),
        'to_id' : fields.many2one('res.partner','To'),
        'routing_id' : fields.many2one('courier.routing','Routing'),
        'invoice_id' : fields.many2one('account.invoice','Invoice'),
        'state' : fields.selection([
        'history_ids' : fields.one2many('courier.history','courier_id','History'),
        'terms_id' : fields.many2one('courier.terms','Terms'),
        'deliver_date' : fields.datetime('Delivery Date'),
        'price': fields.related('routing_id','price',type='integer',string='Price'),
        'path' : fields.related('routing_id', 'path_ids' , type='one2many', relation='courier.routing.path', string='Path', readonly=True),
        'branch_id' : fields.many2one('hr.department','Branch')
_defaults = {'state':'draft'}


Please specify at which event you are getting error & if possible add error from server side in comment.

on 4/16/13, 7:26 AM

please provide an error which comes in server..!!!

Abhishek MEhta
on 4/16/13, 7:34 AM

after making courier.py file and compiling it on server no error comes. but when i m clicking on form view of courier then it will prompt the following message on top right side...

jay rawal
on 4/16/13, 7:46 AM

when a required field is there and you dont fill that field than it will show you the message for that required field.. just like that when clicking on form view it will show the mesage"Form: The record could not be found in the database"

jay rawal
on 4/16/13, 7:53 AM

Thanks Keyur & Abhishek MEhta for replying about my post..

jay rawal
on 4/16/13, 7:55 AM

It is the case when you trying to access the record which is not in the database. What if you create a new record? At that time does it give you any error?

on 4/16/13, 8:01 AM

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 4/16/13, 9:25 AM

After reviewing your code i found that you have not return any thing in default_get method. So, you have to return res in default_get method to avoid this issue.

jay rawal
On 4/16/13, 8:04 AM

just need to change the following part of the code than the error is solved.

def default_get(self, cr, uid, fields, context=None):
     if context is None: context = {}
     res = super(courier_courier, self).default_get(cr, uid, fields, context=context)
     return res

It seems there is not need of this method because you are not doing anything in method.

Sudhir Arya (ERP Harbor Consulting Services)
on 4/16/13, 8:20 AM

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: 4/16/13, 6:54 AM
Seen: 2495 times
Last updated: 3/16/15, 8:10 AM