From 208df590d87fa32433a3a2e61331c59e982d148d Mon Sep 17 00:00:00 2001 From: Sergio Teruel Date: Fri, 7 Feb 2020 23:33:07 +0100 Subject: [PATCH] [IMP] stock_inventory_cost_info: black, isort --- stock_inventory_cost_info/__manifest__.py | 16 ++--- stock_inventory_cost_info/hooks.py | 12 ++-- .../models/stock_inventory.py | 8 +-- .../tests/test_stock_inventory_cost_info.py | 61 +++++++++++-------- 4 files changed, 52 insertions(+), 45 deletions(-) diff --git a/stock_inventory_cost_info/__manifest__.py b/stock_inventory_cost_info/__manifest__.py index 9d537bd06..bf88649fe 100644 --- a/stock_inventory_cost_info/__manifest__.py +++ b/stock_inventory_cost_info/__manifest__.py @@ -5,19 +5,13 @@ "name": "Stock Inventory Cost Info", "summary": "Shows the cost of the inventory adjustments", "version": "12.0.1.0.0", - "author": "Tecnativa, " - "Odoo Community Association (OCA)", + "author": "Tecnativa, " "Odoo Community Association (OCA)", "website": "https://github.com/OCA/stock-logistics-warehouse", "category": "Warehouse", - "depends": [ - "stock", - ], - "data": [ - "views/stock_inventory_views.xml", - "views/report_stockinventory.xml", - ], + "depends": ["stock"], + "data": ["views/stock_inventory_views.xml", "views/report_stockinventory.xml"], "pre_init_hook": "pre_init_hook", "license": "AGPL-3", - 'installable': True, - 'application': False, + "installable": True, + "application": False, } diff --git a/stock_inventory_cost_info/hooks.py b/stock_inventory_cost_info/hooks.py index 590b6175a..2811ac8e8 100644 --- a/stock_inventory_cost_info/hooks.py +++ b/stock_inventory_cost_info/hooks.py @@ -3,9 +3,13 @@ def pre_init_hook(cr): - cr.execute("""ALTER TABLE stock_inventory_line + cr.execute( + """ALTER TABLE stock_inventory_line ADD COLUMN adjustment_cost numeric - DEFAULT 0""") + DEFAULT 0""" + ) - cr.execute("""ALTER TABLE stock_inventory_line - ALTER COLUMN adjustment_cost DROP DEFAULT;""") + cr.execute( + """ALTER TABLE stock_inventory_line + ALTER COLUMN adjustment_cost DROP DEFAULT;""" + ) diff --git a/stock_inventory_cost_info/models/stock_inventory.py b/stock_inventory_cost_info/models/stock_inventory.py index 65aa93393..2c630733d 100644 --- a/stock_inventory_cost_info/models/stock_inventory.py +++ b/stock_inventory_cost_info/models/stock_inventory.py @@ -8,14 +8,10 @@ class InventoryLine(models.Model): _inherit = "stock.inventory.line" currency_id = fields.Many2one( - string="Currency", - related="inventory_id.company_id.currency_id", - readonly=True, + string="Currency", related="inventory_id.company_id.currency_id", readonly=True ) adjustment_cost = fields.Monetary( - string="Adjustment cost", - compute="_compute_adjustment_cost", - store=True, + string="Adjustment cost", compute="_compute_adjustment_cost", store=True ) @api.depends("product_qty", "theoretical_qty", "inventory_id.state") diff --git a/stock_inventory_cost_info/tests/test_stock_inventory_cost_info.py b/stock_inventory_cost_info/tests/test_stock_inventory_cost_info.py index fac3918c5..7e4fb44c8 100644 --- a/stock_inventory_cost_info/tests/test_stock_inventory_cost_info.py +++ b/stock_inventory_cost_info/tests/test_stock_inventory_cost_info.py @@ -8,30 +8,43 @@ from odoo.tests.common import TransactionCase class TestStockInventoryCostInfo(TransactionCase): def setUp(self): super(TestStockInventoryCostInfo, self).setUp() - product_obj = self.env['product.product'] - self.product_1 = product_obj.create({ - 'name': 'product test 1', - 'type': 'product', - 'standard_price': 1000, - }) - self.product_2 = product_obj.create({ - 'name': 'product test 2', - 'type': 'product', - 'standard_price': 2000, - }) - self.inventory = self.env['stock.inventory'].create({ - 'name': 'Another inventory', - 'filter': 'partial', - 'line_ids': [(0, 0, { - 'product_id': self.product_1.id, - 'product_qty': 10, - 'location_id': self.env.ref('stock.warehouse0').lot_stock_id.id - }), (0, 0, { - 'product_id': self.product_2.id, - 'product_qty': 20, - 'location_id': self.env.ref('stock.warehouse0').lot_stock_id.id - })] - }) + product_obj = self.env["product.product"] + self.product_1 = product_obj.create( + {"name": "product test 1", "type": "product", "standard_price": 1000} + ) + self.product_2 = product_obj.create( + {"name": "product test 2", "type": "product", "standard_price": 2000} + ) + self.inventory = self.env["stock.inventory"].create( + { + "name": "Another inventory", + "filter": "partial", + "line_ids": [ + ( + 0, + 0, + { + "product_id": self.product_1.id, + "product_qty": 10, + "location_id": self.env.ref( + "stock.warehouse0" + ).lot_stock_id.id, + }, + ), + ( + 0, + 0, + { + "product_id": self.product_2.id, + "product_qty": 20, + "location_id": self.env.ref( + "stock.warehouse0" + ).lot_stock_id.id, + }, + ), + ], + } + ) def test_compute_adjustment_cost(self): """Tests if the adjustment_cost is correctly computed."""