product_lot_sequence_per_pr.../INSTALLATION.md

5.8 KiB

Installation and Upgrade Guide

Installation

1. Copy Module to Addons Directory

# Copy the module to your custom addons directory
cp -r product_lot_sequence_per_product /path/to/odoo/customaddons/

2. Update Addons List

# Restart Odoo and update the addons list
odoo-bin -c odoo.conf -d your_database -u all --stop-after-init

Or from the Odoo UI:

  • Go to Apps
  • Click "Update Apps List"
  • Search for "Product Lot Sequence Per Product"
  • Click Install

3. Verify Installation

Check the logs for successful installation:

INFO your_database odoo.modules.loading: Module product_lot_sequence_per_product loaded

Upgrading from Previous Version

Upgrade Steps

  1. Backup your database before upgrading:
pg_dump your_database > backup_before_upgrade.sql
  1. Update the module files:
cp -r product_lot_sequence_per_product /path/to/odoo/customaddons/
  1. Upgrade the module:
odoo-bin -c odoo.conf -d your_database -u product_lot_sequence_per_product --stop-after-init

Or from the Odoo UI:

  • Go to Apps
  • Remove "Apps" filter
  • Search for "Product Lot Sequence Per Product"
  • Click Upgrade

What's New in This Version

Performance Optimizations

  • Batch sequence allocation: Generates multiple lot numbers in a single database query
  • Batch lot creation: Creates all lots in one operation
  • Smart thresholds: Automatically uses optimized methods for quantities > 10
  • 8-10x speedup for large batches (500+ units)

New Features

  • Auto-generation in inventory adjustments: Automatically generates lot/serial numbers during physical inventory counts
  • Support for large quantities: Optimized for 500,000+ units
  • Comprehensive logging: Better visibility into lot generation operations

Technical Improvements

  • Added _allocate_sequence_batch() method for efficient sequence allocation
  • Enhanced stock.quant for inventory adjustment auto-generation
  • Improved stock.lot.create() with product grouping
  • Added comprehensive test suites

Migration Notes

No Breaking Changes

This upgrade is fully backward compatible. Existing functionality remains unchanged:

  • Existing sequences continue to work
  • No data migration required
  • No configuration changes needed

Automatic Optimization

The performance optimizations are automatically applied:

  • No configuration required
  • Transparent to users
  • Activates automatically for large quantities

New Behavior

The only new behavior is auto-generation in inventory adjustments:

  • Only applies to products with custom lot sequences configured
  • Only for inventory adjustments without existing lots
  • Can be disabled by not configuring custom sequences

Testing After Upgrade

1. Basic Functionality Test

# Test lot generation in receipt
picking = env['stock.picking'].create({...})
move = env['stock.move'].create({...})
# Generate lots and verify they use custom sequence

2. Performance Test

# Run performance tests
odoo-bin -c odoo.conf -d your_database --test-tags product_lot_sequence_per_product.performance

3. Inventory Adjustment Test

# Test auto-generation in inventory adjustment
quant = env['stock.quant'].create({
    'product_id': product.id,
    'location_id': location.id,
    'inventory_quantity': 100,
})
quant.action_apply_inventory()
# Verify lots were auto-generated

Rollback Procedure

If you need to rollback:

  1. Restore database backup:
psql your_database < backup_before_upgrade.sql
  1. Restore old module files:
cp -r product_lot_sequence_per_product.old /path/to/odoo/customaddons/product_lot_sequence_per_product
  1. Restart Odoo:
odoo-bin -c odoo.conf

Configuration

Setting Up Custom Sequences

  1. Navigate to Product:

    • Go to Inventory > Products
    • Open a product
  2. Configure Sequence:

    • Go to Inventory tab
    • Set "Custom Lot/Serial" field (e.g., "SN-" or "LOT-2024-")
    • The system automatically creates a sequence
  3. Verify Configuration:

    • Check "Next Number" field shows the next lot number
    • Test by creating a receipt or inventory adjustment

Performance Tuning

For very large operations (> 100,000 units):

  1. Database Configuration (postgresql.conf):
work_mem = 256MB
shared_buffers = 2GB
effective_cache_size = 6GB
  1. Odoo Configuration (odoo.conf):
workers = 4
max_cron_threads = 2
limit_memory_hard = 2684354560
limit_memory_soft = 2147483648
  1. Monitor Performance:
# Enable detailed logging
odoo-bin -c odoo.conf --log-level=info

Troubleshooting

Issue: Module Not Appearing in Apps List

Solution:

  1. Check module is in addons path
  2. Update apps list
  3. Check logs for errors

Issue: Slow Performance After Upgrade

Solution:

  1. Check database statistics are up to date:
VACUUM ANALYZE stock_lot;
VACUUM ANALYZE ir_sequence;
  1. Verify PostgreSQL configuration
  2. Check for concurrent operations

Issue: Lots Not Auto-Generating in Inventory Adjustments

Solution:

  1. Verify product has custom sequence configured
  2. Check product tracking is set to 'lot' or 'serial'
  3. Ensure inventory adjustment is for positive quantity
  4. Check logs for errors

Support

For issues or questions:

  1. Check the logs: odoo-bin -c odoo.conf --log-level=debug
  2. Review PERFORMANCE_OPTIMIZATION.md for detailed technical information
  3. Run test suite to verify functionality
  4. Check database configuration and performance

Version History

Version 1.1 (Current)

  • Added performance optimizations for large batches
  • Added auto-generation in inventory adjustments
  • Added comprehensive test suites
  • Added detailed documentation

Version 1.0

  • Initial release
  • Per-product sequence configuration
  • Support for receipts and manufacturing orders
  • UI enhancements