Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
3424 Vistas

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'], 

})

})

Avatar
Descartar
Mejor respuesta

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.


Avatar
Descartar
Autor

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

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.