Vauxoo / addons-vauxoo

All our modules related to developments that solves generic issues on Odoo, or that solve internal problems on Odoo Core, if something is here, maybe it is solving an issue in your company, try it and report what you see.
http://www.vauxoo.com
193 stars 288 forks source link

[IMP] stock_by_warehouse_sale: Fix big performance overhead #1358

Closed moylop260 closed 5 years ago

moylop260 commented 5 years ago

Try me on Runbot

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 the new button to fill the widget data.

moylop260 commented 5 years ago

@JulioSerna @hugho-ad @suniagajose @nhomar Could you check it, please?

JulioSerna commented 5 years ago

👍 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

hugho-ad commented 5 years ago

Grate Job Moy LGTM :+1:

luisg123v commented 4 years ago

@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

moylop260 commented 4 years ago

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?

moylop260 commented 4 years ago

@luisg123v Could you check if is possible get the computed value without edit permission for product form view, please?