Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

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
Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
sie 21
4034
1
cze 21
4680
1
maj 25
2400
1
kwi 25
3425
1
kwi 25
4241