Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata

I currently have an automated rule that cancels all pickings created from the Point of Sale. However, now I want to extend this functionality to delete the picking orders once they are canceled.

I created a new automation rule and added the following server action:


However, I’m encountering an issue when trying to delete the picking records, as it sometimes shows errors like The record does not exist or has already been deleted. I suspect it’s due to dependencies or processes tied to the picking orders.

Could anyone advise how to safely delete canceled picking orders, or how to troubleshoot this issue? Is there a better approach to achieve this in Odoo?

Thank you for your help!

# Iterate over the records that trigger the rule
for record in records:
    # Check if the record exists
    if record.exists():
        _logger.info(f"Processing record: {record.name} with status {record.state}")
        # If the record is in 'cancel' state, delete it
        if record.state == 'cancel':
            record.unlink()
            _logger.info(f"Record {record.name} has been automatically deleted.")
        else:
            _logger.info(f"Record {record.name} is in status '{record.state}', no action taken.")
    else:
        _logger.warning("The record does not exist or has already been deleted.")
Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
dic 24
1039
1
ago 24
2871
0
nov 16
3539
0
lug 24
1006
1
lug 25
1886