diff --git a/addons/account/views/account_portal_templates.xml b/addons/account/views/account_portal_templates.xml
index 1626b45aa36..a1c500185e0 100644
--- a/addons/account/views/account_portal_templates.xml
+++ b/addons/account/views/account_portal_templates.xml
@@ -38,7 +38,7 @@
Invoice # |
Invoice Date |
Due Date |
- Status | |
+ Status |
Amount Due |
@@ -53,7 +53,7 @@
|
|
-
+ |
Waiting for Payment
diff --git a/addons/account_payment/views/account_portal_templates.xml b/addons/account_payment/views/account_portal_templates.xml
index 6e5feb499e4..ed222c82aee 100644
--- a/addons/account_payment/views/account_portal_templates.xml
+++ b/addons/account_payment/views/account_portal_templates.xml
@@ -1,13 +1,13 @@
- | |
+ |
-
Pay Now
@@ -67,7 +67,7 @@
-
Pay Now
diff --git a/addons/payment/models/account_move.py b/addons/payment/models/account_move.py
index 4809263217d..b6a295b3fe5 100644
--- a/addons/payment/models/account_move.py
+++ b/addons/payment/models/account_move.py
@@ -15,6 +15,11 @@ class AccountMove(models.Model):
authorized_transaction_ids = fields.Many2many(
string="Authorized Transactions", comodel_name='payment.transaction',
compute='_compute_authorized_transaction_ids', readonly=True, copy=False)
+ amount_paid = fields.Monetary(
+ string="Amount paid",
+ help="The amount already paid for this invoice.",
+ compute='_compute_amount_paid'
+ )
@api.depends('transaction_ids')
def _compute_authorized_transaction_ids(self):
@@ -23,6 +28,17 @@ class AccountMove(models.Model):
lambda tx: tx.state == 'authorized'
)
+ @api.depends('transaction_ids')
+ def _compute_amount_paid(self):
+ """ Sum all the transaction amount for which state is in 'authorized' or 'done'
+ """
+ for invoice in self:
+ invoice.amount_paid = sum(
+ invoice.transaction_ids.filtered(
+ lambda tx: tx.state in ('authorized', 'done')
+ ).mapped('amount')
+ )
+
def get_portal_last_transaction(self):
self.ensure_one()
return self.with_context(active_test=False).transaction_ids._get_last()
| |