Skip to content

Commit

Permalink
Merge PR #1742 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by jbaudoux
  • Loading branch information
OCA-git-bot committed Nov 6, 2024
2 parents 04d984b + 3c38448 commit c95bb9f
Show file tree
Hide file tree
Showing 24 changed files with 1,070 additions and 0 deletions.
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:a64ae71105a445729ca822e435e9143ffe5e9b425677a11806d72a7fd2a2efb6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/17.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-17-0/stock-logistics-workflow-17-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=17.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:%2017.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 <[email protected]>
- Ricardo Almeida Soares <[email protected]>
- Felipe Vaqueriza de Benito <[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-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/17.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": "17.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 <[email protected]>\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_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 16.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_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 ""
5 changes: 5 additions & 0 deletions stock_lot_on_hand_first/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import stock_move
from . import stock_move_line
from . import stock_picking
from . import stock_picking_type
from . import stock_lot
55 changes: 55 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,55 @@
# 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, domain=None, operator="ilike", limit=None, order=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"):
domain = list(domain or [])

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

if with_quantity_count >= limit:
domain = with_quantity_domain
else:
with_quantity_ids = super()._name_search(
name=name,
domain=with_quantity_domain,
operator=operator,
limit=limit,
order=order,
)
without_quantity_ids = super()._name_search(
name=name,
domain=AND([domain, [("product_qty", "=", 0)]]),
operator=operator,
limit=limit - with_quantity_count,
order=order,
)
# _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,
domain=domain,
operator=operator,
limit=limit,
order=order,
)
12 changes: 12 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,12 @@
# 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",
)
12 changes: 12 additions & 0 deletions stock_lot_on_hand_first/models/stock_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2024 360ERP (<https://www.360erp.com>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from odoo import fields, models


class StockMoveLine(models.Model):
_inherit = "stock.move.line"

display_lots_on_hand_first = fields.Boolean(
related="move_id.display_lots_on_hand_first",
)
12 changes: 12 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,12 @@
# 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 c95bb9f

Please sign in to comment.