[FIX] product_warranty: Fix installation error with return_instruction table
Summary
This PR fixes an installation error in the product_warranty module that occurs when the _get_default_instructions method tries to query the return_instruction table during field initialization, but the table doesn't exist yet.
Problem
During module installation, Odoo initializes model fields before all tables are created. The product.supplierinfo model has a return_instructions field with a default value computed by _get_default_instructions(), which tries to query the return_instruction table. This causes the following error:
psycopg2.errors.UndefinedTable: relation "return_instruction" does not exist
Solution
Wrap the search query in a try/except block to gracefully handle the missing table during installation by returning False instead of raising an exception. Once the installation completes and the table exists, the method works normally.
Testing
- Added comprehensive unit tests to verify the fix handles both installation and normal operation scenarios
- All existing tests pass
- Pre-commit hooks pass
- Module installs successfully with this fix
Test plan
- [x] Install the
product_warrantymodule on a fresh database - should install without errors - [x] Verify that default return instructions are properly set after installation
- [x] Run existing test suite to ensure no regression
- [x] New tests verify both error handling and normal operation
🤖 Generated with Claude Code