From 9c8f05cb0641a13750b6f43d5850e495a7284adb Mon Sep 17 00:00:00 2001
From: Florian da Costa
Date: Wed, 19 Mar 2025 16:03:28 +0100
Subject: [PATCH] [IMP] Remove the to pay mark on an invoice when it is fully
paid on in payment This way the module is usefull when the register payment
wizard is not used. It is a case when you use payment orders or even if you
reconcile your invoices from the bank statement for instance Also add a
button on form view to be able to mark the invoice as to pay when you are
checking what it is exactly
---
account_invoice_select_for_payment/README.rst | 9 ++++-
.../models/account_move.py | 16 +++++++-
.../readme/CONTRIBUTORS.md | 1 +
.../readme/DESCRIPTION.md | 2 +
.../readme/USAGE.md | 2 +
.../static/description/index.html | 9 ++++-
...test_account_invoice_select_for_payment.py | 29 +++++++++++++-
.../views/account_move.xml | 39 ++++++++++++++++++-
8 files changed, 99 insertions(+), 8 deletions(-)
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.