diff --git a/setup/stock_production_lot_warranty/odoo/addons/stock_production_lot_warranty b/setup/stock_production_lot_warranty/odoo/addons/stock_production_lot_warranty new file mode 120000 index 00000000..b64b017f --- /dev/null +++ b/setup/stock_production_lot_warranty/odoo/addons/stock_production_lot_warranty @@ -0,0 +1 @@ +../../../../stock_production_lot_warranty \ No newline at end of file diff --git a/setup/stock_production_lot_warranty/setup.py b/setup/stock_production_lot_warranty/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/stock_production_lot_warranty/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_production_lot_warranty/README.rst b/stock_production_lot_warranty/README.rst new file mode 100644 index 00000000..118fb89e --- /dev/null +++ b/stock_production_lot_warranty/README.rst @@ -0,0 +1,120 @@ +=================================== +Warranty Date on Lot/Serial Numbers +=================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Frma-lightgray.png?logo=github + :target: https://github.com/OCA/rma/tree/12.0/stock_production_lot_warranty + :alt: OCA/rma +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/rma-12-0/rma-12-0-stock_production_lot_warranty + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/145/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Odoo does not provide the warranty information on the serial number of a product. + +This module allows you to compute the warranty expiration date of a serialized +product based on the warranty duration. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module: + +* Go to Inventory > Configuration > Settings +* Activate the traceability +* Go to Inventory > Master Data > Products +* Create or select a product and set the warranty +* Go to the Inventory tab in the Logistics section +* Set the warranty duration + +Usage +===== + +To use this module, + +* Go to Inventory > Master Data > Lot/Serial Numbers +* Create a new serial number and select a product +* The Warranty Expiration Date is automatically computed based on today + the + warranty duration from the select product +* You can overwrite the computed date with your own value. + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Open Source Integrators + +Contributors +~~~~~~~~~~~~ + +* Steve Campbell +* Maxime Chambreuil +* Serpent Consulting Services Pvt. Ltd. + +Other credits +~~~~~~~~~~~~~ + +This module has been financially supported by: + +* Pavlov Media +* Open Source Integrators + +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. + +.. |maintainer-osi-scampbell| image:: https://github.com/osi-scampbell.png?size=40px + :target: https://github.com/osi-scampbell + :alt: osi-scampbell +.. |maintainer-max3903| image:: https://github.com/max3903.png?size=40px + :target: https://github.com/max3903 + :alt: max3903 + +Current `maintainers `__: + +|maintainer-osi-scampbell| |maintainer-max3903| + +This module is part of the `OCA/rma `_ 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_warranty/__init__.py b/stock_production_lot_warranty/__init__.py new file mode 100644 index 00000000..69f7babd --- /dev/null +++ b/stock_production_lot_warranty/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/stock_production_lot_warranty/__manifest__.py b/stock_production_lot_warranty/__manifest__.py new file mode 100644 index 00000000..1ade4a9b --- /dev/null +++ b/stock_production_lot_warranty/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright (C) 2018 - TODAY, Open Source Integrators +# Copyright (C) 2021 Serpent Consulting Services +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Warranty Date on Lot/Serial Numbers", + "summary": "Add warranty date to stock production lot", + "version": "15.0.1.0.0", + "license": "AGPL-3", + "author": "Open Source Integrators, Odoo Community Association (OCA)", + "category": "Stock", + "website": "https://github.com/OCA/rma", + "depends": ["product_warranty", "stock"], + "data": ["views/stock_production_lot.xml"], + "installable": True, + "development_status": "Beta", + "maintainers": ["osi-scampbell", "max3903"], +} diff --git a/stock_production_lot_warranty/i18n/pt.po b/stock_production_lot_warranty/i18n/pt.po new file mode 100644 index 00000000..2287256d --- /dev/null +++ b/stock_production_lot_warranty/i18n/pt.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_production_lot_warranty +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-03-11 20:45+0000\n" +"Last-Translator: Pedro Castro Silva \n" +"Language-Team: none\n" +"Language: pt\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.3.2\n" + +#. module: stock_production_lot_warranty +#: model:ir.model,name:stock_production_lot_warranty.model_stock_production_lot +msgid "Lot/Serial" +msgstr "Lote/Série" + +#. module: stock_production_lot_warranty +#: model:ir.model.fields,field_description:stock_production_lot_warranty.field_stock_production_lot__warranty_exp_date +msgid "Warranty Expiration Date" +msgstr "Data de Expiração da Garantia" diff --git a/stock_production_lot_warranty/i18n/pt_BR.po b/stock_production_lot_warranty/i18n/pt_BR.po new file mode 100644 index 00000000..79b10881 --- /dev/null +++ b/stock_production_lot_warranty/i18n/pt_BR.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_production_lot_warranty +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-07-22 18:19+0000\n" +"Last-Translator: Fernando Colus \n" +"Language-Team: none\n" +"Language: pt_BR\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 3.10\n" + +#. module: stock_production_lot_warranty +#: model:ir.model,name:stock_production_lot_warranty.model_stock_production_lot +msgid "Lot/Serial" +msgstr "Lote/Serial" + +#. module: stock_production_lot_warranty +#: model:ir.model.fields,field_description:stock_production_lot_warranty.field_stock_production_lot__warranty_exp_date +msgid "Warranty Expiration Date" +msgstr "Data de Término da Garantia" diff --git a/stock_production_lot_warranty/i18n/stock_production_lot_warranty.pot b/stock_production_lot_warranty/i18n/stock_production_lot_warranty.pot new file mode 100644 index 00000000..341d85f5 --- /dev/null +++ b/stock_production_lot_warranty/i18n/stock_production_lot_warranty.pot @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_production_lot_warranty +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.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_warranty +#: model:ir.model,name:stock_production_lot_warranty.model_stock_production_lot +msgid "Lot/Serial" +msgstr "" + +#. module: stock_production_lot_warranty +#: model:ir.model.fields,field_description:stock_production_lot_warranty.field_stock_production_lot__warranty_exp_date +msgid "Warranty Expiration Date" +msgstr "" + diff --git a/stock_production_lot_warranty/models/__init__.py b/stock_production_lot_warranty/models/__init__.py new file mode 100644 index 00000000..d45f1fe8 --- /dev/null +++ b/stock_production_lot_warranty/models/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import stock_production_lot diff --git a/stock_production_lot_warranty/models/stock_production_lot.py b/stock_production_lot_warranty/models/stock_production_lot.py new file mode 100644 index 00000000..2d2c4644 --- /dev/null +++ b/stock_production_lot_warranty/models/stock_production_lot.py @@ -0,0 +1,48 @@ +# Copyright (C) 2018 - TODAY, Open Source Integrators +# Copyright (C) 2021 Serpent Consulting Services +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from datetime import datetime, timedelta + +from dateutil.relativedelta import relativedelta + +from odoo import api, fields, models +from odoo.tools import DEFAULT_SERVER_DATE_FORMAT + + +class StockProductionLot(models.Model): + _inherit = "stock.production.lot" + + warranty_exp_date = fields.Date(string="Warranty Expiration Date") + + @api.onchange("product_id") + def _onchange_product_id(self): + self.warranty_exp_date = False + if ( + self.product_id + and self.product_id.product_tmpl_id.warranty_type + and self.product_id.product_tmpl_id.warranty + ): + warranty_type = self.product_id.product_tmpl_id.warranty_type + time = False + if warranty_type == "day": + time = ( + datetime.now() + + timedelta(days=self.product_id.product_tmpl_id.warranty) + ).strftime(DEFAULT_SERVER_DATE_FORMAT) + elif warranty_type == "week": + time = ( + datetime.now() + + timedelta(weeks=self.product_id.product_tmpl_id.warranty) + ).strftime(DEFAULT_SERVER_DATE_FORMAT) + elif warranty_type == "month": + time = ( + datetime.now() + + relativedelta(months=+self.product_id.product_tmpl_id.warranty) + ).strftime(DEFAULT_SERVER_DATE_FORMAT) + elif warranty_type == "year": + time = ( + datetime.now() + + relativedelta(years=+self.product_id.product_tmpl_id.warranty) + ).strftime(DEFAULT_SERVER_DATE_FORMAT) + self.warranty_exp_date = time diff --git a/stock_production_lot_warranty/readme/CONFIGURE.rst b/stock_production_lot_warranty/readme/CONFIGURE.rst new file mode 100644 index 00000000..9be297db --- /dev/null +++ b/stock_production_lot_warranty/readme/CONFIGURE.rst @@ -0,0 +1,8 @@ +To configure this module: + +* Go to Inventory > Configuration > Settings +* Activate the traceability +* Go to Inventory > Products > Products +* Create or select a product and set the warranty +* Go to the Inventory tab in the Logistics section +* Set the warranty duration diff --git a/stock_production_lot_warranty/readme/CONTRIBUTORS.rst b/stock_production_lot_warranty/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..d2767f98 --- /dev/null +++ b/stock_production_lot_warranty/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Steve Campbell +* Maxime Chambreuil +* Serpent Consulting Services Pvt. Ltd. diff --git a/stock_production_lot_warranty/readme/CREDITS.rst b/stock_production_lot_warranty/readme/CREDITS.rst new file mode 100644 index 00000000..54d7b7a0 --- /dev/null +++ b/stock_production_lot_warranty/readme/CREDITS.rst @@ -0,0 +1,4 @@ +This module has been financially supported by: + +* Pavlov Media +* Open Source Integrators diff --git a/stock_production_lot_warranty/readme/DESCRIPTION.rst b/stock_production_lot_warranty/readme/DESCRIPTION.rst new file mode 100644 index 00000000..c3ceb9ed --- /dev/null +++ b/stock_production_lot_warranty/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +Odoo does not provide the warranty information on the serial number of a product. + +This module allows you to compute the warranty expiration date of a serialized +product based on the warranty duration. diff --git a/stock_production_lot_warranty/readme/USAGE.rst b/stock_production_lot_warranty/readme/USAGE.rst new file mode 100644 index 00000000..221c994a --- /dev/null +++ b/stock_production_lot_warranty/readme/USAGE.rst @@ -0,0 +1,7 @@ +To use this module, + +* Go to Inventory > Products > Lot/Serial Numbers +* Create a new serial number and select a product +* The Warranty Expiration Date is automatically computed based on today + the + warranty duration from the select product +* You can overwrite the computed date with your own value. diff --git a/stock_production_lot_warranty/static/description/icon.png b/stock_production_lot_warranty/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/stock_production_lot_warranty/static/description/icon.png differ diff --git a/stock_production_lot_warranty/static/description/index.html b/stock_production_lot_warranty/static/description/index.html new file mode 100644 index 00000000..02c6ce00 --- /dev/null +++ b/stock_production_lot_warranty/static/description/index.html @@ -0,0 +1,459 @@ + + + + + + +Warranty Date on Lot/Serial Numbers + + + +
+

Warranty Date on Lot/Serial Numbers

+ + +

Beta License: AGPL-3 OCA/rma Translate me on Weblate Try me on Runbot

+

Odoo does not provide the warranty information on the serial number of a product.

+

This module allows you to compute the warranty expiration date of a serialized +product based on the warranty duration.

+

Table of contents

+ +
+

Configuration

+

To configure this module:

+
    +
  • Go to Inventory > Configuration > Settings
  • +
  • Activate the traceability
  • +
  • Go to Inventory > Master Data > Products
  • +
  • Create or select a product and set the warranty
  • +
  • Go to the Inventory tab in the Logistics section
  • +
  • Set the warranty duration
  • +
+
+
+

Usage

+

To use this module,

+
    +
  • Go to Inventory > Master Data > Lot/Serial Numbers
  • +
  • Create a new serial number and select a product
  • +
  • The Warranty Expiration Date is automatically computed based on today + the +warranty duration from the select product
  • +
  • You can overwrite the computed date with your own value.
  • +
+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Open Source Integrators
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

This module has been financially supported by:

+ +
+
+

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.

+

Current maintainers:

+

osi-scampbell max3903

+

This module is part of the OCA/rma 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_warranty/tests/__init__.py b/stock_production_lot_warranty/tests/__init__.py new file mode 100644 index 00000000..01c923da --- /dev/null +++ b/stock_production_lot_warranty/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2021 Open Source Integrators +# Copyright (C) 2021 Serpent Consulting Services +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import test_product_lot_warranty diff --git a/stock_production_lot_warranty/tests/test_product_lot_warranty.py b/stock_production_lot_warranty/tests/test_product_lot_warranty.py new file mode 100644 index 00000000..fa665cf3 --- /dev/null +++ b/stock_production_lot_warranty/tests/test_product_lot_warranty.py @@ -0,0 +1,26 @@ +# Copyright (C) 2021 Open Source Integrators +# Copyright (C) 2021 Serpent Consulting Services +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from datetime import datetime, timedelta + +from odoo.tests import common + + +class TestProductLotWarranty(common.TransactionCase): + def test_productlot_warranty(self): + company1 = self.env["res.company"].create({"name": "Test company1"}) + product1 = self.env["product.product"].create( + { + "name": "TestProduct", + "warranty_type": "day", + "warranty": 5, + } + ) + production_lot = self.env["stock.production.lot"].create( + {"product_id": product1.id, "company_id": company1.id} + ) + production_lot._onchange_product_id() + self.assertEqual( + production_lot.warranty_exp_date, + (datetime.now() + timedelta(days=5)).date(), + ) diff --git a/stock_production_lot_warranty/views/stock_production_lot.xml b/stock_production_lot_warranty/views/stock_production_lot.xml new file mode 100644 index 00000000..b83f2f3a --- /dev/null +++ b/stock_production_lot_warranty/views/stock_production_lot.xml @@ -0,0 +1,16 @@ + + + + + stock.production.lot + + + + + + + + + + +