mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[ADD] stock_production_lot_warranty
This commit is contained in:
committed by
Sébastien Alix
parent
b8bab682e2
commit
0b0c6fbbdb
21
stock_production_lot_warranty/README.rst
Normal file
21
stock_production_lot_warranty/README.rst
Normal 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.
|
||||||
3
stock_production_lot_warranty/__init__.py
Normal file
3
stock_production_lot_warranty/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from . import models
|
||||||
25
stock_production_lot_warranty/__manifest__.py
Normal file
25
stock_production_lot_warranty/__manifest__.py
Normal 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',
|
||||||
|
]
|
||||||
|
}
|
||||||
6
stock_production_lot_warranty/models/__init__.py
Normal file
6
stock_production_lot_warranty/models/__init__.py
Normal 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
|
||||||
|
)
|
||||||
36
stock_production_lot_warranty/models/stock_production_lot.py
Normal file
36
stock_production_lot_warranty/models/stock_production_lot.py
Normal 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
|
||||||
8
stock_production_lot_warranty/readme/CONFIGURE.rst
Normal file
8
stock_production_lot_warranty/readme/CONFIGURE.rst
Normal 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
|
||||||
2
stock_production_lot_warranty/readme/CONTRIBUTORS.rst
Normal file
2
stock_production_lot_warranty/readme/CONTRIBUTORS.rst
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
* Steve Campbell <scampbell@opensourceintegrators.com>
|
||||||
|
* Maxime Chambreuil <mchambreuil@opensourceintegraors.com>
|
||||||
4
stock_production_lot_warranty/readme/CREDITS.rst
Normal file
4
stock_production_lot_warranty/readme/CREDITS.rst
Normal 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>
|
||||||
4
stock_production_lot_warranty/readme/DESCRIPTION.rst
Normal file
4
stock_production_lot_warranty/readme/DESCRIPTION.rst
Normal 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.
|
||||||
7
stock_production_lot_warranty/readme/USAGE.rst
Normal file
7
stock_production_lot_warranty/readme/USAGE.rst
Normal 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.
|
||||||
15
stock_production_lot_warranty/views/stock_production_lot.xml
Normal file
15
stock_production_lot_warranty/views/stock_production_lot.xml
Normal 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>
|
||||||
Reference in New Issue
Block a user