From 005062bf0a59c84c791acfa8fe655373cc188fbb Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Thu, 2 Apr 2026 13:37:01 +0700 Subject: [PATCH] feat: add PDF report and XLSX export functionality for backdated inventory adjustments and refine valuation logic --- README.md | 28 +++- __init__.py | 1 + __manifest__.py | 5 +- __pycache__/__init__.cpython-312.pyc | Bin 212 -> 242 bytes models/stock_inventory_backdate.py | 132 +++++++++++------- report/report_stock_inventory_backdate.xml | 70 ++++++++++ report/stock_inventory_backdate_reports.xml | 13 ++ security/ir.model.access.csv | 2 + views/stock_inventory_backdate_views.xml | 2 + wizard/__init__.py | 1 + wizard/stock_inventory_backdate_export.py | 92 ++++++++++++ .../stock_inventory_backdate_export_view.xml | 31 ++++ 12 files changed, 321 insertions(+), 56 deletions(-) create mode 100644 report/report_stock_inventory_backdate.xml create mode 100644 report/stock_inventory_backdate_reports.xml create mode 100644 wizard/__init__.py create mode 100644 wizard/stock_inventory_backdate_export.py create mode 100644 wizard/stock_inventory_backdate_export_view.xml diff --git a/README.md b/README.md index 773cae7..66dba58 100755 --- a/README.md +++ b/README.md @@ -44,12 +44,9 @@ This module allows you to create backdated inventory adjustments with a specific ### How It Works 1. When you validate a backdated adjustment, the module creates standard stock moves -2. After the moves are processed, it updates the dates via SQL to ensure proper backdating: - - Stock move `date` field - - Stock move line `date` field - - Stock valuation layer `create_date` field - - Account move `date` field (if real-time valuation is enabled) - - Account move `account_id` field: Overrides the interim account with `521301 Selisih Persediaan` for the non-valuation side of the entry. +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 @@ -63,6 +60,25 @@ This module allows you to create backdated inventory adjustments with a specific ## 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. diff --git a/__init__.py b/__init__.py index 0650744..9b42961 100755 --- a/__init__.py +++ b/__init__.py @@ -1 +1,2 @@ from . import models +from . import wizard diff --git a/__manifest__.py b/__manifest__.py index 3e3165c..846b930 100755 --- a/__manifest__.py +++ b/__manifest__.py @@ -1,7 +1,7 @@ { "name": "Stock Inventory Backdate", "summary": "Create backdated inventory adjustments with historical position view", - "version": "17.0.2.1.0", + "version": "17.0.2.5.1", "category": "Warehouse", "author": "Suherdy Yacob", "license": "AGPL-3", @@ -9,7 +9,10 @@ "data": [ "security/ir.model.access.csv", "data/sequence_data.xml", + "wizard/stock_inventory_backdate_export_view.xml", "views/stock_inventory_backdate_views.xml", + "report/stock_inventory_backdate_reports.xml", + "report/report_stock_inventory_backdate.xml", ], "installable": True, } diff --git a/__pycache__/__init__.cpython-312.pyc b/__pycache__/__init__.cpython-312.pyc index 7401036dc6154597849843735978c7ce91e1292c..128b35e7cf8efb791b6a3873170d362447c2cecd 100644 GIT binary patch delta 126 zcmcb@_=%DCG%qg~0}veJJ(sC9kyp}P2FRJtkiw9{n8T3E7{$m4Vlx5ROi@gX43*59 zEH4>>N;Da7vE}Bcq~;WZSml{jiA5=Xn#{KtikN}2MJyA8GGsY{ERfn_ZXof2nURt4 OE`!KD29Y9mARhn>-x}xu delta 96 zcmeywc!iPoG%qg~0}$BdJ7tPa + + + diff --git a/report/stock_inventory_backdate_reports.xml b/report/stock_inventory_backdate_reports.xml new file mode 100644 index 0000000..bdbffaa --- /dev/null +++ b/report/stock_inventory_backdate_reports.xml @@ -0,0 +1,13 @@ + + + + Inventory Backdate Report + stock.inventory.backdate + qweb-pdf + stock_inventory_backdate.report_inventory_backdate_template + stock_inventory_backdate.report_inventory_backdate + 'Inventory Adjustment - %s' % (object.name) + + report + + diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv index e81ae50..290ceb7 100755 --- a/security/ir.model.access.csv +++ b/security/ir.model.access.csv @@ -3,3 +3,5 @@ access_stock_inventory_backdate_user,stock.inventory.backdate.user,model_stock_i access_stock_inventory_backdate_line_user,stock.inventory.backdate.line.user,model_stock_inventory_backdate_line,stock.group_stock_user,1,1,1,1 access_stock_inventory_backdate_manager,stock.inventory.backdate.manager,model_stock_inventory_backdate,stock.group_stock_manager,1,1,1,1 access_stock_inventory_backdate_line_manager,stock.inventory.backdate.line.manager,model_stock_inventory_backdate_line,stock.group_stock_manager,1,1,1,1 +access_stock_inventory_backdate_export_wizard_user,stock.inventory.backdate.export.wizard,model_stock_inventory_backdate_export_wizard,stock.group_stock_user,1,1,1,1 +access_stock_inventory_backdate_export_wizard_manager,stock.inventory.backdate.export.wizard,model_stock_inventory_backdate_export_wizard,stock.group_stock_manager,1,1,1,1 diff --git a/views/stock_inventory_backdate_views.xml b/views/stock_inventory_backdate_views.xml index cf84f67..694bb97 100755 --- a/views/stock_inventory_backdate_views.xml +++ b/views/stock_inventory_backdate_views.xml @@ -26,6 +26,8 @@