Skip to content

Commit b74d64f

Browse files
syera94HekkiMelody
authored andcommitted
[14.0][IMP] add compute in account_invoice_select_for_payment in case of paid
1 parent 81c6778 commit b74d64f

File tree

9 files changed

+93
-39
lines changed

9 files changed

+93
-39
lines changed

account_invoice_select_for_payment/README.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Account Invoice Select for Payment
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:7f0521f5bd10a5a9953ec03fcbcdd1887889a6a52c6c433fc19b732894322829
10+
!! source digest: sha256:402cb07f8fb5f2183d646b69cb90531aa0aeaf52f1b0de1d3dd731deb2717458
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
@@ -29,9 +29,11 @@ Account Invoice Select for Payment
2929
|badge1| |badge2| |badge3| |badge4| |badge5|
3030

3131
This module allows to mark invoices as "selected for payment". This can be done
32-
in the list view of invoices using a button in the first column of the view
32+
in the list view of invoices using a button in the first column of the view (which is optionnally hide)
3333
which shows the selection status. This selection persists until a payment is
3434
registered.
35+
It's also possible to choose if the invoice is to pay or not directly in the form viex of the invoice.
36+
When it's to pay, a ribbon appears.
3537

3638
.. IMPORTANT::
3739
This is an alpha version, the data model and design can change at any time without warning.
@@ -47,15 +49,17 @@ Usage
4749
=====
4850

4951
To mark an invoice as "selected for payment", click on the button before the
50-
Number column. This will change the state and change the way the button is
51-
displayed to a checked box.
52+
Number column. This will change the state and change the way the button is displayed to a checked box.
53+
It's also possible to choose if the invoice is to pay or not directly in the form viex of the invoice.
54+
When it's to pay, a ribbon appears.
5255

5356
When done, use the search filter "Selected for payment", and select all the
5457
lines to give access to the Actions menu, in which you can select "Register
5558
payment" to display the Payment wizard.
5659

57-
The selection is cleared when the wizard is displayed, whether the payment is
58-
done or not.
60+
The selection is cleared when the wizard is displayed, whether the payment is done or not.
61+
62+
This module is linked to the module account_payment_order_select_for_payment to be able to select in a payment order only the to pay invoices.
5963

6064
Bug Tracker
6165
===========
@@ -80,6 +84,8 @@ Contributors
8084

8185
* Alexandre Fayolle <[email protected]>
8286
* Hiep Nguyen Hoang <[email protected]>
87+
* Syera BONNEAUX <[email protected]>
88+
* florian Da Costa<[email protected]>
8389

8490
Other credits
8591
~~~~~~~~~~~~~
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
from . import account_move
2-
from . import account_payment
Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
# Copyright 2020 Camptocamp
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
33

4-
from odoo import fields, models
4+
from odoo import api, fields, models
55

66

77
class AccountMove(models.Model):
88
_inherit = "account.move"
99

10-
selected_for_payment = fields.Boolean("To Pay")
10+
selected_for_payment = fields.Boolean(
11+
string="To Pay",
12+
compute="_compute_selected_for_payment",
13+
readonly=False,
14+
store=True,
15+
tracking=True,
16+
)
1117

1218
def action_toggle_select_for_payment(self):
1319
selected = self.filtered(lambda rec: rec.selected_for_payment)
@@ -16,3 +22,15 @@ def action_toggle_select_for_payment(self):
1622
selected.write({"selected_for_payment": False})
1723
if unselected:
1824
unselected.write({"selected_for_payment": True})
25+
26+
@api.depends("payment_state")
27+
def _compute_selected_for_payment(self):
28+
for rec in self:
29+
if rec.payment_state == "paid":
30+
rec.selected_for_payment = False
31+
32+
def button_selected_for_payment(self):
33+
self.write({"selected_for_payment": True})
34+
35+
def button_not_selected_for_payment(self):
36+
self.write({"selected_for_payment": False})

account_invoice_select_for_payment/models/account_payment.py

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
* Alexandre Fayolle <[email protected]>
22
* Hiep Nguyen Hoang <[email protected]>
3+
* Syera BONNEAUX <[email protected]>
4+
* florian Da Costa<[email protected]>
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
This module allows to mark invoices as "selected for payment". This can be done
2-
in the list view of invoices using a button in the first column of the view
2+
in the list view of invoices using a button in the first column of the view (which is optionnally hide)
33
which shows the selection status. This selection persists until a payment is
44
registered.
5+
It's also possible to choose if the invoice is to pay or not directly in the form viex of the invoice.
6+
When it's to pay, a ribbon appears.
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
To mark an invoice as "selected for payment", click on the button before the
2-
Number column. This will change the state and change the way the button is
3-
displayed to a checked box.
2+
Number column. This will change the state and change the way the button is displayed to a checked box.
3+
It's also possible to choose if the invoice is to pay or not directly in the form viex of the invoice.
4+
When it's to pay, a ribbon appears.
45

56
When done, use the search filter "Selected for payment", and select all the
67
lines to give access to the Actions menu, in which you can select "Register
78
payment" to display the Payment wizard.
89

9-
The selection is cleared when the wizard is displayed, whether the payment is
10-
done or not.
10+
The selection is cleared when the wizard is displayed, whether the payment is done or not.
11+
12+
This module is linked to the module account_payment_order_select_for_payment to be able to select in a payment order only the to pay invoices.

account_invoice_select_for_payment/static/description/index.html

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,15 @@ <h1 class="title">Account Invoice Select for Payment</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:7f0521f5bd10a5a9953ec03fcbcdd1887889a6a52c6c433fc19b732894322829
370+
!! source digest: sha256:402cb07f8fb5f2183d646b69cb90531aa0aeaf52f1b0de1d3dd731deb2717458
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372372
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/bank-payment/tree/14.0/account_invoice_select_for_payment"><img alt="OCA/bank-payment" src="https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/bank-payment-14-0/bank-payment-14-0-account_invoice_select_for_payment"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/bank-payment&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>This module allows to mark invoices as “selected for payment”. This can be done
374-
in the list view of invoices using a button in the first column of the view
374+
in the list view of invoices using a button in the first column of the view (which is optionnally hide)
375375
which shows the selection status. This selection persists until a payment is
376-
registered.</p>
376+
registered.
377+
It’s also possible to choose if the invoice is to pay or not directly in the form viex of the invoice.
378+
When it’s to pay, a ribbon appears.</p>
377379
<div class="admonition important">
378380
<p class="first admonition-title">Important</p>
379381
<p class="last">This is an alpha version, the data model and design can change at any time without warning.
@@ -397,13 +399,14 @@ <h1 class="title">Account Invoice Select for Payment</h1>
397399
<div class="section" id="usage">
398400
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
399401
<p>To mark an invoice as “selected for payment”, click on the button before the
400-
Number column. This will change the state and change the way the button is
401-
displayed to a checked box.</p>
402+
Number column. This will change the state and change the way the button is displayed to a checked box.
403+
It’s also possible to choose if the invoice is to pay or not directly in the form viex of the invoice.
404+
When it’s to pay, a ribbon appears.</p>
402405
<p>When done, use the search filter “Selected for payment”, and select all the
403406
lines to give access to the Actions menu, in which you can select “Register
404407
payment” to display the Payment wizard.</p>
405-
<p>The selection is cleared when the wizard is displayed, whether the payment is
406-
done or not.</p>
408+
<p>The selection is cleared when the wizard is displayed, whether the payment is done or not.</p>
409+
<p>This module is linked to the module account_payment_order_select_for_payment to be able to select in a payment order only the to pay invoices.</p>
407410
</div>
408411
<div class="section" id="bug-tracker">
409412
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
@@ -426,6 +429,8 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
426429
<ul class="simple">
427430
<li>Alexandre Fayolle &lt;<a class="reference external" href="mailto:alexandre.fayolle&#64;camptocamp.com">alexandre.fayolle&#64;camptocamp.com</a>&gt;</li>
428431
<li>Hiep Nguyen Hoang &lt;<a class="reference external" href="mailto:hiepnh&#64;trobz.com">hiepnh&#64;trobz.com</a>&gt;</li>
432+
<li>Syera BONNEAUX &lt;<a class="reference external" href="mailto:syera.bonneaux&#64;akretion.com">syera.bonneaux&#64;akretion.com</a>&gt;</li>
433+
<li>florian Da Costa&lt;<a class="reference external" href="mailto:florian.dacosta&#64;akretion.com">florian.dacosta&#64;akretion.com</a>&gt;</li>
429434
</ul>
430435
</div>
431436
<div class="section" id="other-credits">

account_invoice_select_for_payment/views/account_move.xml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,51 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<odoo>
3+
4+
<record id="view_move_form" model="ir.ui.view">
5+
<field name="model">account.move</field>
6+
<field name="inherit_id" ref="account.view_move_form" />
7+
<field name="arch" type="xml">
8+
<button name="button_draft" position="after">
9+
<button
10+
name="button_selected_for_payment"
11+
string="To Pay"
12+
type="object"
13+
attrs="{'invisible' : ['|', '|', ('selected_for_payment', '=', True), ('payment_state', 'not in', ('not_paid', 'partial')), ('move_type', 'not in', ('in_invoice', 'out_refund'))]}"
14+
class="btn-primary"
15+
style="background-color:green"
16+
/>
17+
<button
18+
name="button_not_selected_for_payment"
19+
string="Not To Pay"
20+
type="object"
21+
attrs="{'invisible' : ['|', '|', ('selected_for_payment', '=', False), ('payment_state', 'not in', ('not_paid', 'partial')), ('move_type', 'not in', ('in_invoice', 'out_refund'))]}"
22+
class="btn-primary"
23+
style="background-color:grey"
24+
/>
25+
</button>
26+
<xpath expr="//sheet/widget[5]" position="after">
27+
<widget
28+
name="web_ribbon"
29+
title="To Pay"
30+
bg_color="bg-info"
31+
attrs="{'invisible': ['|',('selected_for_payment', '=', False), ('move_type', 'not in', ('in_invoice', 'out_refund'))]}"
32+
/>
33+
</xpath>
34+
<field name="partner_bank_id" position="after">
35+
<field name="selected_for_payment" invisible="1" />
36+
</field>
37+
</field>
38+
</record>
339
<record id="view_invoice_tree" model="ir.ui.view">
440
<field name="model">account.move</field>
541
<field name="inherit_id" ref="account.view_invoice_tree" />
642
<field name="arch" type="xml">
743
<field name="name" position="before">
844
<field
945
name="selected_for_payment"
10-
attrs="{'invisible': [('payment_state', '!=', 'not_paid') ]}"
46+
attrs="{'invisible': ['|',('payment_state', 'not in', ('not_paid', 'partial')), ('move_type', 'not in', ('in_invoice', 'out_refund'))]}"
1147
widget="toggle_button"
48+
optional="hide"
1249
/>
1350
</field>
1451
</field>

0 commit comments

Comments
 (0)