Skip to content

Commit

Permalink
[16.0][MIG] stock_lot_on_hand_first : Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FactorLibre committed Jul 8, 2024
1 parent 97a1a5f commit 6084629
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 27 deletions.
10 changes: 5 additions & 5 deletions stock_lot_on_hand_first/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Stock Lot On Hand First
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-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/15.0/stock_lot_on_hand_first
:target: https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_lot_on_hand_first
: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-15-0/stock-logistics-workflow-15-0-stock_lot_on_hand_first
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_lot_on_hand_first
: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/stock-logistics-workflow&target_branch=15.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -48,7 +48,7 @@ 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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_lot_on_hand_first%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_lot_on_hand_first%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.

Expand Down Expand Up @@ -87,6 +87,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-grindtildeath|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion stock_lot_on_hand_first/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"maintainers": ["grindtildeath"],
"license": "AGPL-3",
"installable": True,
"depends": ["stock_lot_product_qty_search", "base_view_inheritance_extension"],
"depends": ["base_view_inheritance_extension", "stock"],
"data": [
"views/stock_move_line.xml",
"views/stock_move.xml",
Expand Down
2 changes: 1 addition & 1 deletion stock_lot_on_hand_first/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import stock_move
from . import stock_picking
from . import stock_picking_type
from . import stock_production_lot
from . import stock_lot
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,39 @@
from odoo.osv.expression import AND


class ProductionLot(models.Model):
_inherit = "stock.production.lot"
class StockLot(models.Model):
_inherit = "stock.lot"

@api.model
def _name_search(self, name="", args=None, operator="ilike", limit=80):
def _name_search(
self, name="", args=None, operator="ilike", limit=80, name_get_uid=None
):
"""Move lots without a qty on hand at the end of the list"""

if self.env.context.get("name_search_qty_on_hand_first"):
args = list(args or [])

with_quantity_domain = AND([args, [("product_qty", ">", 0)]])
with_quantity_count = self.env["stock.production.lot"].search_count(
with_quantity_count = self.env["stock.lot"].search_count(
with_quantity_domain
)

if with_quantity_count >= limit:
args = with_quantity_domain
else:
with_quantity_ids = super()._name_search(
name=name, args=with_quantity_domain, operator=operator, limit=limit
name=name,
args=with_quantity_domain,
operator=operator,
limit=limit,
name_get_uid=name_get_uid,
)
without_quantity_ids = super()._name_search(
name=name,
args=AND([args, [("product_qty", "=", 0)]]),
operator=operator,
limit=limit - with_quantity_count,
name_get_uid=name_get_uid,
)
# _name_search is supposed to return a odoo.osv.query.Query object
# that will be evaluated as a list of ids when used in the browse function.
Expand All @@ -42,5 +49,9 @@ def _name_search(self, name="", args=None, operator="ilike", limit=80):
)

return super()._name_search(
name=name, args=args, operator=operator, limit=limit
name=name,
args=args,
operator=operator,
limit=limit,
name_get_uid=name_get_uid,
)
1 change: 0 additions & 1 deletion stock_lot_on_hand_first/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ class StockMove(models.Model):

display_lots_on_hand_first = fields.Boolean(
related="picking_type_id.display_lots_on_hand_first",
readonly=True,
)
1 change: 0 additions & 1 deletion stock_lot_on_hand_first/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ class StockPicking(models.Model):

display_lots_on_hand_first = fields.Boolean(
related="picking_type_id.display_lots_on_hand_first",
readonly=True,
)
1 change: 1 addition & 0 deletions stock_lot_on_hand_first/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* Akim Juillerat <akim.juillerat@camptocamp.com>
* Ricardo Almeida Soares <ricardo.almeidasoares@camptocamp.com>
* Felipe Vaqueriza de Benito <felipe.vaqueriza@factorlibre.com>
19 changes: 11 additions & 8 deletions stock_lot_on_hand_first/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand All @@ -9,10 +8,11 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Stock Lot On Hand First</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:702583c66821bb55337ff427c3ebd6a1ce0a7cc405484c8299973063f32f5e44
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/stock-logistics-workflow/tree/15.0/stock_lot_on_hand_first"><img alt="OCA/stock-logistics-workflow" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-workflow-15-0/stock-logistics-workflow-15-0-stock_lot_on_hand_first"><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/stock-logistics-workflow&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<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/stock-logistics-workflow/tree/16.0/stock_lot_on_hand_first"><img alt="OCA/stock-logistics-workflow" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_lot_on_hand_first"><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/stock-logistics-workflow&amp;target_branch=16.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 display lots with a quantity on hand as first results
in the selection field of Detailed Operations (<cite>stock.move.line</cite>) in order
to avoid displaying old lots that are not in stock anymore.</p>
Expand All @@ -396,7 +396,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_lot_on_hand_first%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_lot_on_hand_first%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -412,18 +412,21 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<ul class="simple">
<li>Akim Juillerat &lt;<a class="reference external" href="mailto:akim.juillerat&#64;camptocamp.com">akim.juillerat&#64;camptocamp.com</a>&gt;</li>
<li>Ricardo Almeida Soares &lt;<a class="reference external" href="mailto:ricardo.almeidasoares&#64;camptocamp.com">ricardo.almeidasoares&#64;camptocamp.com</a>&gt;</li>
<li>Felipe Vaqueriza de Benito &lt;<a class="reference external" href="mailto:felipe.vaqueriza&#64;factorlibre.com">felipe.vaqueriza&#64;factorlibre.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/grindtildeath"><img alt="grindtildeath" src="https://github.com/grindtildeath.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/tree/15.0/stock_lot_on_hand_first">OCA/stock-logistics-workflow</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_lot_on_hand_first">OCA/stock-logistics-workflow</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions stock_lot_on_hand_first/tests/test_lot_on_hand_first.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setUpClass(cls):

@classmethod
def _create_lot(cls, product, lot_name, qty=0):
lot = cls.env["stock.production.lot"].create(
lot = cls.env["stock.lot"].create(
{
"name": lot_name,
"product_id": product.id,
Expand All @@ -41,7 +41,7 @@ def test_lot_on_hand_first(self):
lot_5 = self._create_lot(self.product, "LOT-000005", 1)

name_get_res = (
self.env["stock.production.lot"]
self.env["stock.lot"]
.with_context(name_search_qty_on_hand_first=True)
.name_search(args=[("product_id", "=", self.product.id)])
)
Expand All @@ -63,7 +63,7 @@ def test_lot_on_hand_first_no_qty(self):
lot_3 = self._create_lot(self.product, "LOT-000003", 0)

name_get_res = (
self.env["stock.production.lot"]
self.env["stock.lot"]
.with_context(name_search_qty_on_hand_first=True)
.name_search(args=[("product_id", "=", self.product.id)])
)
Expand Down Expand Up @@ -105,7 +105,7 @@ def test_lot_on_hand_first_with_limit(self):
lot_10 = self._create_lot(self.product, "LOT-000010", 5)

name_get_res = (
self.env["stock.production.lot"]
self.env["stock.lot"]
.with_context(name_search_qty_on_hand_first=True)
.name_search(args=[("product_id", "=", self.product.id)], limit=8)
)
Expand Down

0 comments on commit 6084629

Please sign in to comment.