feat: enable store=True for residual fields and add sum aggregation to list views
This commit is contained in:
parent
5888464802
commit
947de037a1
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
0
CHANGELOG.md
Normal file → Executable file
0
CHANGELOG.md
Normal file → Executable file
12
README.md
Normal file → Executable file
12
README.md
Normal file → Executable file
@ -8,6 +8,7 @@ This module adds residual amount display to customer and vendor payments in Odoo
|
||||
- **List View Integration**: Adds "Residual" column to payment list views (hidden by default)
|
||||
- **Form View Integration**: Displays residual amount in payment form view
|
||||
- **Multi-Currency Support**: Handles both company currency and payment currency residuals
|
||||
- **Aggregation Support**: Enables "sum" aggregation in list views and when grouping by any field (e.g., Partner, Journal)
|
||||
|
||||
## How It Works
|
||||
|
||||
@ -22,15 +23,17 @@ The module extends the `account.payment` model with a computed field that:
|
||||
## Fields Added
|
||||
|
||||
### `payment_residual`
|
||||
- **Type**: Monetary (computed)
|
||||
- **Type**: Monetary (computed, stored)
|
||||
- **Currency**: Payment currency
|
||||
- **Purpose**: Shows the residual amount not yet reconciled
|
||||
- **Aggregation**: Supports "sum" operator for totals and grouping
|
||||
- **Computation**: Based on `move_id.line_ids.amount_residual` and `amount_residual_currency`
|
||||
|
||||
### `payment_residual_currency`
|
||||
- **Type**: Monetary (computed)
|
||||
- **Type**: Monetary (computed, stored)
|
||||
- **Currency**: Payment currency
|
||||
- **Purpose**: Shows the residual amount in the payment's currency
|
||||
- **Aggregation**: Supports "sum" operator
|
||||
|
||||
## Usage
|
||||
|
||||
@ -46,6 +49,11 @@ The module extends the `account.payment` model with a computed field that:
|
||||
3. Shows 0.00 for fully reconciled payments
|
||||
4. Shows the remaining amount for partially reconciled payments
|
||||
|
||||
### Grouping and Aggregation
|
||||
1. In the payment list view, use the **Group By** filter (e.g., by **Partner** or **Journal**)
|
||||
2. The group headers will display the total sum of the residual amounts for each group
|
||||
3. The bottom of the list view displays the total residual for all visible records
|
||||
|
||||
## Technical Details
|
||||
|
||||
### Dependencies
|
||||
|
||||
0
__init__.py
Normal file → Executable file
0
__init__.py
Normal file → Executable file
3
__manifest__.py
Normal file → Executable file
3
__manifest__.py
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
{
|
||||
'name': 'Payment Residual Display',
|
||||
'version': '17.0.1.0.0',
|
||||
'version': '17.0.1.1.0',
|
||||
'category': 'Accounting',
|
||||
'summary': 'Display residual amounts in customer payment lines',
|
||||
'description': """
|
||||
@ -11,6 +11,7 @@
|
||||
- Shows residual amount in payment form view
|
||||
- Computes residual from journal items automatically
|
||||
- Helps identify partially reconciled payments
|
||||
- Supports aggregation and grouping by residual fields
|
||||
|
||||
See README.md for more details.
|
||||
""",
|
||||
|
||||
0
__pycache__/__init__.cpython-310.pyc
Normal file → Executable file
0
__pycache__/__init__.cpython-310.pyc
Normal file → Executable file
0
models/__init__.py
Normal file → Executable file
0
models/__init__.py
Normal file → Executable file
0
models/__pycache__/__init__.cpython-310.pyc
Normal file → Executable file
0
models/__pycache__/__init__.cpython-310.pyc
Normal file → Executable file
0
models/__pycache__/account_payment.cpython-310.pyc
Normal file → Executable file
0
models/__pycache__/account_payment.cpython-310.pyc
Normal file → Executable file
6
models/account_payment.py
Normal file → Executable file
6
models/account_payment.py
Normal file → Executable file
@ -12,7 +12,8 @@ class AccountPayment(models.Model):
|
||||
compute='_compute_payment_residual',
|
||||
currency_field='currency_id',
|
||||
help="Residual amount of this payment (amount not yet reconciled)",
|
||||
readonly=True
|
||||
readonly=True,
|
||||
store=True
|
||||
)
|
||||
|
||||
payment_residual_currency = fields.Monetary(
|
||||
@ -20,7 +21,8 @@ class AccountPayment(models.Model):
|
||||
compute='_compute_payment_residual',
|
||||
currency_field='currency_id',
|
||||
help="Residual amount in payment currency",
|
||||
readonly=True
|
||||
readonly=True,
|
||||
store=True
|
||||
)
|
||||
|
||||
@api.depends('move_id.line_ids.amount_residual',
|
||||
|
||||
2
views/account_payment_views.xml
Normal file → Executable file
2
views/account_payment_views.xml
Normal file → Executable file
@ -12,11 +12,13 @@
|
||||
widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
string="Residual"
|
||||
sum="Total Residual"
|
||||
optional="hide"/>
|
||||
<field name="payment_residual_currency"
|
||||
widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
string="Residual Currency"
|
||||
sum="Total Residual Currency"
|
||||
optional="hide"/>
|
||||
</field>
|
||||
</field>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user