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
102 changes: 102 additions & 0 deletions stock_move_line_expiration_date_required/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
========================================
Stock Move Line Expiration Date Required
========================================

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

.. |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/18.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-18-0/stock-logistics-workflow-18-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=18.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:%2018.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/18.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
17 changes: 17 additions & 0 deletions stock_move_line_expiration_date_required/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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": "18.0.1.0.0",
"author": "Moduon, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-workflow",
"category": "Warehouse Management",
"depends": ["product_expiry"],
"data": [
"views/stock_move_view.xml",
"views/stock_move_line_view.xml",
],
"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\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-02-07 12:53+0000\n"
"PO-Revision-Date: 2024-02-07 13:54+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.2\n"

#. module: stock_move_line_expiration_date_required
#: model:ir.model.fields,field_description:stock_move_line_expiration_date_required.field_stock_move__all_expiry_dates_set
msgid "All Expiry Dates Set"
msgstr "Todas las fechas de expiración establecidas"

#. 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,name:stock_move_line_expiration_date_required.model_stock_picking
msgid "Transfer"
msgstr "Albarán"

#. module: stock_move_line_expiration_date_required
#: model_terms:ir.ui.view,arch_db:stock_move_line_expiration_date_required.view_stock_move_nosuggest_operations
msgid ""
"You won't be able to confirm the parent picking until all Expiry dates are "
"set"
msgstr ""
"No podrás confirmar el Albarán padre hasta que todas las Fechas de Caducidad "
"estén establecidas"
63 changes: 63 additions & 0 deletions stock_move_line_expiration_date_required/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 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"
"PO-Revision-Date: 2024-02-12 10:36+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_move_line_expiration_date_required
#: model:ir.model.fields,field_description:stock_move_line_expiration_date_required.field_stock_move__all_expiry_dates_set
msgid "All Expiry Dates Set"
msgstr "Tutte le date scadenza impostate"

#. 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 "Movimenti prodotto (riga movimento di magazzino)"

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

#. 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 "Le seguenti righe di movimento non hanno data di scadenza: %s"

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

#. module: stock_move_line_expiration_date_required
#: model_terms:ir.ui.view,arch_db:stock_move_line_expiration_date_required.view_stock_move_nosuggest_operations
msgid ""
"You won't be able to confirm the parent picking until all Expiry dates are "
"set"
msgstr ""
"Non sarà possibile confermare il prelievo padre finchè non saranno impostate "
"tutte le data di scadenza"

#~ msgid "Expiration Date"
#~ msgstr "Data di scadenza"

#~ msgid ""
#~ "This is the date on which the goods with this Serial Number may become "
#~ "dangerous and must not be consumed."
#~ msgstr ""
#~ "Questa è la data nella quale la merce con questo numero di serie può "
#~ "diventare pericolosa e non deve essere consumata."
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__all_expiry_dates_set
msgid "All Expiry Dates Set"
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,name:stock_move_line_expiration_date_required.model_stock_picking
msgid "Transfer"
msgstr ""

#. module: stock_move_line_expiration_date_required
#: model_terms:ir.ui.view,arch_db:stock_move_line_expiration_date_required.view_stock_move_nosuggest_operations
msgid ""
"You won't be able to confirm the parent picking until all Expiry dates are "
"set"
msgstr ""
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).
from odoo import SUPERUSER_ID, api, tools


def migrate(cr, version):
# Update the `expiration_date` field definition in the `stock_move_line` table
env = api.Environment(cr, SUPERUSER_ID, {})
sml_model = env["stock.move.line"]
sml_columns = tools.table_columns(env.cr, sml_model._table)
sml_model._fields["expiration_date"].update_db(sml_model, sml_columns)
# Don't need to recompute (flush) fields onto the DB because:
# If the field is required, will have been recomputed.
# If the field is not required, doesn't need to be flushed in the DB.
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
38 changes: 38 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,38 @@
# 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"

all_expiry_dates_set = fields.Boolean(
compute="_compute_all_expiry_dates_set",
)

def _compute_all_expiry_dates_set(self):
"""Check if all move lines have an expiration date set."""
for record in self:
record.all_expiry_dates_set = not record.use_expiration_date or all(
record.move_line_ids.filtered("quantity").mapped("expiration_date")
)

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
Loading