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
0
1
4,332

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
Patrick Hofacker
Avatar
Discard
1 Answer
0
Best Answer

Hi Patrick

You can change return args:

'res_id': res_id


To
'res_id': res_id.id


And try again!
Avatar
Leo Tran
Comment Share
Avatar
Leo Tran
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!

Q&A Forum Regulations

Forum Regulations

By using the FAQ Forum on ERPOnline.vn website, you unconditionally agree to the following terms:

    1. Q&A Forum is a discussion environment to support each other in Odoo/ERPOnline implementation, in the spirit of "community support community", with internet address at: https://www.erponline.vn/forum/hoi-dap-7

    2. You are thoroughly responsible for the content submitted by you.

    3. DO NOT use the Q&A Forum for any activities that violate Vietnamese law and International Conventions to which Vietnam is a participant.

    4. DO NOT post content that is offensive, defamatory, or discredits other individuals or legal entities.

    5. DO NOT post advertisements or advertising content.

    6. DO NOT post content that is not related to management software and ERP in general as well as OpenERP and ERPOnline.vn in particular.

    7. DO NOT post copyrighted content or content, materials, products protected by Intellectual Property law without the written consent of the author.

    8. DO NOT embed images from other websites.

    9. You agree that all options, solutions, answers in the Q&A section on ERPOnline.vn website are for reference only. ERPOnline.vn website will not be liable if you have any damage when applying the plans given in the Q&A section on ERPOnline.vn website.

These terms and conditions may be amended to suit reality at any time without prior notice.