diff --git a/stock_production_lot_expired_date/README.rst b/stock_production_lot_expired_date/README.rst new file mode 100644 index 00000000000..4ead982b1c1 --- /dev/null +++ b/stock_production_lot_expired_date/README.rst @@ -0,0 +1,94 @@ +================================= +Stock production lot expired date +================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:bc47c5c5d74b0944d7f634f8362e1d15e7766947209359f2be5cf54ad7151af3 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/18.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-18-0/product-attribute-18-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=18.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 `_. +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Camptocamp +* ACSONE SA/NV + +Contributors +------------ + +- Julien Coux +- Hughes Damry + +- ``Binhex Systems Solutions ``\ \_: + + - Deriman Alonso d.alonso@binhex.cloud + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_production_lot_expired_date/__init__.py b/stock_production_lot_expired_date/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/stock_production_lot_expired_date/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_production_lot_expired_date/__manifest__.py b/stock_production_lot_expired_date/__manifest__.py new file mode 100644 index 00000000000..b55ab0c0112 --- /dev/null +++ b/stock_production_lot_expired_date/__manifest__.py @@ -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": "18.0.1.0.0", + "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, +} diff --git a/stock_production_lot_expired_date/i18n/es.po b/stock_production_lot_expired_date/i18n/es.po new file mode 100644 index 00000000000..7a0c880c101 --- /dev/null +++ b/stock_production_lot_expired_date/i18n/es.po @@ -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 \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" diff --git a/stock_production_lot_expired_date/i18n/it.po b/stock_production_lot_expired_date/i18n/it.po new file mode 100644 index 00000000000..becfce473b3 --- /dev/null +++ b/stock_production_lot_expired_date/i18n/it.po @@ -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 \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" diff --git a/stock_production_lot_expired_date/i18n/stock_production_lot_expired_date.pot b/stock_production_lot_expired_date/i18n/stock_production_lot_expired_date.pot new file mode 100644 index 00000000000..a83f9529e19 --- /dev/null +++ b/stock_production_lot_expired_date/i18n/stock_production_lot_expired_date.pot @@ -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 17.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 "" diff --git a/stock_production_lot_expired_date/models/__init__.py b/stock_production_lot_expired_date/models/__init__.py new file mode 100644 index 00000000000..41ec6f5fae6 --- /dev/null +++ b/stock_production_lot_expired_date/models/__init__.py @@ -0,0 +1,2 @@ +from . import res_config_settings +from . import stock_lot diff --git a/stock_production_lot_expired_date/models/res_config_settings.py b/stock_production_lot_expired_date/models/res_config_settings.py new file mode 100644 index 00000000000..a55da7738dd --- /dev/null +++ b/stock_production_lot_expired_date/models/res_config_settings.py @@ -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 [ + ("use", _("Use date")), + ("expiration", _("Expiration date")), + ("alert", _("Alert date")), + ("removal", _("Removal date")), + ] diff --git a/stock_production_lot_expired_date/models/stock_lot.py b/stock_production_lot_expired_date/models/stock_lot.py new file mode 100644 index 00000000000..a6248902d43 --- /dev/null +++ b/stock_production_lot_expired_date/models/stock_lot.py @@ -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") diff --git a/stock_production_lot_expired_date/pyproject.toml b/stock_production_lot_expired_date/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/stock_production_lot_expired_date/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/stock_production_lot_expired_date/readme/CONTRIBUTORS.md b/stock_production_lot_expired_date/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..6f64b61ad41 --- /dev/null +++ b/stock_production_lot_expired_date/readme/CONTRIBUTORS.md @@ -0,0 +1,7 @@ +- Julien Coux \<\> +- Hughes Damry \<\> + +* `Binhex Systems Solutions `_: + + + * Deriman Alonso diff --git a/stock_production_lot_expired_date/readme/DESCRIPTION.md b/stock_production_lot_expired_date/readme/DESCRIPTION.md new file mode 100644 index 00000000000..5171220d7ee --- /dev/null +++ b/stock_production_lot_expired_date/readme/DESCRIPTION.md @@ -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 diff --git a/stock_production_lot_expired_date/readme/USAGE.md b/stock_production_lot_expired_date/readme/USAGE.md new file mode 100644 index 00000000000..9c36f31543f --- /dev/null +++ b/stock_production_lot_expired_date/readme/USAGE.md @@ -0,0 +1,3 @@ +\# Go to *Settings \> Inventory \> Traceability* +There you can set the base date under *Base date to compute expiration +dates* diff --git a/stock_production_lot_expired_date/static/description/icon.png b/stock_production_lot_expired_date/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/stock_production_lot_expired_date/static/description/icon.png differ diff --git a/stock_production_lot_expired_date/static/description/index.html b/stock_production_lot_expired_date/static/description/index.html new file mode 100644 index 00000000000..071f43ee7ee --- /dev/null +++ b/stock_production_lot_expired_date/static/description/index.html @@ -0,0 +1,444 @@ + + + + + +Stock production lot expired date + + + +
+

Stock production lot expired date

+ + +

Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runboat

+

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

+ +
+

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. +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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
  • ACSONE SA/NV
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/stock_production_lot_expired_date/tests/__init__.py b/stock_production_lot_expired_date/tests/__init__.py new file mode 100644 index 00000000000..e2df2638f8f --- /dev/null +++ b/stock_production_lot_expired_date/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_production_lot_expired_date diff --git a/stock_production_lot_expired_date/tests/test_stock_production_lot_expired_date.py b/stock_production_lot_expired_date/tests/test_stock_production_lot_expired_date.py new file mode 100644 index 00000000000..0857187bb3a --- /dev/null +++ b/stock_production_lot_expired_date/tests/test_stock_production_lot_expired_date.py @@ -0,0 +1,231 @@ +# Copyright 2016 Julien Coux (Camptocamp) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from datetime import datetime, timedelta + +from odoo.tests.common import TransactionCase + + +class TestStockLotExpirationDates(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.product_model = cls.env["product.product"] + cls.production_lot_model = cls.env["stock.lot"] + cls.category = cls.env.ref("product.product_category_all") + cls.category_2 = cls.env.ref("product.product_category_2") + cls.category_3 = cls.env.ref("product.product_category_3") + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + + cls.product = cls.product_model.create( + { + "name": "Unittest product", + "type": "consu", + "is_storable": True, + "categ_id": cls.category.id, + "use_time": 10, + "expiration_time": 11, + "alert_time": 12, + "removal_time": 13, + } + ) + cls.production_lot = cls.production_lot_model.create( + { + "name": "000001", + "product_id": cls.product.id, + "company_id": cls.env.company.id, + } + ) + + cls.product_2 = cls.product_model.create( + { + "name": "Unittest product 2", + "type": "consu", + "is_storable": True, + "categ_id": cls.category_2.id, + "use_time": -13, + "expiration_time": -12, + "alert_time": -11, + "removal_time": -10, + } + ) + cls.production_lot_2 = cls.production_lot_model.create( + { + "name": "000001", + "product_id": cls.product_2.id, + "company_id": cls.env.company.id, + } + ) + + cls.product_3 = cls.product_model.create( + { + "name": "Unittest product 3", + "type": "consu", + "is_storable": True, + "categ_id": cls.category_3.id, + "use_time": 0, + "expiration_time": 0, + "alert_time": 0, + "removal_time": 0, + } + ) + cls.production_lot_3 = cls.production_lot_model.create( + { + "name": "000001", + "product_id": cls.product_3.id, + "company_id": cls.env.company.id, + } + ) + + day_1 = timedelta(days=1) + cls.date_20 = datetime.strptime("2016-12-20 10:00:00", "%Y-%m-%d %H:%M:%S") + cls.date_21 = cls.date_20 + day_1 + cls.date_22 = cls.date_21 + day_1 + cls.date_23 = cls.date_22 + day_1 + cls.date_24 = cls.date_23 + day_1 + cls.date_25 = cls.date_24 + day_1 + cls.date_26 = cls.date_25 + day_1 + + def _set_lot_base_date(self, base_date): + """It is faster to set directly the param instead + of relying on the config setting execution""" + self.env["ir.config_parameter"].set_param( + "stock_production_lot_expired_date.production_lot_base_date", base_date + ) + + def test_1_onchange_use_date(self): + for base_date in [None, "alert", "expiration", "removal", "use"]: + self._set_lot_base_date(base_date) + for production_lot in [ + self.production_lot, + self.production_lot_2, + self.production_lot_3, + ]: + production_lot.use_date = False + production_lot.expiration_date = False + production_lot.alert_date = False + production_lot.removal_date = False + production_lot.use_date = self.date_23 + production_lot.onchange_use_date() + date_must_change = ( + base_date == "use" and production_lot != self.production_lot_3 + ) + self.assertEqual(production_lot.use_date, self.date_23) + self.assertEqual( + production_lot.expiration_date, + self.date_24 if date_must_change else False, + ) + self.assertEqual( + production_lot.alert_date, + self.date_25 if date_must_change else False, + ) + self.assertEqual( + production_lot.removal_date, + self.date_26 if date_must_change else False, + ) + # Check the onchange does not fails with no value + production_lot.use_date = False + production_lot.onchange_use_date() + + def test_2_onchange_expiration_date(self): + for base_date in [None, "alert", "expiration", "removal", "use"]: + self._set_lot_base_date(base_date) + for production_lot in [ + self.production_lot, + self.production_lot_2, + self.production_lot_3, + ]: + production_lot.use_date = False + production_lot.expiration_date = False + production_lot.alert_date = False + production_lot.removal_date = False + production_lot.expiration_date = self.date_23 + production_lot.onchange_expiration_date() + date_must_change = ( + base_date == "expiration" + and production_lot != self.production_lot_3 + ) + self.assertEqual( + production_lot.use_date, + self.date_22 if date_must_change else False, + ) + self.assertEqual(production_lot.expiration_date, self.date_23) + self.assertEqual( + production_lot.alert_date, + self.date_24 if date_must_change else False, + ) + self.assertEqual( + production_lot.removal_date, + self.date_25 if date_must_change else False, + ) + # Check the onchange not fails with no value + production_lot.expiration_date = False + production_lot.onchange_expiration_date() + + def test_3_onchange_alert_date(self): + for base_date in [None, "alert", "expiration", "removal", "use"]: + self._set_lot_base_date(base_date) + for production_lot in [ + self.production_lot, + self.production_lot_2, + self.production_lot_3, + ]: + production_lot.use_date = False + production_lot.expiration_date = False + production_lot.alert_date = False + production_lot.removal_date = False + production_lot.alert_date = self.date_23 + production_lot.onchange_alert_date() + date_must_change = ( + base_date == "alert" and production_lot != self.production_lot_3 + ) + self.assertEqual( + production_lot.use_date, + self.date_21 if date_must_change else False, + ) + self.assertEqual( + production_lot.expiration_date, + self.date_22 if date_must_change else False, + ) + self.assertEqual(production_lot.alert_date, self.date_23) + self.assertEqual( + production_lot.removal_date, + self.date_24 if date_must_change else False, + ) + # Check the onchange not fails with no value + production_lot.alert_date = False + production_lot.onchange_alert_date() + + def test_4_onchange_removal_date(self): + for base_date in [None, "alert", "expiration", "removal", "use"]: + self._set_lot_base_date(base_date) + for production_lot in [ + self.production_lot, + self.production_lot_2, + self.production_lot_3, + ]: + production_lot.use_date = False + production_lot.expiration_date = False + production_lot.alert_date = False + production_lot.removal_date = False + production_lot.removal_date = self.date_23 + production_lot.onchange_removal_date() + date_must_change = ( + base_date == "removal" and production_lot != self.production_lot_3 + ) + self.assertEqual( + production_lot.use_date, + self.date_20 if date_must_change else False, + ) + self.assertEqual( + production_lot.expiration_date, + self.date_21 if date_must_change else False, + ) + self.assertEqual( + production_lot.alert_date, + self.date_22 if date_must_change else False, + ) + self.assertEqual(production_lot.removal_date, self.date_23) + # Check the onchange not fails with no value + production_lot.removal_date = False + production_lot.onchange_removal_date() diff --git a/stock_production_lot_expired_date/views/res_config_settings.xml b/stock_production_lot_expired_date/views/res_config_settings.xml new file mode 100644 index 00000000000..20a0aff1426 --- /dev/null +++ b/stock_production_lot_expired_date/views/res_config_settings.xml @@ -0,0 +1,24 @@ + + + + stock.config.settings.form (in stock_production_lot_expired_date) + res.config.settings + + + + +
+
+
+
+
+
+