Skip to content

Commit

Permalink
[ADD] purchase_reception_status_line
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidJForgeFlow committed Oct 14, 2024
1 parent 8a98d52 commit 73cfa20
Show file tree
Hide file tree
Showing 14 changed files with 699 additions and 0 deletions.
100 changes: 100 additions & 0 deletions purchase_reception_status_line/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
==============================
Purchase Reception Status Line
==============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f4b1b4db3d01699868997506525d3b3e05eaf22dac85ccd43586bbb2ad9f758e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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-OCA%2Fpurchase--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/purchase-workflow/tree/15.0/purchase_reception_status_line
:alt: OCA/purchase-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/purchase-workflow-15-0/purchase-workflow-15-0-purchase_reception_status_line
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds a field *Reception Status* on purchase orders line.
On a confirmed purchase order line, it can have 3 different values:

* Nothing Received
* Partially Received
* Fully Received

Also takes this into account when computing the reception status for the
purchase order.

**Table of contents**

.. contents::
:local:

Usage
=====

If you are part of the *Purchase Manager* group, you can force a confirmed
purchase order to **Full Received** status: you have to check the field
**Force Received** located in the hidden fields on the
tree view (Order Lines tab).

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_reception_status_line%0Aversion:%2015.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
~~~~~~~

* ForgeFlow

Contributors
~~~~~~~~~~~~

* David Jiménez <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-DavidJForgeFlow| image:: https://github.com/DavidJForgeFlow.png?size=40px
:target: https://github.com/DavidJForgeFlow
:alt: DavidJForgeFlow

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-DavidJForgeFlow|

This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/15.0/purchase_reception_status_line>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions purchase_reception_status_line/__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_reception_status_line/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 ForgeFlow (http://www.akretion.com/)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Purchase Reception Status Line",
"version": "15.0.1.0.0",
"category": "Purchases",
"license": "AGPL-3",
"summary": "Add reception status on purchase order lines",
"author": "ForgeFlow,Odoo Community Association (OCA)",
"maintainers": ["DavidJForgeFlow"],
"website": "https://github.com/OCA/purchase-workflow",
"depends": ["purchase_reception_status"],
"data": ["views/purchase_order.xml"],
"installable": True,
}
2 changes: 2 additions & 0 deletions purchase_reception_status_line/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import purchase_order
from . import purchase_order_line
30 changes: 30 additions & 0 deletions purchase_reception_status_line/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2024 ForgeFlow (http://www.akretion.com/)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, models


class PurchaseOrder(models.Model):
_inherit = "purchase.order"

@api.depends(
"state", "force_received", "order_line.qty_received", "order_line.product_qty"
)
def _compute_reception_status(self):
result = super()._compute_reception_status()
for order in self.filtered(lambda po: po.reception_status != "received"):
status = order.reception_status
if order.state in ("purchase", "done"):
if all(
[line.reception_status == "received" for line in order.order_line]
):
status = "received"

Check warning on line 21 in purchase_reception_status_line/models/purchase_order.py

View check run for this annotation

Codecov / codecov/patch

purchase_reception_status_line/models/purchase_order.py#L21

Added line #L21 was not covered by tests
elif any(
[
line.reception_status in ["received", "partial"]
for line in order.order_line
]
):
status = "partial"
order.reception_status = status
return result
68 changes: 68 additions & 0 deletions purchase_reception_status_line/models/purchase_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Copyright 2024 ForgeFlow (http://www.akretion.com/)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models
from odoo.tools import float_compare


class PurchaseOrderLine(models.Model):
_inherit = "purchase.order.line"

reception_status = fields.Selection(
[
("no", "Nothing Received"),
("partial", "Partially Received"),
("received", "Fully Received"),
],
compute="_compute_reception_status",
store=True,
)
force_received = fields.Boolean(
readonly=False,
states={"draft": [("readonly", True)]},
compute="_compute_force_received",
store=True,
copy=False,
help="If true, the reception status will be forced to Fully Received, "
"even if some quantities are not fully received. ",
)

@api.depends("order_id.force_received")
def _compute_force_received(self):
prec = self.env["decimal.precision"].precision_get("Product Unit of Measure")
for rec in self:
if (
rec.order_id.force_received
and not float_compare(
rec.qty_received, rec.product_qty, precision_digits=prec
)
>= 0
):
rec.force_received = True

Check warning on line 41 in purchase_reception_status_line/models/purchase_order_line.py

View check run for this annotation

Codecov / codecov/patch

purchase_reception_status_line/models/purchase_order_line.py#L41

Added line #L41 was not covered by tests

@api.depends(
"state",
"force_received",
"qty_received",
"product_qty",
"order_id.force_received",
)
def _compute_reception_status(self):
prec = self.env["decimal.precision"].precision_get("Product Unit of Measure")
for line in self:
status = "no"
if line.order_id.state in ("purchase", "done"):
if line.force_received:
status = "received"

Check warning on line 56 in purchase_reception_status_line/models/purchase_order_line.py

View check run for this annotation

Codecov / codecov/patch

purchase_reception_status_line/models/purchase_order_line.py#L56

Added line #L56 was not covered by tests
elif (
float_compare(
line.qty_received, line.product_qty, precision_digits=prec
)
>= 0
):
status = "received"
elif float_compare(line.qty_received, 0, precision_digits=prec) > 0:
status = "partial"
line.reception_status = (
status if not line.order_id.force_received else "received"
)
1 change: 1 addition & 0 deletions purchase_reception_status_line/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* David Jiménez <[email protected]>
9 changes: 9 additions & 0 deletions purchase_reception_status_line/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This module adds a field *Reception Status* on purchase orders line.
On a confirmed purchase order line, it can have 3 different values:

* Nothing Received
* Partially Received
* Fully Received

Also takes this into account when computing the reception status for the
purchase order.
4 changes: 4 additions & 0 deletions purchase_reception_status_line/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
If you are part of the *Purchase Manager* group, you can force a confirmed
purchase order to **Full Received** status: you have to check the field
**Force Received** located in the hidden fields on the
tree view (Order Lines tab).
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 73cfa20

Please sign in to comment.