Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
pro 24
1043
1
srp 24
2882
0
lis 16
3542
0
čvc 24
1016
2
srp 25
115