From 4c8d84f72b7db4bc3b36f78aac590f7153d5423c Mon Sep 17 00:00:00 2001 From: Jordi Ballester Date: Wed, 29 Mar 2017 11:38:27 +0200 Subject: [PATCH] [FIX] it should be possible to delete quants after the revaluation has been posted. --- .../models/stock_inventory_revaluation.py | 2 +- .../tests/test_stock_inventory_revaluation.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/stock_inventory_revaluation/models/stock_inventory_revaluation.py b/stock_inventory_revaluation/models/stock_inventory_revaluation.py index bed56379a..e66c6e800 100644 --- a/stock_inventory_revaluation/models/stock_inventory_revaluation.py +++ b/stock_inventory_revaluation/models/stock_inventory_revaluation.py @@ -426,7 +426,7 @@ class StockInventoryRevaluationQuant(models.Model): readonly=True) quant_id = fields.Many2one('stock.quant', 'Quant', required=True, - readonly=True, + readonly=True, ondelete='cascade', domain=[('product_id.type', '=', 'product')]) product_id = fields.Many2one('product.product', 'Product', diff --git a/stock_inventory_revaluation/tests/test_stock_inventory_revaluation.py b/stock_inventory_revaluation/tests/test_stock_inventory_revaluation.py index 7bf22acc6..7ee5ebc61 100644 --- a/stock_inventory_revaluation/tests/test_stock_inventory_revaluation.py +++ b/stock_inventory_revaluation/tests/test_stock_inventory_revaluation.py @@ -234,6 +234,12 @@ class TestStockInventoryRevaluation(TransactionCase): 'Incorrect inventory revaluation for ' 'type Price Change.') + quants = self.env['stock.quant'].search([('product_id', '=', + self.product_real_1.id)]) + + # We should be able to delete the quants afterwards + quants.with_context(force_unlink=True).unlink() + def create_inventory_revaluation_price_change_average(self): revaluation_type = 'price_change' # Create an Inventory Revaluation for average cost product