Skip to content

Commit

Permalink
Merge PR #1645 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by jbaudoux
  • Loading branch information
OCA-git-bot committed Oct 7, 2024
2 parents b1fe794 + fea6362 commit 1223131
Show file tree
Hide file tree
Showing 24 changed files with 1,054 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/stock_lot_on_hand_first/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,
)
100 changes: 100 additions & 0 deletions stock_lot_on_hand_first/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
=======================
Stock Lot On Hand First
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:702583c66821bb55337ff427c3ebd6a1ce0a7cc405484c8299973063f32f5e44
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |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%2Fstock--logistics--workflow-lightgray.png?logo=github
: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-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=16.0
:alt: Try me on Runboat

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

This module allows to display lots with a quantity on hand as first results
in the selection field of Detailed Operations (`stock.move.line`) in order
to avoid displaying old lots that are not in stock anymore.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Configuration
=============

On the Operations types (`stock.picking.type`) an extra checkbox will appear if
Use Existing Lots/Serial Numbers is selected, to allow reordering the results
appearing in the selection.

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:%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
~~~~~~~

* Camptocamp

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

* Akim Juillerat <akim.juillerat@camptocamp.com>
* Ricardo Almeida Soares <ricardo.almeidasoares@camptocamp.com>
* Felipe Vaqueriza de Benito <felipe.vaqueriza@factorlibre.com>

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

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/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.
1 change: 1 addition & 0 deletions stock_lot_on_hand_first/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions stock_lot_on_hand_first/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
{
"name": "Stock Lot On Hand First",
"summary": "Allows to display lots on hand first in M2o fields",
"version": "16.0.1.0.0",
"development_status": "Alpha",
"category": "Inventory/Inventory",
"website": "https://github.com/OCA/stock-logistics-workflow",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["grindtildeath"],
"license": "AGPL-3",
"installable": True,
"depends": ["base_view_inheritance_extension", "stock"],
"data": [
"views/stock_move_line.xml",
"views/stock_move.xml",
"views/stock_picking_type.xml",
"views/stock_picking.xml",
],
}
56 changes: 56 additions & 0 deletions stock_lot_on_hand_first/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_lot_on_hand_first
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-10 10:08+0000\n"
"PO-Revision-Date: 2024-07-10 12:12+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 3.0.1\n"

#. module: stock_lot_on_hand_first
#: model:ir.model.fields,field_description:stock_lot_on_hand_first.field_stock_move__display_lots_on_hand_first
#: model:ir.model.fields,field_description:stock_lot_on_hand_first.field_stock_picking__display_lots_on_hand_first
#: model:ir.model.fields,field_description:stock_lot_on_hand_first.field_stock_picking_type__display_lots_on_hand_first
msgid "Display Lots On Hand First"
msgstr "Mostrar lotes disponibles primero"

#. module: stock_lot_on_hand_first
#: model:ir.model,name:stock_lot_on_hand_first.model_stock_lot
msgid "Lot/Serial"
msgstr "Lote/Número de serie"

#. module: stock_lot_on_hand_first
#: model:ir.model,name:stock_lot_on_hand_first.model_stock_picking_type
msgid "Picking Type"
msgstr "Tipo de albarán"

#. module: stock_lot_on_hand_first
#: model:ir.model,name:stock_lot_on_hand_first.model_stock_move
msgid "Stock Move"
msgstr "Movimiento de existencias"

#. module: stock_lot_on_hand_first
#: model:ir.model,name:stock_lot_on_hand_first.model_stock_picking
msgid "Transfer"
msgstr "Albarán"

#. module: stock_lot_on_hand_first
#: model:ir.model.fields,help:stock_lot_on_hand_first.field_stock_move__display_lots_on_hand_first
#: model:ir.model.fields,help:stock_lot_on_hand_first.field_stock_picking__display_lots_on_hand_first
#: model:ir.model.fields,help:stock_lot_on_hand_first.field_stock_picking_type__display_lots_on_hand_first
msgid ""
"When marked, lots that do not have a quantity in stock will be displayed "
"last in the selection"
msgstr ""
"Cuando estén marcados, los lotes que no tengan una cantidad en stock se "
"mostrarán al final de la selección"
55 changes: 55 additions & 0 deletions stock_lot_on_hand_first/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_lot_on_hand_first
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-05 17:34+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: stock_lot_on_hand_first
#: model:ir.model.fields,field_description:stock_lot_on_hand_first.field_stock_move__display_lots_on_hand_first
#: model:ir.model.fields,field_description:stock_lot_on_hand_first.field_stock_picking__display_lots_on_hand_first
#: model:ir.model.fields,field_description:stock_lot_on_hand_first.field_stock_picking_type__display_lots_on_hand_first
msgid "Display Lots On Hand First"
msgstr "Visualizza i lotti disponibili per primi"

#. module: stock_lot_on_hand_first
#: model:ir.model,name:stock_lot_on_hand_first.model_stock_production_lot
msgid "Lot/Serial"
msgstr "Lotto/seriale"

#. module: stock_lot_on_hand_first
#: model:ir.model,name:stock_lot_on_hand_first.model_stock_picking_type
msgid "Picking Type"
msgstr "Tipologia prelievo"

#. module: stock_lot_on_hand_first
#: model:ir.model,name:stock_lot_on_hand_first.model_stock_move
msgid "Stock Move"
msgstr "Movimento di magazzino"

#. module: stock_lot_on_hand_first
#: model:ir.model,name:stock_lot_on_hand_first.model_stock_picking
msgid "Transfer"
msgstr "Trasferimento"

#. module: stock_lot_on_hand_first
#: model:ir.model.fields,help:stock_lot_on_hand_first.field_stock_move__display_lots_on_hand_first
#: model:ir.model.fields,help:stock_lot_on_hand_first.field_stock_picking__display_lots_on_hand_first
#: model:ir.model.fields,help:stock_lot_on_hand_first.field_stock_picking_type__display_lots_on_hand_first
msgid ""
"When marked, lots that do not have a quantity in stock will be displayed "
"last in the selection"
msgstr ""
"Quando impostato, i lotti che non hanno quantità a magazzino verranno "
"visualizzati alla fine della selezione"
50 changes: 50 additions & 0 deletions stock_lot_on_hand_first/i18n/stock_lot_on_hand_first.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_lot_on_hand_first
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_lot_on_hand_first
#: model:ir.model.fields,field_description:stock_lot_on_hand_first.field_stock_move__display_lots_on_hand_first
#: model:ir.model.fields,field_description:stock_lot_on_hand_first.field_stock_picking__display_lots_on_hand_first
#: model:ir.model.fields,field_description:stock_lot_on_hand_first.field_stock_picking_type__display_lots_on_hand_first
msgid "Display Lots On Hand First"
msgstr ""

#. module: stock_lot_on_hand_first
#: model:ir.model,name:stock_lot_on_hand_first.model_stock_production_lot
msgid "Lot/Serial"
msgstr ""

#. module: stock_lot_on_hand_first
#: model:ir.model,name:stock_lot_on_hand_first.model_stock_picking_type
msgid "Picking Type"
msgstr ""

#. module: stock_lot_on_hand_first
#: model:ir.model,name:stock_lot_on_hand_first.model_stock_move
msgid "Stock Move"
msgstr ""

#. module: stock_lot_on_hand_first
#: model:ir.model,name:stock_lot_on_hand_first.model_stock_picking
msgid "Transfer"
msgstr ""

#. module: stock_lot_on_hand_first
#: model:ir.model.fields,help:stock_lot_on_hand_first.field_stock_move__display_lots_on_hand_first
#: model:ir.model.fields,help:stock_lot_on_hand_first.field_stock_picking__display_lots_on_hand_first
#: model:ir.model.fields,help:stock_lot_on_hand_first.field_stock_picking_type__display_lots_on_hand_first
msgid ""
"When marked, lots that do not have a quantity in stock will be displayed "
"last in the selection"
msgstr ""
4 changes: 4 additions & 0 deletions stock_lot_on_hand_first/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import stock_move
from . import stock_picking
from . import stock_picking_type
from . import stock_lot
57 changes: 57 additions & 0 deletions stock_lot_on_hand_first/models/stock_lot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import api, models
from odoo.osv.expression import AND


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

@api.model
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.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_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.
# Since we cannot merge the Query objects to respect the intended order
# in which we want to display the results, we return the list of ids
# that will be used by browse in the name_search implementation.
return (
self.browse(with_quantity_ids).ids
+ self.browse(without_quantity_ids).ids
)

return super()._name_search(
name=name,
args=args,
operator=operator,
limit=limit,
name_get_uid=name_get_uid,
)
13 changes: 13 additions & 0 deletions stock_lot_on_hand_first/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from odoo import fields, models


class StockMove(models.Model):

_inherit = "stock.move"

display_lots_on_hand_first = fields.Boolean(
related="picking_type_id.display_lots_on_hand_first",
)
13 changes: 13 additions & 0 deletions stock_lot_on_hand_first/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from odoo import fields, models


class StockPicking(models.Model):

_inherit = "stock.picking"

display_lots_on_hand_first = fields.Boolean(
related="picking_type_id.display_lots_on_hand_first",
)
Loading

0 comments on commit 1223131

Please sign in to comment.