forked from OCA/stock-logistics-workflow
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1082 from OCA/16.0
Syncing from upstream OCA/stock-logistics-workflow (16.0)
- Loading branch information
Showing
46 changed files
with
2,031 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16.0.20240112.1 | ||
16.0.20240122.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...k_move_line_expiration_date_required/odoo/addons/stock_move_line_expiration_date_required
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../stock_move_line_expiration_date_required |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
1 change: 1 addition & 0 deletions
1
setup/stock_move_manage_priority/odoo/addons/stock_move_manage_priority
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../stock_move_manage_priority |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
48 changes: 48 additions & 0 deletions
48
stock_move_line_expiration_date_required/i18n/stock_move_line_expiration_date_required.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
27
stock_move_line_expiration_date_required/models/stock_move.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
57
stock_move_line_expiration_date_required/models/stock_move_line.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
32
stock_move_line_expiration_date_required/models/stock_picking.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
2 changes: 2 additions & 0 deletions
2
stock_move_line_expiration_date_required/readme/CONTRIBUTORS.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
stock_move_line_expiration_date_required/readme/DESCRIPTION.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Oops, something went wrong.