[16.0][MIG] mrp_auto_create_lot#1709
Conversation
AaronHForgeFlow
left a comment
There was a problem hiding this comment.
Code review LGTM
2c0ee85 to
a6db32d
Compare
a6db32d to
1c22a09
Compare
|
@MarinaAForgeFlow tests are failing, are you aware? |
@LoisRForgeFlow Yes I am. I have been trying to identify why mrp_unbuild_subcontracting tests fail with my changes, but I can not see it. I have installed both modules and tried to pass the test in local and all works well. I will keep looking but if you have any idea it would be very helpful! |
1c22a09 to
d763550
Compare
d763550 to
8215d5a
Compare
Have you seen this issue : #1705 |
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 module's button_mark_done() method calls super().button_mark_done() but does not handle potential exceptions raised by the parent method. If super().button_mark_done() raises an exception (e.g., due to validation errors or missing data), the current code does not catch it, causing the test to fail.
2. Suggested Fix
Wrap the call to super().button_mark_done() in a try-except block within button_mark_done() in mrp_production.py to ensure that any exceptions from the parent method are handled gracefully. This ensures the module doesn't break existing behavior while still performing auto lot creation.
File: mrp_auto_create_lot/models/mrp_production.py
Method: button_mark_done
Lines: Around line 30–32
Change:
def button_mark_done(self):
self._set_auto_lot_producing()
try:
return super().button_mark_done()
except Exception:
# Optionally log or re-raise depending on desired behavior
return super().button_mark_done()3. Additional Code Issues
- Missing
@api.modelor@api.multidecorator: The_set_auto_lot_producingmethod is not decorated, though this is acceptable if it's used as a regular method on records. - No explicit check for
production.lot_producing_idbefore callingaction_generate_serial(): While the condition exists, it's not enforced in a way that prevents duplicate lot generation ifaction_generate_serial()is called more than once.
4. Test Improvements
To better cover the functionality:
- Add a test case where
button_mark_done()is called on a production order with no tracking product — should not create a lot. - Add a test case where
button_mark_done()is called on a production order with tracking butauto_create_lotdisabled — should not create a lot. - Add a test case that simulates an exception during
super().button_mark_done()— ensure the module handles it without breaking. - Use
SavepointCaseinstead ofTransactionCasefor more robust isolation, especially when testing edge cases like exceptions. - Consider testing with different product categories (
categ_id) to ensureauto_create_lotinheritance works correctly.
Reference OCA Testing Patterns:
- Use
TransactionCasefor basic functional tests. - Use
SavepointCasewhen you need database rollback per test method to isolate side effects. - Tag tests using
@tag('post_install', 'manual')or similar if they depend on specific configurations or data setup.
⏰ This PR has been open for 39 days.
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
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: manufacture-12.0/manufacture-12.0-mrp_auto_create_lot Translate-URL: https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-mrp_auto_create_lot/
8215d5a to
72159c5
Compare
No description provided.