Hub "Suteau Biosol Orl茅ans" has permission from producer "Jose Maria Jordan Garcia" to add to order cycle and add to inventory.

Producer has a product called "patates douces" with two variants: one of 6kg and one of 10kg. Both are "on demand".
Hub add to order cycle the two variants.

In the shopfront though, one of the two variants doesn't appear: the 10kg one.
When looking at console something seems to fail

(NB the stripe JS time out is probably linked to my bad connexion, I'm in the train, but something else happens).
The hub has set up correctly that products can be added directly to OC, doesn't need to go through inventory. But in case, I check inventory.
Even if the permission to add to inventory is there, the products of the producer doesn't appear, neither in new products not in inventory.
When looking at the console it seems there is a problem with failing overriden something.

It is for sure linked to a permission issue. This user has 15 hubs and more than 10 producers under the same account. Strangely when he creates a new hub or producer the E2E default relationships doesn't happen, he has to manually recreate them all one by one.
I guess this might come from the fact that we changed the ownerships of the orginal shops created, we need to test and open a specific issue. Just putting this info here as might give some clue on investigation.
Variants put in OC appear in shop.
Some don't.
Described above.
Reported by our biggest user in France who is opening a new hub and sale is launched tomorrow (Saturday 17th nov)
bug-s1: a critical feature is broken: adding a product to a shop
The ~Javascript console~ browser errors are unrelated and seem to be from network connectivity issues:
Hey @myriamboure
That ERR_SPDY_PING_FAILED error looks like a network problem.
Can you please confirm/replicate the issue in a place where you have a good connection?
supplier_id 116
product_id 456
variants 1145, 1146 and 1154 (the master variant 1145 is 2kgs)
on variant_overrides, quite a little complexity with some prices and some on_demand:
id | variant_id | hub_id | price | count_on_hand | on_demand
---+----------+--------+-----+---------------+---------------+
276 | 1146 | 147 | 6.00 | | |
331 | 1146 | 188 | | | | t
296 | 1146 | 162 | 17.00 | | |
734 | 1146 | 681 | | | | f
332 | 1154 | 188 | 25.00 | | | t
277 | 1154 | 147 | 27.00 | | |
300 | 1154 | 162 | 25.00 | | |
735 | 1154 | 681 | | | | f
hub_id 147, 188, 162, 681
id | name
-----+------------------------------
147 | Suteau Biosol Admin
162 | SuteauBiosol - boutique pros
188 | COOP. PARTICIPATIVE
681 | SUTEAU BIOSOL Orl茅ans
So, they are all going through inventory (except master variant). The overrides are created.
There are no permissions revoked, so most probably not related to pervious work on permissions.
Permissions look normal, all 4 hubs have permissions to add to OC and add to inventory.
Trying to jump to conclusions now as I have to go (I will come back in 8 hours, at 17h Portugal time):
I hope this is a good start of the investigation.
Yes, so the overrides have false "on demand" and no value set for stock. I presume that this means that the supply for the shop will not be "on demand" and that the stock specified in the supplier's variants will be inherited (need confirmation).
In the variant settings, both 6kg and 10kg indeed have true for "on demand", so in the perspective of the supplier, the stock levels are unlimited. However, if I'm right, the shop is now inheriting the "count on hand" data, which the supplier does not even see in the UI anymore and happens to be 1000 for 6kg and 0 for 10kg.
@myriamboure A quick solution would be to set "on demand" in the variant override to true. Could you check if this works?
I will investigate further, and also post another comment with recommendations for the code.
shop = Enterprise.find_by_permalink("suteau-biosol-orleans")
supplier = Enterprise.find_by_name("JOSE MARIA JORDAN GARCIA")
product = Spree::Product.where(supplier_id: supplier.id, name: "Patates Douces").first
# 6kg variant
variant = product.variants.all.find { |v| v.full_name == "6kg" }
# on_demand: true, count_on_hand: 1000
variant_override = variant.variant_overrides.where(hub_id: shop.id).first
# on_demand: false, count_on_hand: nil
# 10kg variant
variant = product.variants.all.find { |v| v.full_name == "10kg" }
# on_demand: true, count_on_hand: 0
variant_override = variant.variant_overrides.where(hub_id: shop.id).first
# on_demand: false, count_on_hand: nil
Aha... yes they do inherit the supplier's on_hand for that variant if it's nil on the override. I guess it should inherit the on_demand value as well if it's not set on the VO, but maybe there's a gap in the logic there.
Edit: I should say the on_hand value is "referenced" instead of "inherited". The supplier's variant on_hand will be decremented when that VO is ordered.
Ok sorry I'm back I'm checking now.
So indeed the errors in the console were linked to network issue.
But for the real underlying problem, I don't understand the count on hand thing which is 0 for the 10kg variant but I understood the issue come from here.
As a workaround you suggest to "force" on demand in inventory. I went to inventory of Suteau Biosol Orl茅ans and "forced" the on-demand, even if before it was already on demand (in grey "a volont茅" means on demand in French)

And... it works !

So can you open another issue to explain the problem (which I don't understand) @kristinalim ? I think it is still S2 as other users will definitely face that... and won't think to force on-demand...
Thank you all for your quick support at least I have a workaround, our users will be able to launch the new sale :-)
Thanks, @myriamboure! I created sub-issues #3066, #3067, and #3068. I agree that they should be S2.
I'm closing this issue for now as @kristinalim opened three other issues to fix the problem. This remains accessible from the three issues.
The issue has happened again on our user who has 15 shop, some products appear in no shop, we have to fix manually by going in each of the 15 inventories and forcing on demand... hope we can fix that quickly it is very unstable...
Most helpful comment
Yes, so the overrides have false "on demand" and no value set for stock. I presume that this means that the supply for the shop will not be "on demand" and that the stock specified in the supplier's variants will be inherited (need confirmation).
In the variant settings, both 6kg and 10kg indeed have true for "on demand", so in the perspective of the supplier, the stock levels are unlimited. However, if I'm right, the shop is now inheriting the "count on hand" data, which the supplier does not even see in the UI anymore and happens to be 1000 for 6kg and 0 for 10kg.
@myriamboure A quick solution would be to set "on demand" in the variant override to true. Could you check if this works?
I will investigate further, and also post another comment with recommendations for the code.