Closed moylop260 closed 5 years ago
@JulioSerna @hugho-ad @suniagajose @nhomar Could you check it, please?
👍 LGTM
the only change of behavior in the original way is that the button(toggle_button) must be pressed when the sale order is already created if you want to see the current inventory in that sale order line
Grate Job Moy LGTM :+1:
@moylop260
I understand why this solution.. However, I don't fully agree with, you have more context for sure, tough.
The problem:
Since you're relying on an onchange to compute the widget value, it only works when the record is on edit mode. That's because onchanges are not triggered otherwise.
Proposed solution:
AFAIK, the boolean field is not even required. A button could trigger the action to recompute, without needing any field:
<button name="compute_warehouses_stock"
type="object"
icon="fa-circle"
groups="stock.group_stock_multi_warehouses"/>
Did you consider that approach?
CC @yaniaular
If you are talking about product form view, I agree! In fact, it were a pending task.
But for [sale|purchase]_order is better the onchange
Could you create the PR for 11.0, please?
@luisg123v
Could you check if is possible get the computed value without edit
permission for product form view, please?
Current behavior before PR:
We need avoid using compute fields as possible because of the following issue:
Before of this commit editing just one product:
production pyflame profiling the black rectangles are of
stock_by_warehouse...
modules:Desired behavior after PR is merged:
With this change we have the same behaviour using it just for onchange product_id or forcing from a seudo-button (field boolean) A real button is not used since that it requires save the record to work
Using the technical of fields with store=False and onchange methods Dummy PR:
Check the following video testing it:
Considerations:
We have changed the computed to field computed on-demand or product_id onchange then we have a little change of functionality. 1) For sale and purchase form view the widget data is filled from onchange but If you open an exists sale.order.line and you like to fill the widget data (without onchange) then you need use
EDIT
button and press thenew button
to fill the widget data.new button
to fill widget data.