Odoo Help

Welcome!

This community 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.

0

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

By
jay rawal
on 4/16/13, 6:54 AM 1,736 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([
                        ('draft','Draft'),
                        ('pack','Packing'),
                        ('cancel','Cancel'),
                        ('dispatch','Dispatch'),
                        ('delivery','Delivery'),
                        ('return','Return'),
                        ('lost','Lost'),
                        ('done','Done'),
                        ],'Status',readonly=True),
        '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'}

courier_courier()

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

Keyur
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?

Keyur
on 4/16/13, 8:01 AM
1

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4341
| 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.

0
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 (SA)
on 4/16/13, 8:20 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/16/13, 6:54 AM
Seen: 1736 times
Last updated: 3/16/15, 8:10 AM