Skip to content
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
6 changes: 6 additions & 0 deletions setup/stock_picking_is_completed/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
108 changes: 108 additions & 0 deletions stock_picking_is_completed/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
==========================
Stock Picking Is Completed
==========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_picking_is_completed
:alt: OCA/stock-logistics-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_picking_is_completed
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/154/16.0
:alt: Try me on Runbot

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

This module adds a field on stock picking that will check if all movements have
been filled in by stock operator.

This is helpful to see if at least all lines of the picking have been treated.
The picking would not be marked as ready if some quantities stay at 0 (backorders) and
quantities are < the reserved one.

**Table of contents**

.. contents::
:local:

Usage
=====

#. On a picking, do the stock operations as normally, filling in the done quantities.
#. At least when the last operation is filled in with a quantity equal or greater
than the demand quantity, the field 'is_completed' == True and a green banner
is displayed on picking form side.

Known issues / Roadmap
======================

The 'is_completed' status field is not updated until picking is not saved.

This is due to how the framework is managing computed fields that are not
stored. In fact, the field on which we fill in the quantity is
'move_ids_without_package' and not 'move_line_ids' nor 'move_ids', so
the compute is not triggered.

It seems that adding it in the depends() solved the interface refresh when
we change the line quantity. But this introduces a warning in the log
as we depends on a non stored field ('move_ids_without_package').

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-workflow/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/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_picking_is_completed%0Aversion:%2016.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
~~~~~~~

* ACSONE SA/NV

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

* Denis Roussel <denis.roussel@acsone.eu>

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-rousseldenis| image:: https://github.com/rousseldenis.png?size=40px
:target: https://github.com/rousseldenis
:alt: rousseldenis

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

|maintainer-rousseldenis|

This module is part of the `OCA/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_picking_is_completed>`_ 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 stock_picking_is_completed/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions stock_picking_is_completed/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 ACSONE SA/NV
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

{
"name": "Stock Picking Is Completed",
"summary": """
This module adds a field on stock picking that will check if all movements
have been filled in by stock operator""",
"version": "16.0.1.0.0",
"license": "LGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"maintainers": ["rousseldenis"],
"website": "https://github.com/OCA/stock-logistics-workflow",
"depends": [
"stock",
],
"data": [
"views/stock_picking.xml",
],
}
1 change: 1 addition & 0 deletions stock_picking_is_completed/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_picking
96 changes: 96 additions & 0 deletions stock_picking_is_completed/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Copyright 2023 ACSONE SA/NV
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from odoo import api, fields, models
from odoo.osv.expression import NEGATIVE_TERM_OPERATORS
from odoo.tools import float_compare, float_is_zero


class StockPicking(models.Model):

_inherit = "stock.picking"

is_completed = fields.Boolean(
compute="_compute_is_completed",
search="_search_is_completed",
help="This field means if all picking operations have been done (each quantity is > 0)",
)

@api.depends(
"state",
"move_line_ids.qty_done",
"move_ids.quantity_done",
)
def _compute_is_completed(self):
"""
We must implement several fields value retrieval to allow a good behaviour on
form side as several fields can be filled in:
- move_line_ids.qty_done
- move_ids_without_package
"""
precision_digits = self.env["decimal.precision"].precision_get(
"Product Unit of Measure"
)
# We must use recordset (and not ids) as web interface can trigger this
# and record arrives here with NewId
ready_pickings = self.browse()
for picking in self.filtered(lambda picking: picking.state == "assigned"):
if all(
not float_is_zero(move_line.qty_done, precision_digits=precision_digits)
and float_compare(
move_line.qty_done,
move_line.reserved_uom_qty,
precision_digits=precision_digits,
)
>= 0
for move_line in picking.move_line_ids.filtered(
lambda m: m.state not in ("done", "cancel")
)
):
ready_pickings |= picking
elif all(
not float_is_zero(
move_id.quantity_done, precision_digits=precision_digits
)
and float_compare(
move_id.quantity_done,
move_id.product_uom_qty,
precision_digits=precision_digits,
)
>= 0
for move_id in picking.move_ids.filtered(
lambda m: m.state not in ("done", "cancel")
)
):
ready_pickings |= picking
ready_pickings.update({"is_completed": True})
(self - ready_pickings).update({"is_completed": False})

def _get_is_completed_domain(self):
return [
("move_ids.quantity_done", ">", 0),
("state", "=", "assigned"),
]

def _get_is_not_completed_domain(self):
"""
Limit the returned pickings to assigned ones when searching
in order to avoid performances problems.
In fact, with this filter, we want to display the assigned pickings
that have not been completed yet.
"""
return [
("move_ids.quantity_done", "=", 0),
("state", "=", "assigned"),
]

def _search_is_completed(self, operator, value):
negative = operator in NEGATIVE_TERM_OPERATORS

if (value and negative) or (not value and not negative):
pickings = self.search(self._get_is_not_completed_domain())
returned_pickings = pickings.filtered_domain([("is_completed", "=", False)])
else:
pickings = self.search(self._get_is_completed_domain())
returned_pickings = pickings.filtered_domain([("is_completed", "=", True)])

return [("id", "in", returned_pickings.ids)]
1 change: 1 addition & 0 deletions stock_picking_is_completed/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Denis Roussel <denis.roussel@acsone.eu>
6 changes: 6 additions & 0 deletions stock_picking_is_completed/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module adds a field on stock picking that will check if all movements have
been filled in by stock operator.

This is helpful to see if at least all lines of the picking have been treated.
The picking would not be marked as ready if some quantities stay at 0 (backorders) and
quantities are < the reserved one.
10 changes: 10 additions & 0 deletions stock_picking_is_completed/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
The 'is_completed' status field is not updated until picking is not saved.

This is due to how the framework is managing computed fields that are not
stored. In fact, the field on which we fill in the quantity is
'move_ids_without_package' and not 'move_line_ids' nor 'move_ids', so
the compute is not triggered.

It seems that adding it in the depends() solved the interface refresh when
we change the line quantity. But this introduces a warning in the log
as we depends on a non stored field ('move_ids_without_package').
4 changes: 4 additions & 0 deletions stock_picking_is_completed/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#. On a picking, do the stock operations as normally, filling in the done quantities.
#. At least when the last operation is filled in with a quantity equal or greater
than the demand quantity, the field 'is_completed' == True and a green banner
is displayed on picking form side.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading