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

How to trace error in these code

By
Jithin
on 9/7/16, 4:15 AM 181 views

Error log

  Server Error
Traceback (most recent call last):
  File "/opt/ 9/ /openerp/http.py", line 643, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/ 9/ /openerp/http.py", line 680, in dispatch
    result = self._call_function(**self.params)
  File "/opt/ 9/ /openerp/http.py", line 316, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/ 9/ /openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/ 9/ /openerp/http.py", line 309, in checked_call
    result = self.endpoint(*a, **kw)
  File "/opt/ 9/ /openerp/http.py", line 959, in __call__
    return self.method(*args, **kw)
  File "/opt/ 9/ /openerp/http.py", line 509, in response_wrap
    response = f(*args, **kw)
  File "/opt/ 9/ /addons/web/controllers/main.py", line 896, in call_button
    action = self._call_kw(model, method, args, {})
  File "/opt/ 9/ /addons/web/controllers/main.py", line 884, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/opt/ 9/ /openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/ 9/ /openerp/api.py", line 381, in old_api
    result = method(recs, *args, **kwargs)
  File "/opt/ 9/custom/trunk/floating_purchase_order/models/floating.py", line 50, in action_purchase_order
    'order_line' : (0, 0, {'brand_id' : vals['product_brand_id'],
KeyError: 'product_brand_id'


.py file

@api.multi

def action_purchase_order(self, vals):

rec= self.env['purchase.order'].create({

'partner_id' : self.vendors.id,

'store_id' : self.store_id.id,

'purchase_order_type' : self.order_type,

'date_order' : self.date_order,

'date_planned' : self.date_order,

'type' : self.type,

'order_line' : (0, 0, {'brand_id' : vals['product_brand_id'],

'product_id' : vals['purchase_product_id'],

'part_number' : vals['product_part_number'],

'name' : vals['desc'],

'date_planned' : vals['date_order'],

'product_qty' : vals['quantity_no'], 

})

})

0
ayman mohammed adam
On 9/7/16, 4:56 AM

dear Jithin,

I think you need to replace this line:

'order_line' : (0, 0, {'brand_id' : vals['product_brand_id'],

by:

'order_line' : (0, 0, {'brand_id' :  vals.get('product_brand_id',False),

 

I hope I helped you.


Ayman i don't want to fetch any values i want to create in another model.

Jithin
on 9/7/16, 5:05 AM

ok I know the vals is dictionary that means vals have one or more key:value

when you need to pass the value of key not exist for this vals you found error.

replace it and check it .

or determine the brand_id in your form before do create.

ayman mohammed adam
on 9/7/16, 5:52 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: 9/7/16, 4:15 AM
Seen: 181 times
Last updated: 9/7/16, 4:56 AM