This question has been flagged

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

Avatar
Discard
Best Answer

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

Avatar
Discard
Author

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

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

Author

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