From 0e9dfeb3cba126772fa781551ff7c69e3785e5f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Mon, 3 May 2021 14:31:41 +0200 Subject: [PATCH] [IMP] stock_account_quantity_history_location: black, isort, prettier --- .../stock_account_quantity_history_location | 1 + .../setup.py | 6 ++ .../__init__.py | 2 +- .../__manifest__.py | 25 +++---- .../tests/test_valuation_location.py | 75 ++++++++++--------- .../wizards/__init__.py | 1 - .../wizards/stock_quantity_history.py | 31 ++++---- .../wizards/stock_quantity_history.xml | 12 +-- 8 files changed, 80 insertions(+), 73 deletions(-) create mode 120000 setup/stock_account_quantity_history_location/odoo/addons/stock_account_quantity_history_location create mode 100644 setup/stock_account_quantity_history_location/setup.py diff --git a/setup/stock_account_quantity_history_location/odoo/addons/stock_account_quantity_history_location b/setup/stock_account_quantity_history_location/odoo/addons/stock_account_quantity_history_location new file mode 120000 index 0000000..c405a0f --- /dev/null +++ b/setup/stock_account_quantity_history_location/odoo/addons/stock_account_quantity_history_location @@ -0,0 +1 @@ +../../../../stock_account_quantity_history_location \ No newline at end of file diff --git a/setup/stock_account_quantity_history_location/setup.py b/setup/stock_account_quantity_history_location/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/stock_account_quantity_history_location/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_account_quantity_history_location/__init__.py b/stock_account_quantity_history_location/__init__.py index 326c3db..5cb1c49 100644 --- a/stock_account_quantity_history_location/__init__.py +++ b/stock_account_quantity_history_location/__init__.py @@ -1 +1 @@ -from . import wizards \ No newline at end of file +from . import wizards diff --git a/stock_account_quantity_history_location/__manifest__.py b/stock_account_quantity_history_location/__manifest__.py index e4a553a..6637473 100644 --- a/stock_account_quantity_history_location/__manifest__.py +++ b/stock_account_quantity_history_location/__manifest__.py @@ -3,22 +3,15 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Stock Account Quantity History Location', - 'summary': """ + "name": "Stock Account Quantity History Location", + "summary": """ Glue module between Stock Account and Stock Quantity History Location modules""", - 'version': '12.0.1.1.0', - 'license': 'AGPL-3', - 'author': 'Eficent,' - 'Odoo Community Association (OCA)', - 'website': 'https://github.com/OCA/stock-logistics-reporting', - 'depends': [ - 'stock_account', - 'stock_quantity_history_location', - ], - 'data': [ - 'wizards/stock_quantity_history.xml', - ], - 'auto_install': True, - + "version": "12.0.1.1.0", + "license": "AGPL-3", + "author": "Eficent," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-reporting", + "depends": ["stock_account", "stock_quantity_history_location",], + "data": ["wizards/stock_quantity_history.xml",], + "auto_install": True, } diff --git a/stock_account_quantity_history_location/tests/test_valuation_location.py b/stock_account_quantity_history_location/tests/test_valuation_location.py index 7b8704d..34c591c 100644 --- a/stock_account_quantity_history_location/tests/test_valuation_location.py +++ b/stock_account_quantity_history_location/tests/test_valuation_location.py @@ -1,40 +1,41 @@ # Copyright 2020 Tecnativa - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo.addons.stock_quantity_history_location.tests import ( - test_stock_quantity_history_location + test_stock_quantity_history_location, ) -class TestValuationLocation(test_stock_quantity_history_location - .TestStockQuantityHistoryLocation): +class TestValuationLocation( + test_stock_quantity_history_location.TestStockQuantityHistoryLocation +): @classmethod def setUpClass(cls): super().setUpClass() - cls.env['product.price.history'].create({ - 'datetime': '2019-08-12', - 'product_id': cls.product.id, - 'cost': 35.01, - }) - cls.env['product.price.history'].create({ - 'datetime': '2020-01-01', - 'product_id': cls.product.id, - 'cost': 33.33, - }) - cls.product.categ_id.property_cost_method = 'standard' - cls.test_stock_loc2 = cls.env['stock.location'].create({ - 'usage': 'internal', - 'name': 'Test Stock Location 2', - 'company_id': cls.main_company.id - }) + cls.env["product.price.history"].create( + {"datetime": "2019-08-12", "product_id": cls.product.id, "cost": 35.01,} + ) + cls.env["product.price.history"].create( + {"datetime": "2020-01-01", "product_id": cls.product.id, "cost": 33.33,} + ) + cls.product.categ_id.property_cost_method = "standard" + cls.test_stock_loc2 = cls.env["stock.location"].create( + { + "usage": "internal", + "name": "Test Stock Location 2", + "company_id": cls.main_company.id, + } + ) # Create a move for the past - move = cls.env['stock.move'].create({ - 'name': 'Stock move in', - 'location_id': cls.supplier_location.id, - 'location_dest_id': cls.test_stock_loc2.id, - 'product_id': cls.product.id, - 'product_uom': cls.product.uom_id.id, - 'product_uom_qty': 50.0, - }) + move = cls.env["stock.move"].create( + { + "name": "Stock move in", + "location_id": cls.supplier_location.id, + "location_dest_id": cls.test_stock_loc2.id, + "product_id": cls.product.id, + "product_uom": cls.product.uom_id.id, + "product_uom_qty": 50.0, + } + ) move._action_confirm() move._action_assign() move_line = move.move_line_ids[0] @@ -43,13 +44,15 @@ class TestValuationLocation(test_stock_quantity_history_location move.date = "2020-01-01" def test_stock_location_valuation(self): - wizard = self.env['stock.quantity.history'].create({ - "location_id": self.test_stock_loc2.id, - "include_child_locations": True, - "compute_at_date": 1, - "date": "2020-01-01", - }) - action = wizard.with_context( - company_owned=True, valuation=True).open_table() + wizard = self.env["stock.quantity.history"].create( + { + "location_id": self.test_stock_loc2.id, + "include_child_locations": True, + "compute_at_date": 1, + "date": "2020-01-01", + } + ) + action = wizard.with_context(company_owned=True, valuation=True).open_table() self.assertAlmostEqual( - self.product.with_context(action['context']).stock_value, 1666.5) + self.product.with_context(action["context"]).stock_value, 1666.5 + ) diff --git a/stock_account_quantity_history_location/wizards/__init__.py b/stock_account_quantity_history_location/wizards/__init__.py index 500ceb8..51f2abb 100644 --- a/stock_account_quantity_history_location/wizards/__init__.py +++ b/stock_account_quantity_history_location/wizards/__init__.py @@ -1,2 +1 @@ from . import stock_quantity_history - diff --git a/stock_account_quantity_history_location/wizards/stock_quantity_history.py b/stock_account_quantity_history_location/wizards/stock_quantity_history.py index ec3ba8f..690ee21 100644 --- a/stock_account_quantity_history_location/wizards/stock_quantity_history.py +++ b/stock_account_quantity_history_location/wizards/stock_quantity_history.py @@ -2,35 +2,38 @@ # Copyright 2019 Aleph Objects, Inc. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). import ast + from odoo import models class StockQuantityHistory(models.TransientModel): - _inherit = 'stock.quantity.history' + _inherit = "stock.quantity.history" def open_table(self): """Stock valuation goes by a different path than stock report, so we ensure the correct context as well""" action = super().open_table() - if not self.env.context.get('valuation'): + if not self.env.context.get("valuation"): return action # Show 0 quantities on Inventory Valuation to display Account Valuation # anomalies, such as, non 0 stock_value on cost_method FIFO if not self.location_id: - domain = ast.literal_eval(action['domain']) - domain.pop(domain.index(('qty_available', '!=', 0))) - action['domain'] = domain - ctx = action['context'] + domain = ast.literal_eval(action["domain"]) + domain.pop(domain.index(("qty_available", "!=", 0))) + action["domain"] = domain + ctx = action["context"] if isinstance(ctx, str): ctx = ast.literal_eval(ctx) if self.location_id: - ctx['location'] = self.location_id.id - ctx['compute_child'] = self.include_child_locations - if ctx.get('company_owned', False): - ctx.pop('company_owned') + ctx["location"] = self.location_id.id + ctx["compute_child"] = self.include_child_locations + if ctx.get("company_owned", False): + ctx.pop("company_owned") # Ensure the context isn't added later and catch it - ctx['drop_company_owned'] = True - action['name'] = '%s (%s)' % (action['name'], - self.location_id.complete_name) - action['context'] = ctx + ctx["drop_company_owned"] = True + action["name"] = "%s (%s)" % ( + action["name"], + self.location_id.complete_name, + ) + action["context"] = ctx return action diff --git a/stock_account_quantity_history_location/wizards/stock_quantity_history.xml b/stock_account_quantity_history_location/wizards/stock_quantity_history.xml index 3844ef1..9f64613 100644 --- a/stock_account_quantity_history_location/wizards/stock_quantity_history.xml +++ b/stock_account_quantity_history_location/wizards/stock_quantity_history.xml @@ -1,14 +1,16 @@ - + Valuation Report stock.quantity.history - + - - + +