About with_childs on stock_move with default len(locations) == 1

Is this code intended?

The result is a bit confusing.
For example:
When a user from the locations, select two warehouse and execute releated action Products, they get an empty screen, when he expects all warehouse products.
Then If only One warehouse is select, you get all products for this warehouse.

For me it’s OK: if you select one location you probably want to know the stock about this location and all its children but if you select two locations you’re probably interested in the quantities in only those two locations.

But this behaviour can be changed by specifying explicitly the value of the key.

I would prefer two separate actions to know exactly what you will have.

  • Products (With child Locations)
  • Products (without child locations)

The current result is really confusing because in the example I give you get:

  • Products in the location (x) with a list of products
  • Products in the location (x, y) without any products

And what you think is where are the products of location x ?.

Maybe we can include childs by default if all the locations are from warehouse type.

For me, a good solution would be to add the with_childs to the context model with default value following the current behavior.

Note that the issue was arised by a real customer that didn’t understand the behaviour. Keeping the current behaviour is specially strange when the user is clicking on “view”-type locations where quantity will always be 0 if children are not considered.

Even more, we always discourage adding children to storage-type locations and recomend using view locations only. The reason is that it is hard to know the quantity of the location without including its children.

I would personally do in one of theses too alternatives:

  • As Àngel suggests, create two actions. Though it has the problem that it makes the interface more complex.
  • Always include children and prevent creating children on storage-type locations. I think this is the best option because it prevents the aforementioned problems.

Sometimes people understand a behaviour, sometimes they don’t.

I find the solution proposed by Cédric better:

But if we let people decide what is the value then the discussion about the default value is not relevant anymore.

There still need a good default value (which is the current one for me).

If the behavior of an action is different depending on the selection of items I would call that at least counterintuitive. I don’ t think it is appropriate to blame users for poor application design. I rather prefer to hear very closely to user reports to improve with repect to usability and acceptance.

Reading back the Issue 6627: Move._update_product_cost_price uses wrong quantity for computation - Tryton issue tracker and I think that the context switch does not make sense when more than one location is selected. So the switch should be visible for a single selection and forced to false and readonly when there are many.

When you say “switch” do you mean that the user should be allowed to choose if she wants to see only the stock of the current location only or the stock of all its children?

If I understand what you propose correctly, if the user selects two warehouses, Tryton will not allow the user to see the total stock of both locations?

Yes with a check box in the context of the view.

Indeed except if someone come up with a way to ensure that quantities are not summed multiple times.
Ex: all locations have no common children.