-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from coopiteasy/12.0-add-purchase_invoice_status
[ADD] purchase_invoice_status
- Loading branch information
Showing
10 changed files
with
582 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
======================= | ||
Purchase Invoice Status | ||
======================= | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-coopiteasy%2Faddons-lightgray.png?logo=github | ||
:target: https://github.com/coopiteasy/addons/tree/12.0/purchase_invoice_status | ||
:alt: coopiteasy/addons | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
This module adds *partially paid* and *paid* options | ||
to the *Billing Status* (`invoice_status`) selection list of a purchase order. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/coopiteasy/addons/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/coopiteasy/addons/issues/new?body=module:%20purchase_invoice_status%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Coop IT Easy SCRLfs | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Coop IT Easy SCRLfs <https://coopiteasy.be>`__: | ||
|
||
* Vincent Van Rossem <[email protected]> | ||
* Houssine Bakkali <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is part of the `coopiteasy/addons <https://github.com/coopiteasy/addons/tree/12.0/purchase_invoice_status>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2020 - Today Coop IT Easy SCRLfs (<http://www.coopiteasy.be>) | ||
# - Vincent Van Rossem <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Purchase Invoice Status", | ||
"version": "12.0.1.0.0", | ||
"category": "Purchases", | ||
"license": "AGPL-3", | ||
"summary": "Add invoice status on purchase orders", | ||
"author": "Coop IT Easy SCRLfs,Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/purchase-workflow", | ||
"depends": ["purchase"], | ||
"data": ["views/purchase_order.xml"], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import purchase_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Copyright 2020 - Today Coop IT Easy SCRLfs (<http://www.coopiteasy.be>) | ||
# - Vincent Van Rossem <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
from odoo.tools.float_utils import float_compare, float_is_zero | ||
from odoo.tools.translate import _ | ||
|
||
|
||
class PurchaseOrder(models.Model): | ||
_inherit = "purchase.order" | ||
|
||
invoice_status = fields.Selection( | ||
selection_add=[ | ||
("partially_paid", _("Partially Paid")), | ||
("paid", _("Paid")), | ||
] | ||
) | ||
|
||
@api.depends( | ||
"state", | ||
"order_line.qty_invoiced", | ||
"order_line.qty_received", | ||
"order_line.product_qty", | ||
"invoice_ids.state", | ||
"invoice_ids.residual", | ||
"invoice_ids.amount_total", | ||
) | ||
def _get_invoiced(self): | ||
super()._get_invoiced() | ||
for order in self.filtered(lambda o: o.invoice_status in "invoiced"): | ||
if all(invoice.state in "paid" for invoice in order.invoice_ids): | ||
order.invoice_status = "paid" | ||
continue | ||
if any(invoice.state in "paid" for invoice in order.invoice_ids): | ||
order.invoice_status = "partially_paid" | ||
continue | ||
if all( | ||
invoice.state in ("open", "in_payment", "paid") | ||
and float_is_zero( | ||
invoice.residual, | ||
precision_rounding=invoice.currency_id.rounding, | ||
) | ||
for invoice in order.invoice_ids | ||
): | ||
order.invoice_status = "paid" | ||
elif any( | ||
invoice.state in ("open", "in_payment", "paid") | ||
and float_compare( | ||
invoice.residual, | ||
0.0, | ||
precision_rounding=invoice.currency_id.rounding, | ||
) | ||
== 1 # residual > 0 | ||
and float_compare( | ||
invoice.residual, | ||
invoice.amount_total, | ||
precision_rounding=invoice.currency_id.rounding, | ||
) | ||
== -1 # residual < amount_total | ||
for invoice in order.invoice_ids | ||
): | ||
order.invoice_status = "partially_paid" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* `Coop IT Easy SCRLfs <https://coopiteasy.be>`__: | ||
|
||
* Vincent Van Rossem <[email protected]> | ||
* Houssine Bakkali <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This module adds *partially paid* and *paid* options | ||
to the *Billing Status* (`invoice_status`) selection list of a purchase order. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.