From 609035bfd135a8a3727a0111ef3ac675d4535b3d Mon Sep 17 00:00:00 2001 From: AaronHForgeFlow Date: Sat, 30 Oct 2021 10:20:30 +0200 Subject: [PATCH] [14.0][MIG]stock_account_valuation_report --- .../__manifest__.py | 8 ++- .../security/ir.model.access.csv | 2 + .../test_stock_account_valuation_report.py | 67 +++++++++---------- .../wizards/stock_valuation_history.py | 4 +- 4 files changed, 43 insertions(+), 38 deletions(-) create mode 100644 stock_account_valuation_report/security/ir.model.access.csv diff --git a/stock_account_valuation_report/__manifest__.py b/stock_account_valuation_report/__manifest__.py index e7b287b..e5b4619 100644 --- a/stock_account_valuation_report/__manifest__.py +++ b/stock_account_valuation_report/__manifest__.py @@ -4,13 +4,17 @@ { "name": "Stock Account Valuation Report", - "version": "13.0.1.0.0", + "version": "14.0.1.0.0", "summary": "Improves logic of the Inventory Valuation Report", "author": "ForgeFlow S.L., Odoo Community Association (OCA)", "website": "https://github.com/OCA/stock-logistics-reporting", "category": "Warehouse Management", "depends": ["stock_account"], "license": "AGPL-3", - "data": ["views/product_product_views.xml", "wizards/stock_valuation_history.xml"], + "data": [ + "security/ir.model.access.csv", + "views/product_product_views.xml", + "wizards/stock_valuation_history.xml", + ], "installable": True, } diff --git a/stock_account_valuation_report/security/ir.model.access.csv b/stock_account_valuation_report/security/ir.model.access.csv new file mode 100644 index 0000000..31dca36 --- /dev/null +++ b/stock_account_valuation_report/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_stock_valuation_history,access.stock.valuation.history,model_stock_valuation_history,stock.group_stock_user,1,1,1,1 diff --git a/stock_account_valuation_report/tests/test_stock_account_valuation_report.py b/stock_account_valuation_report/tests/test_stock_account_valuation_report.py index b548d22..8385bec 100644 --- a/stock_account_valuation_report/tests/test_stock_account_valuation_report.py +++ b/stock_account_valuation_report/tests/test_stock_account_valuation_report.py @@ -130,7 +130,6 @@ class TestStockAccountValuationReport(TransactionCase): "type": "product", "standard_price": standard_price, "valuation": "real_time", - "invoice_policy": "delivery", } ) return template.product_variant_ids[0] @@ -251,32 +250,32 @@ class TestStockAccountValuationReport(TransactionCase): aml = self.aml_model.search([("product_id", "=", self.product.id)]) inv_aml = aml.filtered(lambda l: l.account_id == self.account_inventory) balance_inv = sum(inv_aml.mapped("balance")) - self.assertEquals(balance_inv, 10.0) + self.assertEqual(balance_inv, 10.0) move = in_picking.move_lines layer = self.layer_model.search([("stock_move_id", "=", move.id)]) - self.assertEquals(layer.remaining_value, 10.0) + self.assertEqual(layer.remaining_value, 10.0) # The accounting value and the stock value match - self.assertEquals(self.product.stock_value, 10.0) - self.assertEquals(self.product.account_value, 10.0) + self.assertEqual(self.product.stock_value, 10.0) + self.assertEqual(self.product.account_value, 10.0) # The qty also match - self.assertEquals(self.product.qty_at_date, 1.0) - self.assertEquals(self.product.account_qty_at_date, 1.0) + self.assertEqual(self.product.qty_at_date, 1.0) + self.assertEqual(self.product.account_qty_at_date, 1.0) # Create an out picking out_picking = self._create_delivery(self.product, 1) self._do_picking(out_picking, fields.Datetime.now(), 1.0) # The original layer must have been reduced. - self.assertEquals(layer.remaining_qty, 0.0) - self.assertEquals(layer.remaining_value, 0.0) + self.assertEqual(layer.remaining_qty, 0.0) + self.assertEqual(layer.remaining_value, 0.0) # The layer out took that out move = out_picking.move_lines layer = self.layer_model.search([("stock_move_id", "=", move.id)]) - self.assertEquals(layer.value, -10.0) + self.assertEqual(layer.value, -10.0) # The report shows the material is gone self.product._compute_inventory_value() - self.assertEquals(self.product.stock_value, 0.0) - self.assertEquals(self.product.account_value, 0.0) - self.assertEquals(self.product.qty_at_date, 0.0) - self.assertEquals(self.product.account_qty_at_date, 0.0) + self.assertEqual(self.product.stock_value, 0.0) + self.assertEqual(self.product.account_value, 0.0) + self.assertEqual(self.product.qty_at_date, 0.0) + self.assertEqual(self.product.account_qty_at_date, 0.0) def test_02_drop_ship(self): """Drop shipment from vendor to customer""" @@ -295,20 +294,20 @@ class TestStockAccountValuationReport(TransactionCase): # Inventory is 0 inv_aml = aml.filtered(lambda l: l.account_id == self.account_inventory) balance_inv = sum(inv_aml.mapped("balance")) - self.assertEquals(balance_inv, 0.0) + self.assertEqual(balance_inv, 0.0) # There are two a stock valuation layers associated to this product move = dropship_picking.move_lines layers = self.layer_model.search([("stock_move_id", "=", move.id)]) - self.assertEquals(len(layers), 2) + self.assertEqual(len(layers), 2) in_layer = layers.filtered(lambda l: l.quantity > 0) # Check that the layer created for the outgoing move - self.assertEquals(in_layer.remaining_qty, 0.0) - self.assertEquals(in_layer.remaining_value, 0.0) + self.assertEqual(in_layer.remaining_qty, 0.0) + self.assertEqual(in_layer.remaining_value, 0.0) # The report shows the material is gone - self.assertEquals(self.product.stock_value, 0.0) - self.assertEquals(self.product.account_value, 0.0) - self.assertEquals(self.product.qty_at_date, 0.0) - self.assertEquals(self.product.account_qty_at_date, 0.0) + self.assertEqual(self.product.stock_value, 0.0) + self.assertEqual(self.product.account_value, 0.0) + self.assertEqual(self.product.qty_at_date, 0.0) + self.assertEqual(self.product.account_qty_at_date, 0.0) def test_03_stock_receipt_several_costs_several_dates(self): """Receive into stock at different cost""" @@ -325,10 +324,10 @@ class TestStockAccountValuationReport(TransactionCase): aml = self.aml_model.search([("product_id", "=", self.product.id)]) inv_aml = aml.filtered(lambda l: l.account_id == self.account_inventory) balance_inv = sum(inv_aml.mapped("balance")) - self.assertEquals(balance_inv, 10.0) + self.assertEqual(balance_inv, 10.0) move = in_picking.move_lines layer = self.layer_model.search([("stock_move_id", "=", move.id)]) - self.assertEquals(layer.remaining_value, 10.0) + self.assertEqual(layer.remaining_value, 10.0) # Receive more in_picking2 = self._create_receipt(self.product, 2.0, False, 20.0) # Receive two unitsat double cost. @@ -344,15 +343,15 @@ class TestStockAccountValuationReport(TransactionCase): aml = self.aml_model.search([("product_id", "=", self.product.id)]) inv_aml = aml.filtered(lambda l: l.account_id == self.account_inventory) balance_inv = sum(inv_aml.mapped("balance")) - self.assertEquals(balance_inv, 50.0) + self.assertEqual(balance_inv, 50.0) move2 = in_picking2.move_lines layer = self.layer_model.search([("stock_move_id", "=", move2.id)]) - self.assertEquals(layer.remaining_value, 40.0) + self.assertEqual(layer.remaining_value, 40.0) # Now we check the report reflects the same - self.assertEquals(self.product.stock_value, 50.0) - self.assertEquals(self.product.account_value, 50.0) - self.assertEquals(self.product.qty_at_date, 3.0) - self.assertEquals(self.product.account_qty_at_date, 3.0) + self.assertEqual(self.product.stock_value, 50.0) + self.assertEqual(self.product.account_value, 50.0) + self.assertEqual(self.product.qty_at_date, 3.0) + self.assertEqual(self.product.account_qty_at_date, 3.0) # That is the value tomorrow, today it is less # We hack the date in the account move, not a topic for this module aml_layer = layer.account_move_id.line_ids @@ -363,7 +362,7 @@ class TestStockAccountValuationReport(TransactionCase): self.product.with_context( at_date=fields.Datetime.now() + relativedelta(days=1) )._compute_inventory_value() - self.assertEquals(self.product.stock_value, 10.0) - self.assertEquals(self.product.account_value, 10.0) - self.assertEquals(self.product.qty_at_date, 1.0) - self.assertEquals(self.product.account_qty_at_date, 1.0) + self.assertEqual(self.product.stock_value, 10.0) + self.assertEqual(self.product.account_value, 10.0) + self.assertEqual(self.product.qty_at_date, 1.0) + self.assertEqual(self.product.account_qty_at_date, 1.0) diff --git a/stock_account_valuation_report/wizards/stock_valuation_history.py b/stock_account_valuation_report/wizards/stock_valuation_history.py index fd7cea7..1e88501 100644 --- a/stock_account_valuation_report/wizards/stock_valuation_history.py +++ b/stock_account_valuation_report/wizards/stock_valuation_history.py @@ -16,8 +16,8 @@ class StockValuationHistory(models.TransientModel): ) def open_at_date(self): - action = self.env["ir.actions.act_window"].for_xml_id( - "stock_account_valuation_report", "product_valuation_action" + action = self.env["ir.actions.act_window"]._for_xml_id( + "stock_account_valuation_report.product_valuation_action" ) domain = [("type", "=", "product")] product_id = self.env.context.get("product_id", False)