Skip to Content
Menu
This question has been flagged
1 Reply
5774 Views

I have a button on the sale.order.line model that opens a popup on the stock.picking model. The popup opens perfectly , but when I want to spend some fields default to popup, Odoo displays the following message:

TypeError: res.partner(id,) is not JSON serializable

In the following images shown how the popup:


http://es.zimagez.com/zimage/json0.php

http://es.zimagez.com/zimage/json2.php


This is the function that opens the popup:

    @api.multi
    def action_stock_picking(self):        
        self.ensure_one()
        picking_form = self.env.ref('stock.view_picking_form', False)
            return {
                'name': _('Formulario de Inventario: Recepciones'),
                'type': 'ir.actions.act_window',
                'view_type': 'form',
                'view_mode': 'form',
                'res_model': 'stock.picking',
                'views': [(picking_form.id, 'form')],
                'view_id': picking_form.id,
                'target': 'new',
                'context': dict(
          #partner_id stock.picking = partner_id sale.order.line

                    **default_partner_id=self.order_id.partner_id,**

                    default_origin=self.order_id.name,
                    default_picking_type_id = 1,
                    default_model='stock.picking',
                    default_res_id=self.id,
                    default_composition_mode='comment',
                    mark_invoice_as_sent=True,
                ),
            }

When I want to spend the client popup, Odoo shows the error that I mentioned previously.

Thank you very much to all. I hope some help from you.

Avatar
Discard
Best Answer
Just have to set partner_id like default_partner_id=self.order_id.partner_id.id instead of default_partner_id=self.order_id.partner_id,

@api.multi def action_stock_picking(self): self.ensure_one() picking_form = self.env.ref('stock.view_picking_form', False) return { 'name': _('Formulario de Inventario: Recepciones'), 'type': 'ir.actions.act_window', 'view_type': 'form', 'view_mode': 'form', 'res_model': 'stock.picking', 'views': [(picking_form.id, 'form')], 'view_id': picking_form.id, 'target': 'new', 'context': dict( #partner_id stock.picking = partner_id sale.order.line **default_partner_id=self.order_id.partner_id.id,** default_origin=self.order_id.name, default_picking_type_id = 1, default_model='stock.picking', default_res_id=self.id, default_composition_mode='comment', mark_invoice_as_sent=True, ), }
Avatar
Discard