コンテンツへスキップ
メニュー
この質問にフラグが付けられました

In Odoo 16, I need to validate certain stock.picking transfers programatically using a cron when they do not have the status 'canceled'.

However, if I use the actions also used in the database, the status is still on 'ready', the amount to process is all still in 'reserved' and no items are set to 'done'.

Does anyone know what I'm doing wrong? My code is the following:

	​order_id = existing_order.id
lines_to_ship = self.env['stock.picking'].search([('sale_id', '=', order_id), ('state', '!=', 'done'),
('state', '!=', 'canceled')])

if not lines_to_ship or len(lines_to_ship) < 1:
return

for
line_to_ship in lines_to_ship:
try:
success = line_to_ship.sudo().action_assign()
if not success:
continue
​ validated = line_to_ship.sudo().with_context({'skip_sanity_check': True, 'skip_immediate': True,
​ 'skip_backorder': True}).button_validate()

done = line_to_ship.sudo().with_context({'cancel_backorder': False})._action_done()
except Exception as e:
_logger.info(str(e))
continue
アバター
破棄
関連投稿 返信 ビュー 活動
1
8月 21
4085
1
6月 21
4714
1
5月 25
2463
1
4月 25
3485
1
4月 25
4316