diff --git a/account_invoice_select_for_payment/README.rst b/account_invoice_select_for_payment/README.rst
index 3f06e66589c..7e6e44235bd 100644
--- a/account_invoice_select_for_payment/README.rst
+++ b/account_invoice_select_for_payment/README.rst
@@ -31,7 +31,9 @@ Account Invoice Select for Payment
This module allows to mark invoices as "selected for payment". This can
be done in the list view of invoices using a button in the first column
of the view which shows the selection status. This selection persists
-until a payment is registered.
+until a payment is registered. It's also possible to choose if the
+invoice is to pay or not directly in the form viex of the invoice. When
+it's to pay, a ribbon appears.
.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
@@ -48,7 +50,9 @@ Usage
To mark an invoice as "selected for payment", click on the button before
the Number column. This will change the state and change the way the
-button is displayed to a checked box.
+button is displayed to a checked box. It's also possible to choose if
+the invoice is to pay or not directly in the form viex of the invoice.
+When it's to pay, a ribbon appears.
When done, use the search filter "Selected for payment", and select all
the lines to give access to the Actions menu, in which you can select
@@ -81,6 +85,7 @@ Contributors
- Alexandre Fayolle
- Hiep Nguyen Hoang
- Khoi (Kien Kim)
+- Florian da Costa
Other credits
-------------
diff --git a/account_invoice_select_for_payment/models/account_move.py b/account_invoice_select_for_payment/models/account_move.py
index 1ed4725e85e..6900ac0856c 100644
--- a/account_invoice_select_for_payment/models/account_move.py
+++ b/account_invoice_select_for_payment/models/account_move.py
@@ -1,13 +1,19 @@
# Copyright 2020 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import fields, models
+from odoo import api, fields, models
class AccountMove(models.Model):
_inherit = "account.move"
- selected_for_payment = fields.Boolean("To Pay")
+ selected_for_payment = fields.Boolean(
+ string="To Pay",
+ compute="_compute_selected_for_payment",
+ readonly=False,
+ store=True,
+ tracking=True,
+ )
def action_toggle_select_for_payment(self):
selected = self.filtered(lambda rec: rec.selected_for_payment)
@@ -17,6 +23,12 @@ def action_toggle_select_for_payment(self):
if unselected:
unselected.write({"selected_for_payment": True})
+ @api.depends("payment_state")
+ def _compute_selected_for_payment(self):
+ for rec in self:
+ if rec.payment_state in ("in_payment", "paid", "reversed"):
+ rec.selected_for_payment = False
+
def action_register_payment(self):
invoices = self.filtered(lambda inv: inv.selected_for_payment)
if invoices:
diff --git a/account_invoice_select_for_payment/readme/CONTRIBUTORS.md b/account_invoice_select_for_payment/readme/CONTRIBUTORS.md
index a504f0d1bc4..1e12757155e 100644
--- a/account_invoice_select_for_payment/readme/CONTRIBUTORS.md
+++ b/account_invoice_select_for_payment/readme/CONTRIBUTORS.md
@@ -1,3 +1,4 @@
- Alexandre Fayolle \<\>
- Hiep Nguyen Hoang \<\>
- Khoi (Kien Kim) \<\>
+- Florian da Costa \<\>
diff --git a/account_invoice_select_for_payment/readme/DESCRIPTION.md b/account_invoice_select_for_payment/readme/DESCRIPTION.md
index 3695344999a..63680b10fa2 100644
--- a/account_invoice_select_for_payment/readme/DESCRIPTION.md
+++ b/account_invoice_select_for_payment/readme/DESCRIPTION.md
@@ -2,3 +2,5 @@ This module allows to mark invoices as "selected for payment". This can
be done in the list view of invoices using a button in the first column
of the view which shows the selection status. This selection persists
until a payment is registered.
+It's also possible to choose if the invoice is to pay or not directly in the form viex of the invoice.
+When it's to pay, a ribbon appears.
diff --git a/account_invoice_select_for_payment/readme/USAGE.md b/account_invoice_select_for_payment/readme/USAGE.md
index 34708c44cbe..98abba1d691 100644
--- a/account_invoice_select_for_payment/readme/USAGE.md
+++ b/account_invoice_select_for_payment/readme/USAGE.md
@@ -1,6 +1,8 @@
To mark an invoice as "selected for payment", click on the button before
the Number column. This will change the state and change the way the
button is displayed to a checked box.
+It's also possible to choose if the invoice is to pay or not directly in the form viex of the invoice.
+When it's to pay, a ribbon appears.
When done, use the search filter "Selected for payment", and select all
the lines to give access to the Actions menu, in which you can select
diff --git a/account_invoice_select_for_payment/static/description/index.html b/account_invoice_select_for_payment/static/description/index.html
index 4dc17d72815..1fca19d9140 100644
--- a/account_invoice_select_for_payment/static/description/index.html
+++ b/account_invoice_select_for_payment/static/description/index.html
@@ -373,7 +373,9 @@
Account Invoice Select for Payment
This module allows to mark invoices as “selected for payment”. This can
be done in the list view of invoices using a button in the first column
of the view which shows the selection status. This selection persists
-until a payment is registered.
+until a payment is registered. It’s also possible to choose if the
+invoice is to pay or not directly in the form viex of the invoice. When
+it’s to pay, a ribbon appears.
Important
This is an alpha version, the data model and design can change at any time without warning.
@@ -398,7 +400,9 @@
To mark an invoice as “selected for payment”, click on the button before
the Number column. This will change the state and change the way the
-button is displayed to a checked box.
+button is displayed to a checked box. It’s also possible to choose if
+the invoice is to pay or not directly in the form viex of the invoice.
+When it’s to pay, a ribbon appears.
When done, use the search filter “Selected for payment”, and select all
the lines to give access to the Actions menu, in which you can select
“Register payment” to display the Payment wizard.