Repository navigation
Conversation
|
This PR has the |
|
@OCA/human-resources-maintainers we've been using this successfully in production for a couple of months now. Could you please take a look? Thanks! |
alexey-pelykh
left a comment
There was a problem hiding this comment.
The functional intent is sound -- showing serial/lot numbers on accepted equipment requests is useful. However, three issues need addressing:
- The
hr_personal_equipment_request/static/description/index.htmlchange is a regenerated README from a different module and should be dropped from this PR. - OCA convention requires a version bump in
__manifest__.pyfor IMP-type changes (e.g.,16.0.1.0.0->16.0.1.1.0). - No tests cover the new
lot_idsrelated field. At minimum, a test should verify the field is populated correctly when stock moves with lots are created via the equipment request flow.
9eb3142 to
58a99fb
Compare
marcos-mendez
left a comment
There was a problem hiding this comment.
Automated Review -- Tests Failed
1. Root Cause
The test failure occurs because the stock.move is not properly linked to the stock.lot records during the test setup. Specifically, the lot_ids field on the stock.move is not correctly assigned, leading to an inconsistency between allocation.lot_ids and allocation.move_ids.lot_ids.
2. Suggested Fix
In test_compute_qty_delivered and related tests, ensure that move.lot_ids is correctly assigned using the write method or by directly assigning the recordset to move.lot_ids. Also, in the test_action_cancel_without_qty_delivered, the assignment of move.lot_ids should be done correctly to reflect actual serial numbers used in the test.
File: hr_personal_equipment_stock/tests/test_hr_personal_equipment_stock.py
Lines: Around 175, 218, and 232
Change:
move.lot_ids = [lot_id.id for lot_id in lot_ids]to:
move.write({'lot_ids': [(6, 0, [lot_id.id for lot_id in lot_ids])]})This ensures the many2many relationship is properly written to the database.
3. Additional Code Issues
-
Missing error handling in
_create_lot_ids: The function assumesproduct.product_variant_idexists and is valid, but no check is performed. This could cause runtime errors ifproducthas no variants.Suggested fix:
if not product.product_variant_id: raise UserError("Product must have a variant to create lots.")
-
Potential performance issue in
_create_lot_ids: Creating many records in a loop without batching may cause performance degradation in large-scale tests.Suggested improvement:
Useself.env["stock.lot"].create()with a list of dictionaries for better performance.
4. Test Improvements
Add the following test cases to improve coverage:
- Test with product tracking = 'none': Ensure
lot_idsis empty when no tracking is enabled. - Test with multiple serial numbers per move: Validate that multiple lots can be assigned to a single move.
- Test
lot_idson cancelled moves: Confirm thatlot_idsare cleared when a move is cancelled. - Test with
lot_idsafter backorder creation: Ensure thatlot_idsare correctly propagated in backorders.
Use OCA patterns:
- Use
TransactionCasefor tests involving data creation and manipulation. - Tag tests using
@tag('post_install', 'manual')if they require installation steps. - Use
SavepointCasefor tests that need database isolation, especially when dealing withstock.moveandstock.lotrelationships.
Example:
@tag('post_install', 'manual')
def test_lot_ids_with_tracking_none(self):
self.product_personal_equipment_1.tracking = 'none'
self.personal_equipment_request.accept_request()
allocation = self.personal_equipment_request.line_ids[0]
self.assertFalse(allocation.lot_ids)This will ensure that the module behaves correctly under various tracking configurations.
⚠️ PR Aging Alert: CRITICAL
This PR by @anusriNPS has been waiting for 223 days — that is over 7 months without being merged or closed.
Every ignored PR is a contributor who might not come back. Review time matters. (OCA Aging Report)
Reciprocal Review Request
Hi everyone! I found some test failures on this PR and left detailed feedback above. I am happy to discuss or help debug. In the meantime, if any of you get a chance, I would appreciate a look at my open PR(s):
My open PRs across OCA:
- server-tools#3554 [MIG] datetime_formatter: Migration to 18.0
- server-tools#3548 [18.0][MIG] base_kanban_stage: Migration to 18.0
- hr-attendance#262 [16.0][ADD] Hr_attendance_idsecure: iDSecure (ControliD) attendance integration
- stock-logistics-workflow#2276 [16.0][ADD] stock_move_line_devaluation
- stock-logistics-workflow#2275 [16.0][ADD] Stock move line analytic account
- stock-logistics-workflow#2268 [16.0][ADD] stock_move_line_picking_partner
- purchase-workflow#2694 [16.0][IMP]Purchase workflow added to review state & exception fix
Reviewing each other's work helps the whole community move forward. Thank you!
Environment via OCA Neural Reviewer: Minikube + K8s Job + oca-ci/py3.10-odoo16.0 | Odoo 16.0
Automated review by OCA Neural Reviewer + qwen3-coder:30b
alexey-pelykh
left a comment
There was a problem hiding this comment.
Re-reviewing after the update — good progress:
- Stray
hr_personal_equipment_requestfile — ✅ Removed from the PR. All changes now scoped tohr_personal_equipment_stock. - Tests for
lot_ids— ✅ Comprehensive coverage added: lot creation helper, lot assignment verification on delivery, lot clearing on cancel, partial delivery with lots. Well done. - Version bump — Still missing. OCA convention requires bumping the minor version for IMP changes (e.g.,
16.0.1.0.0→16.0.1.1.0). Can be done at merge time if needed.
All CI green. The functional change and tests are solid.
Co-Reviewed-By: Claude Opus 4.6 (1M context) [email protected]
|
This PR has the |
58a99fb to
7bf9eae
Compare
|
Note: Using |
SirPyTech
left a comment
There was a problem hiding this comment.
Thanks for the PR!
I reviewed the code and tried it locally, everything looks good 👏
|
@OCA/human-resources-maintainers this has more than enough reviews, can someone please have a look? Thanks! |
7bf9eae to
7c8310f
Compare
936d66a to
d662ccb
Compare
SirPyTech
left a comment
There was a problem hiding this comment.
Thanks for implementing the simpler approach I proposed in PyTech-SRL#1 🙏
I only noticed a small issue (coming from my own proposal 😅), please check
d662ccb to
1023139
Compare
|
This PR has the |
c31d5a3 to
3f86f84
Compare
Originally posted by @Saran440 in #1497 (comment) This is ready from almost 2 months and has a bunch of approvals, please have a look, thanks! |
d0e40e9 to
d4d4b22
Compare
SirPyTech
left a comment
There was a problem hiding this comment.
Thanks for aligning this to the 18.0 version, I noticed one small change that is still missing, please check.
| ) | ||
| ) | ||
| for move in moves: | ||
| moved_qty = move.quantity_done |
There was a problem hiding this comment.
issue: Please convert the quantity as mentioned in #1643 (comment).
There was a problem hiding this comment.
Agree, while porting back refactored changes, missed to include quantity conversion
| lot = move_line.lot_id | ||
| if lot not in qty_by_lot: | ||
| qty_by_lot[lot] = 0 | ||
| moved_qty = move_line.qty_done |
There was a problem hiding this comment.
issue: Please convert the quantity as mentioned in #1643 (comment).
There was a problem hiding this comment.
Implemented quantity conversion as required
Display serial number under "Personal Equipment" Tab in Personal Equipment request form view when Personal Equipment Request is in "Accepted" state.
Using proper values for qty_delivered based on stock availability when a picking associated with allocation is validated/returned/scrapped.
Refactored computation method of qty_delivered and lot_ids to use common methods for same logic.
d4d4b22 to
e7a51b3
Compare
SirPyTech
left a comment
There was a problem hiding this comment.
Thanks!
I have suggested a few more changes in the 18.0 porting (#1643 (review)) but it's fine to keep them only in there.
| ) | ||
| ) | ||
| for move in moves: | ||
| moved_qty = move.quantity_done |
| lot = move_line.lot_id | ||
| if lot not in qty_by_lot: | ||
| qty_by_lot[lot] = 0 | ||
| moved_qty = move_line.qty_done |
|
This PR has the |
Display serial number under "Personal Equipment" Tab
in Personal Equipment request form view when Personal Equipment Request is in "Accepted" state.
lot_idsas computed field which helps to update serial number even when pickings are duplicated.qty_deliveredfield to be uptodate based on stock availability in PPE location which helps to avoid wrong field updation when an allocation is returned from pickings or pickings are duplicated.Included commit from 18.0 to backport refactored changes.