Skip to Content
Menu
This question has been flagged

Hello everyone,

I try to call the "Create Backorder?" Wizard pop up using a Server Action. I created a button in the form view for the Server Action. But an error occured stating: Answers appreciated thank you!

AttributeError: 'stock.picking' object has no attribute 'open_wizard'

Below is my code:

def open_wizard(self):
    return {
        'name': 'Create Backorder?',
        'type': 'ir.actions.act_window',
        'view_mode': 'form', 'res_model':
            'stock.backorder.confirmation',
            'views': [[1530, 'form']],
            'view_id': 1530, 'target':
                'new', 'context': {
                    'button_validate_picking_ids': [27],
                    'default_show_transfers': False,
                    'default_pick_ids': [[4, 27]]
                   
                }
    }

actions = records.open_wizard()
Avatar
Discard
Best Answer

Hi,

Try the following code,

class StockPicking(models.Model):

    _inherit = 'stock.picking'


    def open_wizard(self):

        return {

            'name': 'Create Backorder?',

            'type': 'ir.actions.act_window',

            'view_mode': 'form',

            'res_model': 'stock.backorder.confirmation',

            'views': [[self.env.ref('stock.view_stock_backorder_confirmation').id, 'form']],

            'target': 'new',

            'context': {

                'button_validate_picking_ids': self.ids,

                'default_show_transfers': False,

                'default_pick_ids': [(6, 0, self.ids)]

            }

        }Make sure to replace the self.env.ref('stock.view_stock_backorder_confirmation').id with the correct ID of your form view.

actions = records.open_wizard()


Hope it helps

Avatar
Discard
Related Posts Replies Views Activity
0
Apr 17
4017
0
Jun 15
5346
0
Jan 23
1637
0
Jan 22
2603
1
Oct 21
4682