[ADD] stock_production_lot_warranty

This commit is contained in:
osi-scampbell
2019-01-04 15:43:12 -07:00
committed by Sébastien Alix
parent b8bab682e2
commit 0b0c6fbbdb
11 changed files with 131 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models

View File

@@ -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',
]
}

View File

@@ -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
)

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,2 @@
* Steve Campbell <scampbell@opensourceintegrators.com>
* Maxime Chambreuil <mchambreuil@opensourceintegraors.com>

View File

@@ -0,0 +1,4 @@
This module has been financially supported by:
* Pavlov Media <https://www.pavlovmedia.com>
* Open Source Integrators <https://www.opensourceintegrators.com>

View File

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

View File

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

View File

@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<odoo>
<record id="stock_production_lot_extend_warranty" model="ir.ui.view">
<field name="model">stock.production.lot</field>
<field name="inherit_id" ref="stock.view_production_lot_form"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='main_group']/group[1]"
position="after">
<field name="warranty_exp_date"/>
</xpath>
</field>
</record>
</odoo>