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

backend: several issues related to the "stock out" endpoints #87

Merged
merged 4 commits into from
Sep 30, 2020

Conversation

guewen
Copy link

@guewen guewen commented Sep 25, 2020

See the commits for details

ref 1647

"check" doesn't really imply a side-effect and is confusing.
"split" describes better what it does (even if it doesn't always split,
the end goal is the same).
This is actually an issue in the core stock module, which is fixed
locally as it is much more likely to happen in shopfloor than any
other places (and the consequences if it happens in shopfloor have
no workaround, while you can still edit the move lines when it happens
on the UI).

Reported as odoo/odoo#58491
The details about the issue are there.

In short: calling _action_assign on a stock.move create/write package
levels which may in turn replace the "result_package_id" of a move line,
even if it was already set by a user.

To prevent this, we skip the package level sync when:

* any line related to the package has a result_package_id set
* any line related to the package has a qty_done set

Depending on the response of odoo to this issue, we may later remove
this commit partially or completely.
When we create a stock issue, create an inventory with the quantity
of units to keep. The quantity to keep is the quantity of products
which have been picked (qty_done > 0). To do so, we unreserve the move
lines in the location where qty_done == 0, so remain only the picked
ones, and when creating the inventory, we sum the move lines quantities.

As the state of a move line is a related to the move, we have to include
"partially_available" ones.

It is important to keep the domain on the state to exclude cancel and
done moves, and it should be more efficient to filter on
assigned/partially_available than to exclude all the others.

A scenario where it was observed is:

In a location, we have 2 packages:

* Pack1: 2 units
* Pack2: 100 units

We create a move for 100 units, it creates 2 move lines:

* 2 units from Pack1
* 98 units from Pack2

In the application, we scan Pack1, move only 1 unit to a destination
Bin. The next line is shown for the remaining unit of Pack1, we use the
"stock out" button.

At this point, what we expect:

* The inventory for Pack1 is created with 1 unit (to satisfy the first
  unit put in the destination Bin)

Before the correction:

* The inventory for Pack1 is created with 0 unit, because the move is
  "partially_available", so the move line for the picked unit is ignored.

I researched for other occurrences where we do not search for
"partially_available" on move lines and fixed them.
@guewen guewen force-pushed the 13.0-shopfloor-stock-out branch from c854cdb to 43d3d38 Compare September 25, 2020 09:45
@codecov-commenter
Copy link

codecov-commenter commented Sep 25, 2020

Codecov Report

Merging #87 into 13.0-shopfloor will increase coverage by 1.54%.
The diff coverage is 90.00%.

Impacted file tree graph

@@                Coverage Diff                 @@
##           13.0-shopfloor      #87      +/-   ##
==================================================
+ Coverage           91.06%   92.61%   +1.54%     
==================================================
  Files                  55       55              
  Lines                3972     3979       +7     
==================================================
+ Hits                 3617     3685      +68     
+ Misses                355      294      -61     
Impacted Files Coverage Δ
shopfloor/actions/inventory.py 95.16% <ø> (ø)
shopfloor/models/stock_picking.py 95.45% <85.71%> (-4.55%) ⬇️
shopfloor/models/stock_move_line.py 96.55% <100.00%> (ø)
shopfloor/services/checkout.py 95.99% <100.00%> (ø)
shopfloor/services/cluster_picking.py 94.04% <100.00%> (ø)
shopfloor/actions/message.py 92.00% <0.00%> (+2.66%) ⬆️
shopfloor/services/delivery.py 95.47% <0.00%> (+17.69%) ⬆️
shopfloor/services/scan_anything.py 100.00% <0.00%> (+33.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e07718...43d3d38. Read the comment docs.

Copy link
Member

@simahawk simahawk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by reading commit messages seems legit :)

@simahawk simahawk merged commit b6a8f59 into 13.0-shopfloor Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants