From 2ff788b79659cd2e24f3963d8ad68482cba9fc1f Mon Sep 17 00:00:00 2001 From: Chanakya Soni Date: Wed, 16 Jun 2021 19:44:35 +0530 Subject: [PATCH] [14.0][FIX] Travis. --- stock_production_lot_warranty/__manifest__.py | 36 ++++++------ .../models/__init__.py | 4 +- .../models/stock_production_lot.py | 56 ++++++++++--------- .../views/stock_production_lot.xml | 9 ++- 4 files changed, 53 insertions(+), 52 deletions(-) diff --git a/stock_production_lot_warranty/__manifest__.py b/stock_production_lot_warranty/__manifest__.py index f78add05..c6c30beb 100644 --- a/stock_production_lot_warranty/__manifest__.py +++ b/stock_production_lot_warranty/__manifest__.py @@ -2,24 +2,24 @@ # 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': '12.0.1.0.0', - 'license': 'AGPL-3', - 'author': 'Open Source Integrators, Odoo Community Association (OCA)', - 'category': 'Stock', - 'website': 'https://github.com/OCA/rma', - 'depends': [ - 'product_warranty', - 'stock', + "name": "Warranty Date on Lot/Serial Numbers", + "summary": "Add warranty date to stock production lot", + "version": "14.0.1.0.0", + "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', + "data": [ + "views/stock_production_lot.xml", + ], + "installable": True, + "development_status": "Beta", + "maintainers": [ + "osi-scampbell", + "max3903", ], - 'installable': True, - '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 index 3e187a92..dad7ec54 100644 --- a/stock_production_lot_warranty/models/__init__.py +++ b/stock_production_lot_warranty/models/__init__.py @@ -1,5 +1,3 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from . import ( - stock_production_lot -) +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 index ddb58d5d..aa5a8073 100644 --- a/stock_production_lot_warranty/models/stock_production_lot.py +++ b/stock_production_lot_warranty/models/stock_production_lot.py @@ -2,41 +2,45 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). 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): - _inherit = 'stock.production.lot' + _inherit = "stock.production.lot" - warranty_exp_date = fields.Date(string='Warranty Expiration Date') + warranty_exp_date = fields.Date(string="Warranty Expiration Date") - @api.onchange('product_id') + @api.onchange("product_id") def _onchange_product_id(self): 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: + 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) + 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/views/stock_production_lot.xml b/stock_production_lot_warranty/views/stock_production_lot.xml index f8e4939b..b83f2f3a 100644 --- a/stock_production_lot_warranty/views/stock_production_lot.xml +++ b/stock_production_lot_warranty/views/stock_production_lot.xml @@ -1,14 +1,13 @@ - + stock.production.lot - + - + - +