如何在 Odoo 15 上处理 'stock.immediate.transfer' 条记录?

How to process 'stock.immediate.transfer' records on Odoo 15?

我最近从 Odoo 13 切换到 Odoo 15。使用 Odoo 13,我可以处理 'stock.picking' 和

models.execute_kw(db, uid, password, 'stock.immediate.transfer',
                                            'create',
                                            ({'pick_ids': [pickid]})
    )
   
   models.execute_kw(db, uid, password, 'stock.immediate.transfer', 'process',
                                [createdid], {})

然而现在使用 Odoo 15,运行 相同的流程处理和 returns True 但选股记录不会关闭。我查看了文档,但没有看到有关如何处理即时转账的任何信息。

process function has changed, now it prepares the stock pickings then call again the button_validate function to process transfers, and to do so, it will first check if button_validate_picking_ids 通过上下文传递。

请注意,即使该函数再次调用了 button_validate 函数,它也会 return True 并且如果您在调用 [=16] 之后手动调用 button_validate =] 函数,传输将被处理并传递到 done 状态。

models.execute_kw(db, uid, password, 'stock.picking', 'button_validate', [picking_ids])

您可以重现相同的逻辑来处理传输(将上下文传递给向导 process 函数):

action = models.execute_kw(db, uid, password, 'stock.picking', 'button_validate', [picking_ids])

values = {'pick_ids': [(6, 0, picking_ids)], 
          'immediate_transfer_line_ids': [(0, 0, {'to_immediate': True, 'picking_id': pick_id}) for pick_id in picking_ids]}

transfer_id = models.execute_kw(db, uid, password, 'stock.immediate.transfer', 'create', [values])
models.execute_kw(db, uid, password, 'stock.immediate.transfer', 'process', [transfer_id], {'context': action['context']})