Se rendre au contenu
Menu
Cette question a été signalée

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
Ignorer
Publications associées Réponses Vues Activité
1
déc. 24
1042
1
août 24
2880
0
nov. 16
3541
0
juil. 24
1015
2
août 25
81