[WIP][MIG][12.0] stock_production_lot_warranty

This commit is contained in:
Murtuza Saleh
2019-04-23 15:05:04 +05:30
parent bbebf412d9
commit 51670530d5
7 changed files with 43 additions and 33 deletions

View File

@@ -14,13 +14,13 @@ Warranty Date on Lot/Serial Numbers
: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/11.0/stock_production_lot_warranty
: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-11-0/rma-11-0-stock_production_lot_warranty
: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/11.0
:target: https://runbot.odoo-community.org/runbot/145/12.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -81,6 +81,7 @@ Contributors
* Steve Campbell <scampbell@opensourceintegrators.com>
* Maxime Chambreuil <mchambreuil@opensourceintegraors.com>
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
Other credits
~~~~~~~~~~~~~
@@ -114,6 +115,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-osi-scampbell| |maintainer-max3903|
This module is part of the `OCA/rma <https://github.com/OCA/rma/tree/11.0/stock_production_lot_warranty>`_ project on GitHub.
This module is part of the `OCA/rma <https://github.com/OCA/rma/tree/12.0/stock_production_lot_warranty>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -4,7 +4,7 @@
{
'name': 'Warranty Date on Lot/Serial Numbers',
'summary': 'Add warranty date to stock production lot',
'version': '11.0.0.0.1',
'version': '12.0.1.0.0',
'license': 'AGPL-3',
'author': 'Open Source Integrators, Odoo Community Association (OCA)',
'category': 'Stock',
@@ -16,7 +16,7 @@
'data': [
'views/stock_production_lot.xml',
],
'application': False,
'installable': True,
'development_status': 'Beta',
'maintainers': [
'osi-scampbell',

View File

@@ -1,4 +1,3 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import (

View File

@@ -1,9 +1,10 @@
# 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
from dateutil.relativedelta import relativedelta
from odoo import api, fields, models
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
class StockProductionLot(models.Model):
@@ -13,24 +14,29 @@ class StockProductionLot(models.Model):
@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
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
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

View File

@@ -1,2 +1,3 @@
* Steve Campbell <scampbell@opensourceintegrators.com>
* Maxime Chambreuil <mchambreuil@opensourceintegraors.com>
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/rma/tree/11.0/stock_production_lot_warranty"><img alt="OCA/rma" src="https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/rma-11-0/rma-11-0-stock_production_lot_warranty"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/145/11.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/rma/tree/12.0/stock_production_lot_warranty"><img alt="OCA/rma" src="https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/rma-12-0/rma-12-0-stock_production_lot_warranty"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/145/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Odoo does not provide the warranty information on the serial number of a product.</p>
<p>This module allows you to compute the warranty expiration date of a serialized
product based on the warranty duration.</p>
@@ -430,6 +430,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<ul class="simple">
<li>Steve Campbell &lt;<a class="reference external" href="mailto:scampbell&#64;opensourceintegrators.com">scampbell&#64;opensourceintegrators.com</a>&gt;</li>
<li>Maxime Chambreuil &lt;<a class="reference external" href="mailto:mchambreuil&#64;opensourceintegraors.com">mchambreuil&#64;opensourceintegraors.com</a>&gt;</li>
<li>Serpent Consulting Services Pvt. Ltd. &lt;<a class="reference external" href="mailto:support&#64;serpentcs.com">support&#64;serpentcs.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
@@ -449,7 +450,7 @@ mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external" href="https://github.com/osi-scampbell"><img alt="osi-scampbell" src="https://github.com/osi-scampbell.png?size=40px" /></a> <a class="reference external" href="https://github.com/max3903"><img alt="max3903" src="https://github.com/max3903.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rma/tree/11.0/stock_production_lot_warranty">OCA/rma</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rma/tree/12.0/stock_production_lot_warranty">OCA/rma</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="stock_production_lot_extend_warranty" model="ir.ui.view">
@@ -7,7 +7,9 @@
<field name="arch" type="xml">
<xpath expr="//group[@name='main_group']/group[1]"
position="after">
<group>
<field name="warranty_exp_date"/>
</group>
</xpath>
</field>
</record>