stock_inventory_backdate/README.md

108 lines
4.5 KiB
Markdown
Executable File

# Stock Inventory Backdate
## Overview
This module allows you to create backdated inventory adjustments with a specific date and time. Unlike the standard Odoo inventory adjustment, this module creates stock moves with the exact backdated datetime you specify.
## Features
- **Dedicated Backdated Adjustment Form**: Separate interface for creating backdated inventory adjustments
- **Historical Inventory Position**: View the theoretical inventory quantity at the backdated time
- **Full Datetime Support**: Specify both date and time for the adjustment
- **Proper Backdating**: All related records (stock moves, move lines, valuation layers, and account moves) are backdated correctly
- **Multi-line Support**: Adjust multiple products in a single backdated adjustment
- **Lot/Serial Number Support**: Handle products with lot/serial number tracking
- **Package & Owner Support**: Support for advanced tracking features
## Usage
### Creating a Backdated Inventory Adjustment
1. Go to **Inventory > Operations > Backdated Adjustments**
2. Click **Create**
3. Set the **Adjustment Date & Time** to the desired backdate
4. Select the **Location** where you want to adjust inventory
**Option A: Load All Products**
5. Click **Load Products** to automatically load all products with inventory at that location
- The system will calculate the theoretical quantity at the backdated time for each product
6. Adjust the **Counted Quantity** for each product as needed
7. The **Difference** column shows what will be adjusted
8. Click **Validate** to create the backdated stock moves
**Option B: Add Individual Products**
5. In the **Inventory Lines** tab, click **Add a line**
6. Select the **Product** you want to adjust
- The system will automatically calculate the **Theoretical Quantity** at the backdated time
7. Enter the **Counted Quantity**
- The **Difference** is calculated automatically
8. Add more products as needed
9. Click **Validate** to create the backdated stock moves
## Technical Details
### How It Works
1. When you validate a backdated adjustment, the module creates standard stock moves
2. The system performs a **Physical Stock Adjustment Only**.
3. After the moves are processed, it updates the dates via SQL for the moves and lines to ensure proper backdating.
4. Any generated `stock.valuation.layer` or `account.move` (accounting) records are automatically **removed** to ensure no financial impact.
### Models
- **stock.inventory.backdate**: Main model for backdated adjustments
- **stock.inventory.backdate.line**: Individual product lines in the adjustment
### Security
- Stock Users can create, read, update, and delete backdated adjustments
- Stock Managers have full access
## Version History
### Version 17.0.2.5.1
- Added **PDF Report** for backdated inventory adjustments.
- Added **XLSX Export** feature using `xlsxwriter`.
- Fixed module initialization and updated XML syntax for **Odoo 17** compatibility.
### Version 17.0.2.4.0
- Refactored to **Selective Valuation**: Adjustment now generates its primary journal entry, but side-effect "Revaluation" layers are strictly suppressed.
- This ensures the BIA itself is visible in accounting while preventing doubling/tripling of journal entries on other moves.
### Version 17.0.2.3.0
- Implemented comprehensive **Valuation Bypass** via Odoo context.
- Prevents both primary valuation layers and **recursive revaluation side-effects** on other moves.
- Guarantees strictly **Physical Stock Only** adjustments even with automated valuation enabled.
### Version 17.0.2.2.0
- Changed logic to perform **Physical Stock Adjustments Only**.
- Automatically removes `stock.valuation.layer` and `account.move` records after validation to ensure no financial impact.
- Ideal for correcting stock levels without affecting accounting.
### Version 17.0.2.1.0
- Refactored validation logic to use batch processing for improved performance and reliability.
- Fixed uniqueness constraint conflicts on account moves by optimizing the sequence of operations.
- Enhanced SQL error handling for products without automated valuation.
### Version 17.0.2.0.0
- Complete redesign with dedicated backdated adjustment form
- Proper backdating of all related records
- Historical inventory position calculation
- Support for lot/serial numbers, packages, and owners
### Version 17.0.1.1.0
- Changed fields from Date to Datetime
- Added time support to inventory adjustments
### Version 17.0.1.0.0
- Initial release
- Basic backdating functionality
## Author
Suherdy Yacob
## License
AGPL-3