Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd

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
Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
aug. 21
4034
1
jun. 21
4681
1
mei 25
2404
1
apr. 25
3425
1
apr. 25
4243