Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't Delete Products from Enterprise's Product list #5947

Closed
emilyjeanrogers opened this issue Aug 25, 2020 · 8 comments · Fixed by #6617
Closed

Can't Delete Products from Enterprise's Product list #5947

emilyjeanrogers opened this issue Aug 25, 2020 · 8 comments · Fixed by #6617
Labels
bug-s3 The bug is stopping a critical or non-critical feature but there is a usable workaround. hackathon Issues for upcoming hackathons

Comments

@emilyjeanrogers
Copy link

emilyjeanrogers commented Aug 25, 2020

Description

Aus Enterprise Grassroots Beef (975) has several products they wish to delete. In Edit Products, on select of the Trash Icon, the confirmation window appears 'Are you Sure?'. On select 'Yes' to confirm, nothing happens. The product doesn't delete.

Expected Behavior

A product can be deleted, or an error message is shown explaining why it can't be deleted.

Actual Behaviour

Nothing happens - product is not deleted.

The products they want to delete have now been listed as variants of a single Soap product. See image below:

Screen Shot 2020-08-25 at 2 23 24 PM

Maybe related:

The screen shot above was taken when logged in as Superadmin, and shows that the products that could not be deleted don't have images. This screen shot was taken in Chrome on a MacBook Pro. Tested on Safari as well - also no images.

@chezaorchard took the following screenshot at the same time, also logged in as Superadmin, also using Chrome browser, and the products DO have images.

Screen Shot 2020-08-25 at 1 53 04 pm

Steps to Reproduce

  1. Log in as Superadmin
  2. Search for Enterprise Grassroots Beef
  3. Use keyword search to find any of the Soap products that are not variants of a top level product (see image above)
  4. Try to delete one of these products

Workaround

The products can not be deleted. There is no workaround. The products can be ignored, but this is highly annoying to the customer.

Severity

S2

bug-s1: a critical feature is broken: checkout, payments, signup, login
bug-s2: a non-critical feature is broken, no workaround
bug-s3: a feature is broken but there is a workaround
bug-s4: it's annoying, but you can use it
bug-s5: we can live with it, only a few users impacted

https://github.com/openfoodfoundation/openfoodnetwork/wiki/Bug-severity
-->

Your Environment

  • Version used:
  • Browser name and version:
  • Operating System and version (desktop or mobile):

Possible Fix

@emilyjeanrogers
Copy link
Author

Maybe related to #5942

@sigmundpetersen sigmundpetersen added the bug-s2 The bug is affecting any of the non-critical features described in S1 and there is no workaround. label Aug 25, 2020
@seanbaker74
Copy link

seanbaker74 commented Aug 26, 2020

I experienced this issue after upgrading my test system from 2.9.6 to 3.2.3. Certain products cannot be deleted through the UI, and no error message is provided. The server's production.log file does not provide any useful debugging information.

This issue appears to be related to the addition of the Spree::StockItem code (0e71183)

In the rails console, if I run Spree::Product.destroy on a product that cannot be deleted, I get:
ActiveRecord::ReadOnlyRecord: ActiveRecord::ReadOnlyRecord

This issue was reported in Spree: spree/spree#3723

In Spree, it looks like the fix was to remove stock_movements as a dependency to Spree::StockItem.destroy

Fix:
In stock_item.rb, change:
has_many :stock_movements, dependent: :destroy
to...
has_many :stock_movements

On my test system, if I make that change to stock_item.rb, I'm then able to delete those products in the UI.

Should also make the other recommended change in that spree issue, which was to "soft delete" the stock_item entries instead of hard deleting them so that the stock_movements entries can still reference the deleted stock_items.

@tschumilas
Copy link

Also noting this issue - and the comment the recent move to V3 brought soft deletion to stock items - could this have caused the problem of not being able to delete variants that have been ordered ? #5335

@RachL RachL added bug-s3 The bug is stopping a critical or non-critical feature but there is a usable workaround. and removed bug-s3 The bug is stopping a critical or non-critical feature but there is a usable workaround. bug-s2 The bug is affecting any of the non-critical features described in S1 and there is no workaround. labels Sep 1, 2020
@filipefurtad0
Copy link
Contributor

filipefurtad0 commented Sep 4, 2020

I have partially reproduced this bug in a staging environment. It seems to play a role, whether the stock of the product/variant to be deleted is set to be on_hand or on_demand.

For two newly created products, product A with stock on_hand and product B with stock on_demand, and after adding them to an open OC, and placing two orders, each order containing either product A or product B, I've observed that:

image

The image of that product seems broken, after attempting to delete the product, which seems to be causing error 404 on the console. This is also the case, when logged in as superadmin.

Hope this is useful to tackle the underlying issue.

@lin-d-hop
Copy link
Contributor

On release testing just now I noticed that also Duplicate Product button is not working for some cases.

I am noting here because I have a hunch it is related.... but I don't have the time to investigate properly and create an issue right now.

@RachL
Copy link
Contributor

RachL commented Sep 14, 2020

@lin-d-hop we have this known issue here: #3808 is that what you have experienced?

@emilyjeanrogers
Copy link
Author

emilyjeanrogers commented Nov 4, 2020

I am adding further details to be absolutely sure that this issue includes being unable to delete Variants as well as top level products from an Enterprise's product list. A top level product can be moved by a Superadmin into a dummy enterprise, but a variant cannot.

Enterprise Grassroots Beef (975) wants to delete a variant of the top level product Offal and Bones. The variant they want to delete is called Brisket Bones:

Screen Shot 2020-11-04 at 2 37 06 PM

When I use the trash icon to try to delete the variant using Superadmin it appears to be working, but when you click OK the product just doesn't delete:
Screen Shot 2020-11-04 at 2 37 22 PM

When I go into Variants and attempt to delete from in there, I get the snail:

Screen Shot 2020-11-04 at 2 41 20 PM
Screen Shot 2020-11-04 at 2 41 28 PM

There is no workaround that I'm aware of for deleting a variant. A variant can't be moved to another enterprise. The only option is to set stock levels as zero so it will never appear in a shop - but it will always be there in their product list.

@tschumilas
Copy link

Just concuring with @emilyjeanrogers (and embarassed I didn't flag when I created the issue). There is no way to move only one variant to another producer. So if a product has many variants - support team has to assign all of them to a dummy enterprise, and re-create the entire list of variants, minus the one variant the producer needs deleted. Speaking for alread over-burdened support teams - surely we'd say that this workaround is not realistic, and make this an s2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-s3 The bug is stopping a critical or non-critical feature but there is a usable workaround. hackathon Issues for upcoming hackathons
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants