From 51670530d5404e5c60a77dfa941f7a53ad239ed8 Mon Sep 17 00:00:00 2001 From: Murtuza Saleh Date: Tue, 23 Apr 2019 15:05:04 +0530 Subject: [PATCH] [WIP][MIG][12.0] stock_production_lot_warranty --- stock_production_lot_warranty/README.rst | 9 ++-- stock_production_lot_warranty/__manifest__.py | 4 +- .../models/__init__.py | 1 - .../models/stock_production_lot.py | 52 +++++++++++-------- .../readme/CONTRIBUTORS.rst | 1 + .../static/description/index.html | 5 +- .../views/stock_production_lot.xml | 4 +- 7 files changed, 43 insertions(+), 33 deletions(-) diff --git a/stock_production_lot_warranty/README.rst b/stock_production_lot_warranty/README.rst index 8abf9333..52bfba20 100644 --- a/stock_production_lot_warranty/README.rst +++ b/stock_production_lot_warranty/README.rst @@ -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 * Maxime Chambreuil +* Serpent Consulting Services Pvt. Ltd. Other credits ~~~~~~~~~~~~~ @@ -114,6 +115,6 @@ Current `maintainers `__: |maintainer-osi-scampbell| |maintainer-max3903| -This module is part of the `OCA/rma `_ project on GitHub. +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/__manifest__.py b/stock_production_lot_warranty/__manifest__.py index e585d1bf..f78add05 100644 --- a/stock_production_lot_warranty/__manifest__.py +++ b/stock_production_lot_warranty/__manifest__.py @@ -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', diff --git a/stock_production_lot_warranty/models/__init__.py b/stock_production_lot_warranty/models/__init__.py index 45eb3ad2..3e187a92 100644 --- a/stock_production_lot_warranty/models/__init__.py +++ b/stock_production_lot_warranty/models/__init__.py @@ -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 ( diff --git a/stock_production_lot_warranty/models/stock_production_lot.py b/stock_production_lot_warranty/models/stock_production_lot.py index 7fa36661..ddb58d5d 100644 --- a/stock_production_lot_warranty/models/stock_production_lot.py +++ b/stock_production_lot_warranty/models/stock_production_lot.py @@ -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 diff --git a/stock_production_lot_warranty/readme/CONTRIBUTORS.rst b/stock_production_lot_warranty/readme/CONTRIBUTORS.rst index 484c2429..d2767f98 100644 --- a/stock_production_lot_warranty/readme/CONTRIBUTORS.rst +++ b/stock_production_lot_warranty/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Steve Campbell * Maxime Chambreuil +* Serpent Consulting Services Pvt. Ltd. diff --git a/stock_production_lot_warranty/static/description/index.html b/stock_production_lot_warranty/static/description/index.html index f90678bc..629b5ef5 100644 --- a/stock_production_lot_warranty/static/description/index.html +++ b/stock_production_lot_warranty/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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.

@@ -430,6 +430,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
@@ -449,7 +450,7 @@ 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.

+

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/views/stock_production_lot.xml b/stock_production_lot_warranty/views/stock_production_lot.xml index 37dcab83..f8e4939b 100644 --- a/stock_production_lot_warranty/views/stock_production_lot.xml +++ b/stock_production_lot_warranty/views/stock_production_lot.xml @@ -1,4 +1,4 @@ - + @@ -7,7 +7,9 @@ + +