Help

Welcome!

This community is for professionals and enthusiasts of our products and services.
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

0

Problem with Odoo 8 API, not json serializable

Avatar
Patrick Hofacker

Hey guys,

i'm trying to solve call a wizard(lets call it wiz2) out of another wizard(call this wiz1), then comfortably change the records of the wiz1-model via the model of wiz2.
My problem ist now that i get errors.. over and over, may one of you is able to help me.
here is my code so far:

The Code of the wiz1:

# -*- coding: utf-8 -*-
from openerp import models, fields, api
from openerp import exceptions


class TransferExtension(models.TransientModel):
    _inherit = 'stock.transfer_details_items'
    
    @api.multi
    def do_enter_serials(self):
        self.ensure_one()        
        #get the reference on new model
        wizardmodel = self.env['serial.wizard']
        #create new record
        res_id = wizardmodel.create({'item_clicked':self.id})
        #Read the view_id.
        view = self.env.ref('unique_serials_v1.view_serial_wizard')
        #call the other wizard
        return { 
            'name': 'Eingabe der Serialnummern',
            'type': 'ir.actions.act_window',
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'serial.wizard',
            'res_id': res_id,
            'views': [(view.id, 'form')],
            'view_id': view.id,
            'target': 'new'
        }    


And this is the code of my wiz2

# -*- coding: utf-8 -*-
from openerp import models, fields, api
from openerp import exceptions


class SerialWizard(models.TransientModel):
    _name = 'serial.wizard'
    
    item_clicked = fields.Many2one('stock.transfer_details_items',string='Item')


so i'm getting the error:
Odoo Server Error

Traceback (most recent call last):
File "/opt/odoo/openerp/http.py", line 537, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/openerp/http.py", line 588, in dispatch
return self._json_response(result)
File "/opt/odoo/openerp/http.py", line 526, in _json_response
body = simplejson.dumps(response)
File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line 354, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python2.7/dist-packages/simplejson/encoder.py", line 262, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python2.7/dist-packages/simplejson/encoder.py", line 340, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python2.7/dist-packages/simplejson/encoder.py", line 239, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: serial.wizard(7,) is not JSON serializable

and don't have any idea where the problem is.

Hope you can help me
Thanks in Advance

Pinguincommander
Avatar
Discard
1 Answer
0
Avatar
Leo Tran
Best Answer

Hi Patrick

You can change return args:

'res_id': res_id


To
'res_id': res_id.id


And try again!
Avatar
Discard

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!