diff --git a/stock_production_lot_warranty/README.rst b/stock_production_lot_warranty/README.rst new file mode 100644 index 00000000..21cd7854 --- /dev/null +++ b/stock_production_lot_warranty/README.rst @@ -0,0 +1,21 @@ +**This file is going to be generated by oca-gen-addon-readme.** + +*Manual changes will be overwritten.* + +Please provide content in the ``readme`` directory: + +* **DESCRIPTION.rst** (required) +* INSTALL.rst (optional) +* CONFIGURE.rst (optional) +* **USAGE.rst** (optional, highly recommended) +* DEVELOP.rst (optional) +* ROADMAP.rst (optional) +* HISTORY.rst (optional, recommended) +* **CONTRIBUTORS.rst** (optional, highly recommended) +* CREDITS.rst (optional) + +Content of this README will also be drawn from the addon manifest, +from keys such as name, authors, maintainers, development_status, +and license. + +A good, one sentence summary in the manifest is also highly recommended. 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..e585d1bf --- /dev/null +++ b/stock_production_lot_warranty/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright (C) 2018 - TODAY, Open Source Integrators +# 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': '11.0.0.0.1', + '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', + ], + 'application': False, + 'development_status': 'Beta', + 'maintainers': [ + 'osi-scampbell', + 'max3903', + ] +} diff --git a/stock_production_lot_warranty/models/__init__.py b/stock_production_lot_warranty/models/__init__.py new file mode 100644 index 00000000..45eb3ad2 --- /dev/null +++ b/stock_production_lot_warranty/models/__init__.py @@ -0,0 +1,6 @@ +# Copyright (C) 2018 - TODAY, Open Source Integrators +# 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..7fa36661 --- /dev/null +++ b/stock_production_lot_warranty/models/stock_production_lot.py @@ -0,0 +1,36 @@ +# Copyright (C) 2018 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models, api +from dateutil.relativedelta import relativedelta +from datetime import datetime, timedelta + + +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): + if self.product_id: + if (self.product_id.product_tmpl_id.warranty_type and + self.product_id.product_tmpl_id.warranty): + today_date = datetime.now() + if self.product_id.product_tmpl_id.warranty_type == 'day': + time = (today_date + + timedelta(days=self.product_id. + product_tmpl_id.warranty)) + elif self.product_id.product_tmpl_id.warranty_type == 'week': + time = (today_date + + timedelta(weeks=self.product_id. + product_tmpl_id.warranty)) + elif self.product_id.product_tmpl_id.warranty_type == 'month': + time = (today_date + + relativedelta(months=+self.product_id. + product_tmpl_id.warranty)) + elif self.product_id.product_tmpl_id.warranty_type == 'year': + time = (today_date + + relativedelta(years=+self.product_id. + product_tmpl_id.warranty)) + 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..39a9d0fe --- /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 > 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 diff --git a/stock_production_lot_warranty/readme/CONTRIBUTORS.rst b/stock_production_lot_warranty/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..484c2429 --- /dev/null +++ b/stock_production_lot_warranty/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Steve Campbell +* Maxime Chambreuil 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..3bcbead5 --- /dev/null +++ b/stock_production_lot_warranty/readme/USAGE.rst @@ -0,0 +1,7 @@ +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. 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..37dcab83 --- /dev/null +++ b/stock_production_lot_warranty/views/stock_production_lot.xml @@ -0,0 +1,15 @@ + + + + + stock.production.lot + + + + + + + + +