Skip to content

Commit

Permalink
Merge pull request #153 from coopiteasy/12.0-add-purchase_invoice_status
Browse files Browse the repository at this point in the history
[ADD] purchase_invoice_status
  • Loading branch information
Houssine BAKKALI authored Jan 31, 2021
2 parents 8acc2e2 + b2a052c commit 9ad3596
Show file tree
Hide file tree
Showing 10 changed files with 582 additions and 0 deletions.
61 changes: 61 additions & 0 deletions purchase_invoice_status/README.rst
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.
1 change: 1 addition & 0 deletions purchase_invoice_status/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions purchase_invoice_status/__manifest__.py
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,
}
1 change: 1 addition & 0 deletions purchase_invoice_status/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import purchase_order
63 changes: 63 additions & 0 deletions purchase_invoice_status/models/purchase_order.py
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"
4 changes: 4 additions & 0 deletions purchase_invoice_status/readme/CONTRIBUTORS.rst
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]>
2 changes: 2 additions & 0 deletions purchase_invoice_status/readme/DESCRIPTION.rst
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.
Loading

0 comments on commit 9ad3596

Please sign in to comment.