Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncing from upstream OCA/stock-logistics-workflow (16.0) #1082

Merged
merged 14 commits into from
Jan 22, 2024
Merged
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ addon | version | maintainers | summary
[stock_lot_scrap](stock_lot_scrap/) | 16.0.1.0.0 | | This module adds a button in Production Lot/Serial Number view form to Scrap all products contained.
[stock_move_free_reservation_reassign](stock_move_free_reservation_reassign/) | 16.0.1.0.1 | | Try to reassign a move when its reservation is removed due to the related quant becoming unavailable
[stock_move_line_auto_fill](stock_move_line_auto_fill/) | 16.0.1.1.0 | | Stock Move Line auto fill
[stock_move_line_expiration_date_required](stock_move_line_expiration_date_required/) | 16.0.1.0.1 | | Stock Move Line Expiration Date Required
[stock_move_line_reserved_quant](stock_move_line_reserved_quant/) | 16.0.1.0.0 | [![rousseldenis](https://github.com/rousseldenis.png?size=30px)](https://github.com/rousseldenis) | This module allows to get the link from a stock move line to the reserved quant
[stock_move_line_serial_unique](stock_move_line_serial_unique/) | 16.0.1.0.0 | | Stock Move Line Serial Unique
[stock_move_manage_priority](stock_move_manage_priority/) | 16.0.1.0.0 | | Stock Move Priority Management
[stock_move_propagate_first_move](stock_move_propagate_first_move/) | 16.0.1.0.1 | | This addon propagate the picking type of the original move to all next moves created from procurement
[stock_no_negative](stock_no_negative/) | 16.0.1.0.2 | | Disallow negative stock levels by default
[stock_override_procurement](stock_override_procurement/) | 16.0.1.0.0 | | This technical module allow to override procurement values
Expand Down
2 changes: 1 addition & 1 deletion setup/_metapackage/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.0.20240112.1
16.0.20240122.0
2 changes: 2 additions & 0 deletions setup/_metapackage/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
'odoo-addon-stock_lot_scrap>=16.0dev,<16.1dev',
'odoo-addon-stock_move_free_reservation_reassign>=16.0dev,<16.1dev',
'odoo-addon-stock_move_line_auto_fill>=16.0dev,<16.1dev',
'odoo-addon-stock_move_line_expiration_date_required>=16.0dev,<16.1dev',
'odoo-addon-stock_move_line_reserved_quant>=16.0dev,<16.1dev',
'odoo-addon-stock_move_line_serial_unique>=16.0dev,<16.1dev',
'odoo-addon-stock_move_manage_priority>=16.0dev,<16.1dev',
'odoo-addon-stock_move_propagate_first_move>=16.0dev,<16.1dev',
'odoo-addon-stock_no_negative>=16.0dev,<16.1dev',
'odoo-addon-stock_override_procurement>=16.0dev,<16.1dev',
Expand Down
6 changes: 6 additions & 0 deletions setup/stock_move_line_expiration_date_required/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,
)
6 changes: 6 additions & 0 deletions setup/stock_move_manage_priority/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,
)
94 changes: 94 additions & 0 deletions stock_move_line_expiration_date_required/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
========================================
Stock Move Line Expiration Date Required
========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e71da7a78b3fdea74bcf93f838ff0cd22407f8d9767995749dcbe8270b94a42b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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_move_line_expiration_date_required
: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_move_line_expiration_date_required
: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 causes Stock Move Lines with products that have been configured to use an
expiration date and have the expiration time set to 0 days after receipt to
have their expiration date filled in manually and not be auto-calculated.

Expiration date on product that have been configured to use an expiration date will be a required field.

If you configure a product to use an expiration date and you do not set the expiration time (0 days after receipt)
then you will be required to manually enter the expiration date on the stock move line, otherwise, expiration date will be auto-calculated as usual.

Pickings with products configured with an expiration date will not be allowed to be confirmed if any of his stock move lines (related to products with expiration date) have an empty expiration date.

**Table of contents**

.. contents::
:local:

Usage
=====

Go to a warehouse entry that has a product with expiration date configured to
0 days after receipt and fill in its expiration date manually.

Check the expiration date is required now and doesn't let to continue until you fill it.

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

* Moduon

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

* Eduardo de Miguel (`Moduon <https://www.moduon.team/>`__)
* Emilio Pascual (`Moduon <https://www.moduon.team/>`__)

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.

This module is part of the `OCA/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_move_line_expiration_date_required>`_ 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_move_line_expiration_date_required/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions stock_move_line_expiration_date_required/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 Moduon Team S.L. <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl)
{
"name": "Stock Move Line Expiration Date Required",
"Summary": "Expiration date is required to enter manually on Move Lines.",
"version": "16.0.1.0.1",
"author": "Moduon, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-workflow",
"category": "Warehouse Management",
"depends": ["product_expiry"],
"data": [],
"installable": True,
"license": "LGPL-3",
}
54 changes: 54 additions & 0 deletions stock_move_line_expiration_date_required/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_move_line_expiration_date_required
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-11 08:46+0000\n"
"PO-Revision-Date: 2024-01-11 09:47+0100\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: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.4\n"

#. module: stock_move_line_expiration_date_required
#: model:ir.model.fields,field_description:stock_move_line_expiration_date_required.field_stock_move_line__expiration_date
msgid "Expiration Date"
msgstr "Fecha de caducidad"

#. module: stock_move_line_expiration_date_required
#: model:ir.model,name:stock_move_line_expiration_date_required.model_stock_move_line
msgid "Product Moves (Stock Move Line)"
msgstr "Movimientos de Producto (Stock Move Line)"

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

#. module: stock_move_line_expiration_date_required
#. odoo-python
#: code:addons/stock_move_line_expiration_date_required/models/stock_picking.py:0
#, python-format
msgid "The following move lines have no expiration date: %s"
msgstr "Las siguientes líneas de movimientos no tienen fecha de caducidad: %s"

#. module: stock_move_line_expiration_date_required
#: model:ir.model.fields,help:stock_move_line_expiration_date_required.field_stock_move_line__expiration_date
msgid ""
"This is the date on which the goods with this Serial Number may become "
"dangerous and must not be consumed."
msgstr ""
"Ésta es la fecha en la que los bienes con este nº de serie se convierten en "
"peligrosos, y no deben ser consumidos."

#. module: stock_move_line_expiration_date_required
#: model:ir.model,name:stock_move_line_expiration_date_required.model_stock_picking
msgid "Transfer"
msgstr "Albarán"
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_move_line_expiration_date_required
#
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_move_line_expiration_date_required
#: model:ir.model.fields,field_description:stock_move_line_expiration_date_required.field_stock_move_line__expiration_date
msgid "Expiration Date"
msgstr ""

#. module: stock_move_line_expiration_date_required
#: model:ir.model,name:stock_move_line_expiration_date_required.model_stock_move_line
msgid "Product Moves (Stock Move Line)"
msgstr ""

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

#. module: stock_move_line_expiration_date_required
#. odoo-python
#: code:addons/stock_move_line_expiration_date_required/models/stock_picking.py:0
#, python-format
msgid "The following move lines have no expiration date: %s"
msgstr ""

#. module: stock_move_line_expiration_date_required
#: model:ir.model.fields,help:stock_move_line_expiration_date_required.field_stock_move_line__expiration_date
msgid ""
"This is the date on which the goods with this Serial Number may become "
"dangerous and must not be consumed."
msgstr ""

#. module: stock_move_line_expiration_date_required
#: model:ir.model,name:stock_move_line_expiration_date_required.model_stock_picking
msgid "Transfer"
msgstr ""
3 changes: 3 additions & 0 deletions stock_move_line_expiration_date_required/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import stock_move_line
from . import stock_move
from . import stock_picking
27 changes: 27 additions & 0 deletions stock_move_line_expiration_date_required/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2024 Moduon Team S.L. <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/LGPL).

import datetime

from odoo import fields, models


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

def _generate_serial_move_line_commands(self, lot_names, origin_move_line=None):
"""Override to add a default `expiration_date` into the move lines values."""
move_lines_commands = super()._generate_serial_move_line_commands(
lot_names, origin_move_line=origin_move_line
)
if not self.product_id.use_expiration_date:
return move_lines_commands
# managed by super() until here
expiration_dtt = False
if self.product_id.expiration_time > 0:
expiration_dtt = fields.Datetime.today() + datetime.timedelta(
days=self.product_id.expiration_time
)
for move_line_command in move_lines_commands:
move_line_command[2]["expiration_date"] = expiration_dtt
return move_lines_commands
57 changes: 57 additions & 0 deletions stock_move_line_expiration_date_required/models/stock_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2024 Moduon Team S.L. <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/LGPL).

from datetime import timedelta

from odoo import api, fields, models


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

expiration_date = fields.Datetime(
required="[('parent.use_expiration_date', '=', True),"
" ('parent.picking_code', '=', 'incoming')]"
)

@api.depends("product_id", "picking_type_use_create_lots", "lot_id.expiration_date")
def _compute_expiration_date(self):
expiration_dtt_move_line_map = {}
for move_line in self:
if move_line.lot_id.expiration_date:
continue
if not move_line.picking_type_use_create_lots:
continue
if not move_line.product_id.use_expiration_date:
continue
if move_line.expiration_date:
continue
# will be managed by super() until here
expiration_dtt = False
if move_line.product_id.expiration_time > 0:
expiration_dtt = fields.Datetime.today() + timedelta(
days=move_line.product_id.expiration_time
)
expiration_dtt_move_line_map.setdefault(move_line, expiration_dtt)
# super writes the expiration date if it's filled directly from Stock Move
res = super()._compute_expiration_date()
# apply expiration date calculated before super
for move_line in self.filtered(lambda ml: ml in expiration_dtt_move_line_map):
move_line.expiration_date = expiration_dtt_move_line_map[move_line]
return res

@api.onchange("product_id", "product_uom_id")
def _onchange_product_id(self):
res = super()._onchange_product_id()
if not self.picking_type_use_create_lots:
return res
if not self.product_id.use_expiration_date:
return res
# managed by super() until here
expiration_dtt = False
if self.product_id.expiration_time > 0:
expiration_dtt = fields.Datetime.today() + timedelta(
days=self.product_id.expiration_time
)
self.expiration_date = expiration_dtt
return res
32 changes: 32 additions & 0 deletions stock_move_line_expiration_date_required/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2024 Moduon Team S.L. <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/LGPL).


from odoo import _, exceptions, models


class StockPicking(models.Model):
_inherit = "stock.picking"

def _sanity_check(self, separate_pickings=True):
"""Sanity check for expiration dates."""
res = super()._sanity_check()
for picking in self:
move_lines = self.env["stock.move.line"].browse()
for move in picking.move_ids:
# For assigned moves
move_lines |= move._get_move_lines()
move_lines_wo_expiration_date = move_lines.filtered_domain(
[
("use_expiration_date", "=", True),
("expiration_date", "=", False),
]
)
if move_lines_wo_expiration_date:
raise exceptions.UserError(
_(
"The following move lines have no expiration date: %s",
", ".join(move_lines_wo_expiration_date.mapped("display_name")),
)
)
return res
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Eduardo de Miguel (`Moduon <https://www.moduon.team/>`__)
* Emilio Pascual (`Moduon <https://www.moduon.team/>`__)
10 changes: 10 additions & 0 deletions stock_move_line_expiration_date_required/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This module causes Stock Move Lines with products that have been configured to use an
expiration date and have the expiration time set to 0 days after receipt to
have their expiration date filled in manually and not be auto-calculated.

Expiration date on product that have been configured to use an expiration date will be a required field.

If you configure a product to use an expiration date and you do not set the expiration time (0 days after receipt)
then you will be required to manually enter the expiration date on the stock move line, otherwise, expiration date will be auto-calculated as usual.

Pickings with products configured with an expiration date will not be allowed to be confirmed if any of his stock move lines (related to products with expiration date) have an empty expiration date.
Loading
Loading