Deleting products added to a web shop

Hi all, hello @pokoli

I’m new to Tryton and also something new to Python, and new in this Forum.
So first of all, thanks for your work on this great open source software!

When trying to use Tryton and the WooCommerce Connector (using a container, see Dockerfile code mentioned above), I stumbled across an error message when trying to delete a product which was added to, and removed from WooCommerce Shop before:
“A value is required for field ‘Product Template’ in ‘Product Variant’.” - and the product is not deleted.

The error seems to be related with the foreign key
web_shop-product_product_product_fkey of the web_shop-product_product table

When removing a product in Tryton, in my case, it is deleted from the table product_product.
But the web_shop-product_product_product_fkey seems to impede this once a product is added to this table.

After deleting this fkey, the product which was added to, and removed from the WooCommerce Shop can be deleted in Tryton without error.

But - removing this fkey would result in inactive product registers in the web_shop-product_product table, which don’t exist any more in the product_product table.

What do you think about this?

Thanks in advance and all the best!
Jan

What you describe is not something related to the WooCommerce connector but the behaviour of the standard web_shop modules (where the relation is defined).

The issues is once a product is added to a web_shop it can not be deleted and the same happens on a Category and also on the Attribute because there is a ondelete='RESTRICT'on the relation fields.

For products and categories you can make it inactive on tryton, but this won’t trigger a delete on the webshop so this makes an inconsistent value.

Not sure why this restrictions where added but as far as the product had not be used on a sale I do not think we should prevent it’s deletion because it has been uploaded to a webshop. Indeed I will expect the conector to delete the product from the webshop if it has been deleted on tryton. That’s what we do when the product has been removed from the list of active products in the shop.

Could you please give us some more feedback about why are you deleting the product?

Thanks for your fast answer @pokoli!

You are right, that would be the Issue. But yes, I think the way it’s implemented is really ok.

Because once added to web shop (and eventually uploaded to the WooCommerce Shop), it might be a problem if a product is sold by third party Web Shops, in the moment when it doesn’t exist any more in Tryton. I was just a bit confused by this error message I think.