From e8aaf4ccab6e4caaba89300a60b05c731f940e6f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 26 Nov 2021 09:06:55 +0100 Subject: [PATCH] product_expiry_simple: black, isort, etc... Travis: exclude the module because it conflicts with product_expiry --- .travis.yml | 2 + product_expiry_simple/__manifest__.py | 37 ++++++------- .../models/stock_move_line.py | 6 +-- .../models/stock_production_lot.py | 14 ++--- product_expiry_simple/models/stock_quant.py | 10 ++-- .../views/stock_move_line.xml | 22 ++++++-- .../views/stock_production_lot.xml | 43 ++++++++++----- product_expiry_simple/views/stock_quant.xml | 52 +++++++++++++------ .../odoo/addons/product_expiry_simple | 1 + setup/product_expiry_simple/setup.py | 6 +++ 10 files changed, 125 insertions(+), 68 deletions(-) create mode 120000 setup/product_expiry_simple/odoo/addons/product_expiry_simple create mode 100644 setup/product_expiry_simple/setup.py diff --git a/.travis.yml b/.travis.yml index 5e8e3a666b33..661a42757607 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,8 @@ jobs: env: global: - VERSION="14.0" TESTS="0" LINT_CHECK="0" MAKEPOT="0" + # product_expiry_simple conflicts with product_expiry from the official addons + - EXCLUDE=product_expiry_simple - MQT_DEP=PIP install: diff --git a/product_expiry_simple/__manifest__.py b/product_expiry_simple/__manifest__.py index 1b98a7530053..c7b07d5e1a19 100644 --- a/product_expiry_simple/__manifest__.py +++ b/product_expiry_simple/__manifest__.py @@ -4,26 +4,23 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Product Expiry Simple', - 'version': '14.0.1.0.0', - 'category': 'Product', - 'license': 'AGPL-3', - 'summary': - 'Simpler and better alternative to the official product_expiry module', - 'author': 'Akretion,Jarsa Sistemas,Odoo Community Association (OCA)', - 'maintainers': ['alexis-via'], - 'website': 'http://github.com/OCA/stock-logistics-workflow', - 'depends': [ - 'stock', + "name": "Product Expiry Simple", + "version": "14.0.1.0.0", + "category": "Product", + "license": "AGPL-3", + "summary": "Simpler and better alternative to the official product_expiry module", + "author": "Akretion,Jarsa Sistemas,Odoo Community Association (OCA)", + "maintainers": ["alexis-via"], + "website": "https://github.com/OCA/stock-logistics-workflow", + "depends": [ + "stock", ], - 'excludes': [ - 'product_expiry' + "excludes": ["product_expiry"], + "data": [ + "data/product_removal.xml", + "views/stock_production_lot.xml", + "views/stock_quant.xml", + "views/stock_move_line.xml", ], - 'data': [ - 'data/product_removal.xml', - 'views/stock_production_lot.xml', - 'views/stock_quant.xml', - 'views/stock_move_line.xml', - ], - 'installable': True, + "installable": True, } diff --git a/product_expiry_simple/models/stock_move_line.py b/product_expiry_simple/models/stock_move_line.py index 28066826a874..d208c8801792 100644 --- a/product_expiry_simple/models/stock_move_line.py +++ b/product_expiry_simple/models/stock_move_line.py @@ -7,9 +7,9 @@ class StockMoveLine(models.Model): - _inherit = 'stock.move.line' + _inherit = "stock.move.line" - expiry_date = fields.Date(string='Expiry Date') + expiry_date = fields.Date(string="Expiry Date") # When you read the code of _create_and_assign_production_lot() # you need the defects of that method: @@ -21,4 +21,4 @@ class StockMoveLine(models.Model): def _assign_production_lot(self, lot): super()._assign_production_lot(lot) if self[0].expiry_date: - self.lot_id.write({'expiry_date': self[0].expiry_date}) + self.lot_id.write({"expiry_date": self[0].expiry_date}) diff --git a/product_expiry_simple/models/stock_production_lot.py b/product_expiry_simple/models/stock_production_lot.py index 061bad9b0a6e..f6ab6f00eb09 100644 --- a/product_expiry_simple/models/stock_production_lot.py +++ b/product_expiry_simple/models/stock_production_lot.py @@ -3,14 +3,14 @@ # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models, _ +from odoo import _, api, fields, models class StockProductionLot(models.Model): - _inherit = 'stock.production.lot' + _inherit = "stock.production.lot" - expiry_date = fields.Date(string='Expiry Date') - expired = fields.Boolean(compute='_compute_expired') + expiry_date = fields.Date(string="Expiry Date") + expired = fields.Boolean(compute="_compute_expired") def _compute_expired(self): today = fields.Date.context_today(self) @@ -20,7 +20,7 @@ def _compute_expired(self): expired = True lot.expired = expired - @api.depends('name', 'expiry_date') + @api.depends("name", "expiry_date") def name_get(self): res = [] today = fields.Date.context_today(self) @@ -28,8 +28,8 @@ def name_get(self): dname = lot.name if lot.expiry_date: if lot.expiry_date < today: - dname = _('[%s Expired] %s') % (lot.expiry_date, dname) + dname = _("[%s Expired] %s") % (lot.expiry_date, dname) else: - dname = '[%s] %s' % (lot.expiry_date, dname) + dname = "[%s] %s" % (lot.expiry_date, dname) res.append((lot.id, dname)) return res diff --git a/product_expiry_simple/models/stock_quant.py b/product_expiry_simple/models/stock_quant.py index 43a2169b7e89..0274b7240d8e 100644 --- a/product_expiry_simple/models/stock_quant.py +++ b/product_expiry_simple/models/stock_quant.py @@ -7,15 +7,15 @@ class StockQuant(models.Model): - _inherit = 'stock.quant' + _inherit = "stock.quant" - expiry_date = fields.Date(related='lot_id.expiry_date', store=True) - expired = fields.Boolean(related='lot_id.expired') + expiry_date = fields.Date(related="lot_id.expiry_date", store=True) + expired = fields.Boolean(related="lot_id.expired") # method copy/pasted from the official product_expiry module # Copyright Odoo SA @api.model def _get_removal_strategy_order(self, removal_strategy): - if removal_strategy == 'fefo': - return 'expiry_date, in_date, id' + if removal_strategy == "fefo": + return "expiry_date, in_date, id" return super()._get_removal_strategy_order(removal_strategy) diff --git a/product_expiry_simple/views/stock_move_line.xml b/product_expiry_simple/views/stock_move_line.xml index 33ae1aabdd68..56f3f8f87ff1 100644 --- a/product_expiry_simple/views/stock_move_line.xml +++ b/product_expiry_simple/views/stock_move_line.xml @@ -1,22 +1,34 @@ - + product_expiry_simple.stock.move.line.tree stock.move.line - + - + product_expiry_simple.stock.move.line.tree stock.move.line - + - + diff --git a/product_expiry_simple/views/stock_production_lot.xml b/product_expiry_simple/views/stock_production_lot.xml index 685e0655415a..b0f6aef2ce94 100644 --- a/product_expiry_simple/views/stock_production_lot.xml +++ b/product_expiry_simple/views/stock_production_lot.xml @@ -1,4 +1,4 @@ - + - - Expired + + Expired @@ -23,34 +26,38 @@ product_expiry_simple.stock.quant.tree stock.quant - + - + - expiry_date and expiry_date < current_date + expiry_date and expiry_date < current_date product_expiry_simple.stock.quant.tree.editable stock.quant - + - + - expiry_date and expiry_date < current_date + expiry_date and expiry_date < current_date @@ -58,15 +65,30 @@ product_expiry_simple.stock.quant.search stock.quant - + - - - + + + - + diff --git a/setup/product_expiry_simple/odoo/addons/product_expiry_simple b/setup/product_expiry_simple/odoo/addons/product_expiry_simple new file mode 120000 index 000000000000..edd445bc8233 --- /dev/null +++ b/setup/product_expiry_simple/odoo/addons/product_expiry_simple @@ -0,0 +1 @@ +../../../../product_expiry_simple \ No newline at end of file diff --git a/setup/product_expiry_simple/setup.py b/setup/product_expiry_simple/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/product_expiry_simple/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)