Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] stock: use float comparison to assign moves #32844

Closed
wants to merge 1 commit into from

Conversation

len-foss
Copy link
Contributor

We remove the remaining comparisons to use the precision rounding of the UoM.

opw 1969888
closes #32707
closes #32745

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Apr 19, 2019
@gdgellatly
Copy link
Contributor

@len-odoo

It seems strange, because the line of code that seems to cause the issue is untouched in the PR.

This is our temporary fix

class StockMove(models.Model):
    _inherit = "stock.move"

    def _update_reserved_quantity(self, *args, **kwargs):
        return float_round(
            super()._update_reserved_quantity(*args, **kwargs),
            precision_rounding=self.product_uom.rounding,
        )

We remove the remaining comparisons to use the precision rounding of the UoM.

opw 1969888
closes odoo#32707
closes odoo#32745
@robodoo robodoo added the CI 🤖 Robodoo has seen passing statuses label Apr 23, 2019
@len-foss
Copy link
Contributor Author

@gdgellatly AFAICT, the _update_reserved_quantity method of 'stock.move' is only called in _action_assign. Since then this fix makes all comparisons on the return value go by float_compare with the right rounding, this should have essentially the same effect as your temporary fix (except we don't modify the value).

I wonder though, is it mostly unrelated to the code and only a display issue?
Because in the view there is
decoration-danger="not is_done and reserved_availability < product_uom_qty
which is obviously never gonna work unless we change the value. Which your fix does.

@gdgellatly
Copy link
Contributor

gdgellatly commented Apr 23, 2019

@len-odoo to be honest I never looked at the screen (except when it was wrong). The reserved qty always displayed right on the stock move, wrong on the stock_move_line

I just deployed the fix then ran a shell script something like

p = env['stock.picking'].search(<some state clause, confirmed/waiting I think>).filtered(lambda s: all(s.move_ids.mapped('reserved_qty'))
len(p) # say 410
p.do_unreserve()
p.action_assign()
env.cr.commit()
p = env['stock.picking'].search(<some state clause>).filtered(lambda s: all(s.move_ids.mapped('reserved_qty'))
len(p) # 3

and moved on to the next problem. Never looked back.

EDIT: Although actually, that decoration would never trigger because reserved is always marginally greater the product_uom_qty

@len-foss len-foss requested a review from sle-odoo April 24, 2019 06:36
@sle-odoo
Copy link
Contributor

@len-odoo lgtm

@len-foss
Copy link
Contributor Author

Thank you Simon.
robodoo r+

@robodoo
Copy link
Contributor

robodoo commented Apr 24, 2019

Merged, thanks!

@len-foss len-foss deleted the 12.0-opw1969888-stck-len branch April 24, 2019 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI 🤖 Robodoo has seen passing statuses OE the report is linked to a support ticket (opw-...)
Projects
None yet
5 participants