跳至內容
選單
此問題已被標幟

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
4034
1
6月 21
4679
1
5月 25
2397
1
4月 25
3424
1
4月 25
4233