Metadata-Version: 2.1
Name: odoo-addon-account_move_requalify_bad_debt
Version: 16.0.1.0.1
Requires-Python: >=3.10
Requires-Dist: odoo>=16.0a,<16.1dev
Summary: Create requalification accounting entry from 43600000 to 69400000
Home-page: https://somconnexio.coop
License: AGPL-3
Author: Som Connexio
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 16.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Description-Content-Type: text/markdown

# Bad Debt Requalification

## Overview
This module allows accountants to create a requalification accounting entry that moves doubtful client balances from account **43600000 (Clients de cobrament dubtós)** to account **69400000 (Pèrdues per deteriorament de crèdits)**.

It is designed for Odoo 16 and follows standard OCA/Spanish accounting practices for bad debt provisions.

## Features
- Wizard launched from the **Account Move** list view.
- Automatic generation of a balancing journal entry:
  - Debit/Credit to **43600000** to cancel the original doubtful line.
  - Debit/Credit to **69400000** to record the loss.
- Automatic reconciliation between the original account move line and the newly created compensating line.
- Validation warnings for:
  - Missing moves selection.
  - Moves from different companies.
  - Missing accounts **43600000** or **69400000**.
  - Already reconciled lines.
- User-friendly notification showing moves created, lines reconciled, and total amounts in €.

## Configuration
No additional configuration is required. The module depends on `account` and searches for accounts with codes **43600000** and **69400000** in the active company.

## Usage
1. Go to **Invoicing / Accounting / Journal Entries**.
2. Select one or more posted moves that contain lines in account **43600000**.
3. From the action menu, choose **"Bad debt requalification entry to 694"**.
4. In the wizard, select a **Journal** (General type) and the **Date**.
5. Click **"Create move"**.
6. The new move will be posted and, where possible, the 436 lines will be reconciled.

## Architecture / Controllers
- **Model:** `requalify.bad.debt.wizard` (`TransientModel`)
- **Main Method:** `action_requalify()`
  - Creates an `account.move` of type `entry`.
  - Builds line dictionary (`line_vals`) dynamically based on the sign of each **436** line balance.
  - Posts the move.
  - Reconciles matching original vs. new lines by partner, name, and amounts.
  - Returns a `display_notification` action.
- **Views:**
  - `views/requalify_bad_debt_wizard_views.xml` - Wizard form.
  - `views/account_move_views.xml` - Server action bound to `account.move`.

## Security
- Access to the wizard is restricted to the group `account.group_account_invoice`.
- Defined in `security/ir.model.access.csv`.

## Testing
- Full coverage suite in `tests/test_requalify_bad_debt.py`.
- Test cases include:
  - Happy path with positive and negative balances.
  - Multiple moves aggregated into a single entry.
  - Warning validation (different companies, missing accounts, already reconciled lines).
  - Empty line selection.

## License
AGPL-3
