Search code examples
pythonormodooodoo-17

record doesn't exist error when creating a new record


okay so, I am trying to inherit the sale.order.line model and tapping into the create() method. The goal is that when a new order line gets added if it's a service-type product, we add a new order line with a specific product that is already set up on Settings. However, on the create() call, it throws an error saying: Record does not exist or has been deleted.(Record: sale.order.line(115,), User: 2), I am not sure why. The first thing is, that the record exits and the second thing is, not using it on the create call. Here is my code: https://gist.github.com/M4hd1BD/9f661e189e85111df097897ce83f5a40, can anyone take a look and see what might I have done wrong here?


Solution

  • The issue was matching an id with an instance of product.template. Fixed by changing the first if clause to:

    if (
            product_type == "service"
            and sale_order_line.product_template_id.id != shop_supplies_product.id
            and shop_supplies_product
        ):