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: ensure reception report always uses quantity field #147815

Conversation

ticodoo
Copy link
Contributor

@ticodoo ticodoo commented Jan 2, 2024

Does a couple of small fixes

  • Removes some leftover post-quantitypocalypse field references that don't exist anymore for the reception report.

  • Also fix another bug where the unassign was keeping the incorrect link in the batch picking assign => individual picking unassign (wrong in stable too, but no one has complained since it's a rare use case so can be back-ported later if needed)

  • Removes obsolete force_detailed_view context reference from tests


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

@robodoo
Copy link
Contributor

robodoo commented Jan 2, 2024

Pull request status dashboard.

@C3POdoo C3POdoo requested a review from a team January 2, 2024 10:36
@C3POdoo C3POdoo added the RD research & development, internal work label Jan 2, 2024
Comment on lines 1707 to 1709
self.assertEqual(len(delivery.move_ids_without_package), 2, "Delivery moves should have split into assigned + not assigned")
self.assertEqual(len(delivery.move_ids_without_package.mapped('move_orig_ids')), 1, "Only 1 delivery + 1 receipt move should be assigned")
self.assertEqual(len(receipt.move_ids_without_package.mapped('move_dest_ids')), 1, "Receipt move should remain unsplit")
Copy link
Contributor

Choose a reason for hiding this comment

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

The mapped is not needed and I find the comment "Only 1 delivery + 1 receipt move should be assigned" not very helpful (I let a suggestion but feel free to not follow it)

Suggested change
self.assertEqual(len(delivery.move_ids_without_package), 2, "Delivery moves should have split into assigned + not assigned")
self.assertEqual(len(delivery.move_ids_without_package.mapped('move_orig_ids')), 1, "Only 1 delivery + 1 receipt move should be assigned")
self.assertEqual(len(receipt.move_ids_without_package.mapped('move_dest_ids')), 1, "Receipt move should remain unsplit")
self.assertEqual(len(delivery.move_ids_without_package), 2, "Delivery moves should have split into assigned + not assigned")
self.assertEqual(len(delivery.move_ids_without_package.move_orig_ids), 1, "Delivery move should be linked to 1 assigned receipt move")
self.assertEqual(len(receipt.move_ids_without_package.move_dest_ids), 1, "Receipt move should remain unsplit")

But I'm not sure, maybe checking records' values (qty and move's origin) instead is better to ensure the split was correctly done ?

Suggested change
self.assertEqual(len(delivery.move_ids_without_package), 2, "Delivery moves should have split into assigned + not assigned")
self.assertEqual(len(delivery.move_ids_without_package.mapped('move_orig_ids')), 1, "Only 1 delivery + 1 receipt move should be assigned")
self.assertEqual(len(receipt.move_ids_without_package.mapped('move_dest_ids')), 1, "Receipt move should remain unsplit")
self.assertRecordValues(delivery.move_ids_without_package, [
{'product_qty': incoming_qty, 'move_orig_ids': receipt.move_ids_without_package.ids},
{'product_qty': outgoing_qty - incoming_qty, 'move_orig_ids': []},
])
self.assertEqual(len(receipt.move_ids_without_package.move_dest_ids), 1, "Receipt move should remain unsplit")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, too fast with my copy paste for the mapped part (pushed this change already)

For your other suggestions, I don't think they're necessary. There are 2 delivery moves after the action_assign is called because it splits it between the linked qty and the not linked qty and then I check those values in the later asserts. I would prefer to avoid the test failing due to the order of the records changing since that part doesn't matter.

Since odoo#140898 the pickings detailed operation view has been
moved to a smart button instead of showing in a picking tab. This
included the removal of the `force_detailed_view` context since there
was no longer a detailed view to force show. This commit removes some
leftover references to this context within tests.
Following quantitypocalypse (odoo#137864), a couple of
`reserved_uom_qty` and `reserved_qty` references were left over. This
was partially due to no tests for these tricky parts of the code,
therefore we both fix these references to use the newer
`quantity`/`quantity_product_uom` fields and add/update tests to ensure
we avoid breaking these 2 use cases again.

Also discovered during this fix, the remaining assigned qtys when
unassigning done incoming moves from already reserved outgoing moves
(i.e. the "1. batch reserved + individual picking unreserved" use case
in the code comments) was NOT being calculated correctly. This also
fixes that + adds a test for it.
@ticodoo ticodoo force-pushed the 17.0-stock-fix-reception-report-qty-fields-tic branch from 3e45eac to c65d7d9 Compare January 2, 2024 17:39
@svs-odoo
Copy link
Contributor

svs-odoo commented Jan 3, 2024

robodoo r+

@robodoo
Copy link
Contributor

robodoo commented Jan 3, 2024

@ticodoo @svs-odoo linked pull request(s) odoo/enterprise#53536 not ready. Linked PRs are not staged until all of them are ready.

@robodoo
Copy link
Contributor

robodoo commented Jan 3, 2024

@ticodoo @svs-odoo because this PR has multiple commits, I need to know how to merge it:

  • merge to merge directly, using the PR as merge commit message
  • rebase-merge to rebase and merge, using the PR as merge commit message
  • rebase-ff to rebase and fast-forward

@svs-odoo
Copy link
Contributor

svs-odoo commented Jan 3, 2024

robodoo rebase-ff

@robodoo
Copy link
Contributor

robodoo commented Jan 3, 2024

Merge method set to rebase and fast-forward.

robodoo pushed a commit that referenced this pull request Jan 3, 2024
Since #140898 the pickings detailed operation view has been
moved to a smart button instead of showing in a picking tab. This
included the removal of the `force_detailed_view` context since there
was no longer a detailed view to force show. This commit removes some
leftover references to this context within tests.

Part-of: #147815
@robodoo robodoo closed this in 7e6b875 Jan 3, 2024
@fw-bot fw-bot deleted the 17.0-stock-fix-reception-report-qty-fields-tic branch January 17, 2024 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants