Replies: 5 comments 2 replies
-
|
@AmitEMV how do you suggest that the actual initial data is determined, via the calling function? Overall this makes sense, happy for you to submit a working PR and we can discuss further there |
Beta Was this translation helpful? Give feedback.
-
|
The current implementation has the advantage that the user is forced to do an active selection if there are more than one stockitem. It's not clear how you intend to implement the pre-selection logic but I belevie there are many use cases to handle. If the pre-selection logic is not very flexible and configurable I would appreciate at least a setting to keep the currrent functionality. |
Beta Was this translation helpful? Give feedback.
-
|
@SchrodingersGat Yes, the calling function determines what data has to be sent - the allocation modal just displays the data and auto-selects if there'a any. @gunstr Yes, there can be a System Setting to enable/disable this behaviour. Also, even if it's enabled, this |
Beta Was this translation helpful? Give feedback.
-
Another option would be to add a clear indication in the modal that there are multiple stock items and the system has made a decision. I do not know what options you have in mind for the pre-selection, but in our case the most common is to pick the stock item with the oldest batch code (we use YYWW, i.e Year/Week). However - we also have cases when a specific batch has to be be used for an assembly. If most parts have just one single stock item it would be important to highligt for the user that there are options that might require an active decision when that is not the case. I understand that with your suggestion the user can unselect and pick another item, but with the current solution the user is even forced to do that as the drop down is empty if there is more than one stock item. |
Beta Was this translation helpful? Give feedback.
-
|
@SchrodingersGat @gunstr what if we split this change in two: (1) make const unselectedItem = (item) => ({line_item: item.pk, quantity: 0, stock_item: null});
export function useAllocateToSalesOrderForm({
orderId,
shipmentId,
lineItems,
onFormSuccess,
getInitialData = (items) => items.map(unselectedItem),
}: {
orderId: number;
shipmentId?: number;
lineItems: any[];
onFormSuccess: (response: any) => void;
getInitialData?: (lineItems: any[]) => FieldValues[];
}) {
// ...
return useCreateApiFormModal({
// ...
initialData: getInitialData(lineItems),
});}This way, we can later make it so that a configuration or plugin can change the behavior of |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
In Allocate Stock modal today, the default selection of an item doesn't happen unless it's the only element in the dropdown. This specific section of code in
SalesOrderForms.tsxcurrently has -A change here can allow the items to be pre-selected in any specific way we want it. We can pass in the items which are oldest, newest or any other business rules that might make sense. The resulting code would be -
And we would do this to show this modal -
where
initDatahas this shapeWould this change be something that can be accepted here or any suggestions if not?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions