تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
768 أدوات العرض

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.")
الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
ديسمبر 24
1039
1
أغسطس 24
2878
0
نوفمبر 16
3541
0
يوليو 24
1009
1
أغسطس 25
11