-
-
Notifications
You must be signed in to change notification settings - Fork 729
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
[Spree Upgrade] Add on_hand and on_demand to the variants create and edit pages #3613
[Spree Upgrade] Add on_hand and on_demand to the variants create and edit pages #3613
Conversation
65dec6f
to
caa8cbf
Compare
caa8cbf
to
3324536
Compare
We do not include stock management from v2 because we will use the variants edit page to manage on_hand and on_demand
3324536
to
6ad952f
Compare
…and edit pagei), this is where they used to be in spree v1 The admin variants controller create action is adapted (same as in the admin ProductsController). This is necessary because variant.on_hand and on_demand cannot be mass assigned on creation in v2, see VariantStock for more details. For now we are hiding the new stock management page that comes in spree v2 as we don't need the complexity added by the management of stock per stock location (only one stock location in ofn v2 for now)
6ad952f
to
21a10d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Thank you for doing it so thoroughly.
@luisramos0 Tested this one and found that: Not sure whether this is caused by this change or whether this was an existing issue. |
…t on_hand and on_demand if there are previous errors in the variant
Thanks @lin-d-hop for testing! Tech explanation: this is a problem with variants in the system that do not have stock_items. I am not sure how did we end up with variants that do not have stock_items. So @lin-d-hop , I suggest you confirm the error is related to specific variants and not user profiles, and if that's correct we reset the database and try to re-create the problem (variants without stock_items). |
the problem is "related" to this PR (this PR makes the problem more visible) but the problem is not caused by this PR. So, I think we can merge this PR and create a separate issue for this problem. |
Thanks @luisramos0 |
ok, thanks! for reference this is the invalid data:
I have reset the DB in staging AU and tried to replicate the issue by creating and deleting variants in both the bulk edit page and the new variant page... all looks good. @lin-d-hop can we move to ready to go? |
This is blocking #3640 so I am going to merge it. We can open new issue if required. |
What? Why?
Closes #3573
shared/_product_tabs
Here I de-deface shared/_product_tabs and remove the new Stock Management option from it.
Variants create/edit Page
In spree v2, on_hand and on_demand were removed from the variants edit page (on_hand here and on_demand here).
These fields were moved to a new submenu/page "Stock Management" but because this new page includes the complexity of stock management, it looks at lot easier (for both the dev and the user!) to just re-add these two fields in the variants edit page. Maybe when/if we make OFN work with multiple stock locations we can move OFN to use the stock management page.
This variants edit page is obviously needing a de-deface. But with the de-deface it will also need more specs and a new angular controller to do what's currently being done in on_demand_script.html.haml.deface for example. It will take some effort so I created a new tech debt issue for it #3615
Meanwhile, in this PR, I added a new deface override to add the two fields back to the page and adapted on_demand_script.html.haml.deface so that it works.
In terms of improvement, I didn't want to waste time improving the overrides so I decided to write feature specs on top of the page that will be valid after #3615 I added the specs in master #3617 these specs pass in master and pass in v2 with this PR (I tested locally and we can validate this when #3617 is merged into 2-0-stable).
What should we test?
The variants edit page should work as normal and the user should be able to manage on_hand and on_demand. These 2 fields should play well with changing the same values on the bulk edit page.
I have tested this locally and it's working correctly.