Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][IMP] add compute in account_invoice_select_for_payment in case of paid #1317

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions account_invoice_select_for_payment/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ Account Invoice Select for Payment
|badge1| |badge2| |badge3| |badge4| |badge5|

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
in the list view of invoices using a button in the first column of the view (which is optionnally hide)
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.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Expand All @@ -47,15 +49,17 @@ 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.
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 "Register
payment" to display the Payment wizard.

The selection is cleared when the wizard is displayed, whether the payment is
done or not.
The selection is cleared when the wizard is displayed, whether the payment is done or not.

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.

Bug Tracker
===========
Expand All @@ -80,6 +84,8 @@ Contributors

* Alexandre Fayolle <[email protected]>
* Hiep Nguyen Hoang <[email protected]>
* Syera BONNEAUX <[email protected]>
* florian Da Costa<[email protected]>

Other credits
~~~~~~~~~~~~~
Expand Down
1 change: 0 additions & 1 deletion account_invoice_select_for_payment/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from . import account_move
from . import account_payment
22 changes: 20 additions & 2 deletions account_invoice_select_for_payment/models/account_move.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -16,3 +22,15 @@
selected.write({"selected_for_payment": False})
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 == "paid":
rec.selected_for_payment = False

def button_selected_for_payment(self):
self.write({"selected_for_payment": True})

Check warning on line 33 in account_invoice_select_for_payment/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

account_invoice_select_for_payment/models/account_move.py#L33

Added line #L33 was not covered by tests

def button_not_selected_for_payment(self):
self.write({"selected_for_payment": False})

Check warning on line 36 in account_invoice_select_for_payment/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

account_invoice_select_for_payment/models/account_move.py#L36

Added line #L36 was not covered by tests
17 changes: 0 additions & 17 deletions account_invoice_select_for_payment/models/account_payment.py

This file was deleted.

2 changes: 2 additions & 0 deletions account_invoice_select_for_payment/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
* Alexandre Fayolle <[email protected]>
* Hiep Nguyen Hoang <[email protected]>
* Syera BONNEAUX <[email protected]>
* florian Da Costa<[email protected]>
4 changes: 3 additions & 1 deletion account_invoice_select_for_payment/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
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
in the list view of invoices using a button in the first column of the view (which is optionnally hide)
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.
10 changes: 6 additions & 4 deletions account_invoice_select_for_payment/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
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.
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 "Register
payment" to display the Payment wizard.

The selection is cleared when the wizard is displayed, whether the payment is
done or not.
The selection is cleared when the wizard is displayed, whether the payment is done or not.

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.
17 changes: 11 additions & 6 deletions account_invoice_select_for_payment/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,11 @@ <h1 class="title">Account Invoice Select for Payment</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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>
<p>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
in the list view of invoices using a button in the first column of the view (which is optionnally hide)
which shows the selection status. This selection persists until a payment is
registered.</p>
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.</p>
<div class="admonition important">
<p class="first admonition-title">Important</p>
<p class="last">This is an alpha version, the data model and design can change at any time without warning.
Expand All @@ -397,13 +399,14 @@ <h1 class="title">Account Invoice Select for Payment</h1>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>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.</p>
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.</p>
<p>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.</p>
<p>The selection is cleared when the wizard is displayed, whether the payment is
done or not.</p>
<p>The selection is cleared when the wizard is displayed, whether the payment is done or not.</p>
<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>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
Expand All @@ -426,6 +429,8 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Alexandre Fayolle &lt;<a class="reference external" href="mailto:alexandre.fayolle&#64;camptocamp.com">alexandre.fayolle&#64;camptocamp.com</a>&gt;</li>
<li>Hiep Nguyen Hoang &lt;<a class="reference external" href="mailto:hiepnh&#64;trobz.com">hiepnh&#64;trobz.com</a>&gt;</li>
<li>Syera BONNEAUX &lt;<a class="reference external" href="mailto:syera.bonneaux&#64;akretion.com">syera.bonneaux&#64;akretion.com</a>&gt;</li>
<li>florian Da Costa&lt;<a class="reference external" href="mailto:florian.dacosta&#64;akretion.com">florian.dacosta&#64;akretion.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
Expand Down
39 changes: 38 additions & 1 deletion account_invoice_select_for_payment/views/account_move.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,51 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="view_move_form" model="ir.ui.view">
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<button name="button_draft" position="after">
<button
name="button_selected_for_payment"
string="To Pay"
type="object"
attrs="{'invisible' : ['|', '|', ('selected_for_payment', '=', True), ('payment_state', 'not in', ('not_paid', 'partial')), ('move_type', 'not in', ('in_invoice', 'out_refund'))]}"
class="btn-primary"
style="background-color:green"
/>
<button
name="button_not_selected_for_payment"
string="Not To Pay"
type="object"
attrs="{'invisible' : ['|', '|', ('selected_for_payment', '=', False), ('payment_state', 'not in', ('not_paid', 'partial')), ('move_type', 'not in', ('in_invoice', 'out_refund'))]}"
class="btn-primary"
style="background-color:grey"
/>
</button>
<xpath expr="//sheet/widget[5]" position="after">
<widget
name="web_ribbon"
title="To Pay"
bg_color="bg-info"
attrs="{'invisible': ['|',('selected_for_payment', '=', False), ('move_type', 'not in', ('in_invoice', 'out_refund'))]}"
/>
</xpath>
<field name="partner_bank_id" position="after">
<field name="selected_for_payment" invisible="1" />
</field>
</field>
</record>
<record id="view_invoice_tree" model="ir.ui.view">
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_invoice_tree" />
<field name="arch" type="xml">
<field name="name" position="before">
<field
name="selected_for_payment"
attrs="{'invisible': [('payment_state', 'not in', ['not_paid', 'partial']) ]}"
attrs="{'invisible': ['|',('payment_state', 'not in', ('not_paid', 'partial')), ('move_type', 'not in', ('in_invoice', 'out_refund'))]}"
widget="toggle_button"
optional="hide"
/>
</field>
</field>
Expand Down
Loading