From b7b36ca09b9d058a6b95aa45571d46713695dd0e 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 398b6f3b8..83836f4f3 100644 --- a/stock_inventory_revaluation/models/stock_inventory_revaluation.py +++ b/stock_inventory_revaluation/models/stock_inventory_revaluation.py @@ -425,7 +425,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 1a976d88f..a94aa6250 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