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

Odoo 8 API Problem. Not JSON Serializable

By
Patrick Hofacker
on 10/24/15, 9:14 AM 1,077 views

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

Patrick

1

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 10/24/15, 9:55 AM

Documentation new api - method create():

Takes a number of field values, and returns a recordset containing the record created:

>>> self.create({'name': "New Name"})

res.partner(78)


Conclusion: your problem with res_id

Oh my god... im such an idiot... Many Thanks... take all my upvotes i can give to you. That was the solution

Patrick Hofacker
on 10/24/15, 10:00 AM

If the answer is correct, select rather that you accept it. Additionally, you can possibly vote.

zbik
on 10/24/15, 10:07 AM

Sry didn't find the button right away. But now your answer is marked. Thank your very much... im hanging there since 2 weeks

Patrick Hofacker
on 10/24/15, 11:00 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: 10/24/15, 9:14 AM
Seen: 1077 times
Last updated: 10/24/15, 11:00 AM