Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
1122 Lượt xem

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()
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 4 17
4352
0
thg 6 15
5670
0
thg 1 23
1904
0
thg 1 22
2889
1
thg 10 21
5094