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

[17.0][MIG] stock_production_lot_expired_date #1580

Merged
Merged
95 changes: 95 additions & 0 deletions stock_production_lot_expired_date/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
=================================
Stock production lot expired date
=================================

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

.. |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-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%2Fproduct--attribute-lightgray.png?logo=github
:target: https://github.com/OCA/product-attribute/tree/17.0/stock_production_lot_expired_date
:alt: OCA/product-attribute
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-attribute-17-0/product-attribute-17-0-stock_production_lot_expired_date
: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/product-attribute&target_branch=17.0
:alt: Try me on Runboat

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

This module allows to facilitate the input of stock production lot
expired dates:

- Add settings on stock to choose the base date for stock production
lot
- Add onchanges on stock production lot to compute expired dates from
base date

**Table of contents**

.. contents::
:local:

Usage
=====

| # Go to *Settings > Inventory > Traceability*
| There you can set the base date under *Base date to compute expiration
dates*

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/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/product-attribute/issues/new?body=module:%20stock_production_lot_expired_date%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
* ACSONE SA/NV

Contributors
------------

- Julien Coux <[email protected]>
- Hughes Damry <[email protected]>

- ``Binhex Systems Solutions <https://binhex.cloud/>``\ \_:

- Deriman Alonso [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.

This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/17.0/stock_production_lot_expired_date>`_ 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_production_lot_expired_date/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions stock_production_lot_expired_date/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2016 Julien Coux (Camptocamp)
# Copyright 2022 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Stock production lot expired date",
"version": "17.0.1.0.1",
"author": "Camptocamp, ACSONE SA/NV, Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Product",
"depends": ["product_expiry", "stock"],
"website": "https://github.com/OCA/product-attribute",
"data": ["views/res_config_settings.xml"],
"installable": True,
}
60 changes: 60 additions & 0 deletions stock_production_lot_expired_date/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_production_lot_expired_date
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-29 11:34+0000\n"
"Last-Translator: Ivorra78 <[email protected]>\n"
"Language-Team: none\n"
"Language: es\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_production_lot_expired_date
#. odoo-python
#: code:addons/stock_production_lot_expired_date/models/res_config_settings.py:0
#, python-format
msgid "Alert date"
msgstr "Fecha de alerta"

#. module: stock_production_lot_expired_date
#: model:ir.model.fields,field_description:stock_production_lot_expired_date.field_res_config_settings__production_lot_base_date
msgid "Base date to compute expiration dates"
msgstr "Fecha base para calcular las fechas de caducidad"

#. module: stock_production_lot_expired_date
#: model:ir.model,name:stock_production_lot_expired_date.model_res_config_settings
msgid "Config Settings"
msgstr "Ajustes de Config"

#. module: stock_production_lot_expired_date
#. odoo-python
#: code:addons/stock_production_lot_expired_date/models/res_config_settings.py:0
#, python-format
msgid "Expiration date"
msgstr "Fecha de Expiración"

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

#. module: stock_production_lot_expired_date
#. odoo-python
#: code:addons/stock_production_lot_expired_date/models/res_config_settings.py:0
#, python-format
msgid "Removal date"
msgstr "Fecha de retirada"

#. module: stock_production_lot_expired_date
#. odoo-python
#: code:addons/stock_production_lot_expired_date/models/res_config_settings.py:0
#, python-format
msgid "Use date"
msgstr "Fecha de uso"
60 changes: 60 additions & 0 deletions stock_production_lot_expired_date/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_production_lot_expired_date
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-04-27 15:33+0000\n"
"Last-Translator: Sebastiano Picchi <[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.14.1\n"

#. module: stock_production_lot_expired_date
#. odoo-python
#: code:addons/stock_production_lot_expired_date/models/res_config_settings.py:0
#, python-format
msgid "Alert date"
msgstr "Data di avviso"

#. module: stock_production_lot_expired_date
#: model:ir.model.fields,field_description:stock_production_lot_expired_date.field_res_config_settings__production_lot_base_date
msgid "Base date to compute expiration dates"
msgstr "Data base da cui computare la data di scadenza"

#. module: stock_production_lot_expired_date
#: model:ir.model,name:stock_production_lot_expired_date.model_res_config_settings
msgid "Config Settings"
msgstr "Impostazioni di configurazione"

#. module: stock_production_lot_expired_date
#. odoo-python
#: code:addons/stock_production_lot_expired_date/models/res_config_settings.py:0
#, python-format
msgid "Expiration date"
msgstr "Data di scadenza"

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

#. module: stock_production_lot_expired_date
#. odoo-python
#: code:addons/stock_production_lot_expired_date/models/res_config_settings.py:0
#, python-format
msgid "Removal date"
msgstr "Data rimozione"

#. module: stock_production_lot_expired_date
#. odoo-python
#: code:addons/stock_production_lot_expired_date/models/res_config_settings.py:0
#, python-format
msgid "Use date"
msgstr "Data d'uso"
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_production_lot_expired_date
#
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_production_lot_expired_date
#. odoo-python
#: code:addons/stock_production_lot_expired_date/models/res_config_settings.py:0
#, python-format
msgid "Alert date"
msgstr ""

#. module: stock_production_lot_expired_date
#: model:ir.model.fields,field_description:stock_production_lot_expired_date.field_res_config_settings__production_lot_base_date
msgid "Base date to compute expiration dates"
msgstr ""

#. module: stock_production_lot_expired_date
#: model:ir.model,name:stock_production_lot_expired_date.model_res_config_settings
msgid "Config Settings"
msgstr ""

#. module: stock_production_lot_expired_date
#. odoo-python
#: code:addons/stock_production_lot_expired_date/models/res_config_settings.py:0
#, python-format
msgid "Expiration date"
msgstr ""

#. module: stock_production_lot_expired_date
#: model:ir.model,name:stock_production_lot_expired_date.model_stock_lot
msgid "Lot/Serial"
msgstr ""

#. module: stock_production_lot_expired_date
#. odoo-python
#: code:addons/stock_production_lot_expired_date/models/res_config_settings.py:0
#, python-format
msgid "Removal date"
msgstr ""

#. module: stock_production_lot_expired_date
#. odoo-python
#: code:addons/stock_production_lot_expired_date/models/res_config_settings.py:0
#, python-format
msgid "Use date"
msgstr ""
2 changes: 2 additions & 0 deletions stock_production_lot_expired_date/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import res_config_settings
from . import stock_lot
23 changes: 23 additions & 0 deletions stock_production_lot_expired_date/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models


class ResConfig(models.TransientModel):
_inherit = "res.config.settings"

production_lot_base_date = fields.Selection(
selection="_selection_production_lot_base_date",
string="Base date to compute expiration dates",
config_parameter="stock_production_lot_expired_date.production_lot_base_date",
)

@api.model
def _selection_production_lot_base_date(self):
return [

Check warning on line 18 in stock_production_lot_expired_date/models/res_config_settings.py

View check run for this annotation

Codecov / codecov/patch

stock_production_lot_expired_date/models/res_config_settings.py#L18

Added line #L18 was not covered by tests
("use", _("Use date")),
("expiration", _("Expiration date")),
("alert", _("Alert date")),
("removal", _("Removal date")),
]
57 changes: 57 additions & 0 deletions stock_production_lot_expired_date/models/stock_lot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2016-2018 Julien Coux (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from dateutil.relativedelta import relativedelta

from odoo import api, models


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

@api.model
def _get_product_expired_times(self, product):
return {
"expiration_time": product.expiration_time,
"use_time": product.use_time,
"removal_time": product.removal_time,
"alert_time": product.alert_time,
}

def _apply_onchange_interval_date(self, from_field):
self.ensure_one()
base_date = self.env["ir.config_parameter"].get_param(
"stock_production_lot_expired_date.production_lot_base_date"
)
if self.product_id and base_date == from_field:
if getattr(self, from_field + "_date"):
to_fields = ["alert", "expiration", "removal", "use"]
to_fields.remove(from_field)
times = self._get_product_expired_times(self.product_id)
from_time = times[from_field + "_time"]
from_date = getattr(self, from_field + "_date")
values = {}
for index in [0, 1, 2]:
if times[to_fields[index] + "_time"]:
days = from_time - times[to_fields[index] + "_time"]
values[to_fields[index] + "_date"] = from_date - relativedelta(
days=days
)
if values:
self.write(values)

@api.onchange("removal_date")
def onchange_removal_date(self):
self._apply_onchange_interval_date("removal")

@api.onchange("alert_date")
def onchange_alert_date(self):
self._apply_onchange_interval_date("alert")

@api.onchange("expiration_date")
def onchange_expiration_date(self):
self._apply_onchange_interval_date("expiration")

@api.onchange("use_date")
def onchange_use_date(self):
self._apply_onchange_interval_date("use")
3 changes: 3 additions & 0 deletions stock_production_lot_expired_date/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
7 changes: 7 additions & 0 deletions stock_production_lot_expired_date/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- Julien Coux \<<[email protected]>\>
- Hughes Damry \<<[email protected]>\>

* `Binhex Systems Solutions <https://binhex.cloud/>`_:


* Deriman Alonso <[email protected]>
6 changes: 6 additions & 0 deletions stock_production_lot_expired_date/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module allows to facilitate the input of stock production lot
expired dates:

- Add settings on stock to choose the base date for stock production lot
- Add onchanges on stock production lot to compute expired dates from
base date
Loading
Loading