From a5c82b0c572aba3daf789db54ff2aa26c3cb7682 Mon Sep 17 00:00:00 2001 From: amoyaux Date: Tue, 24 Oct 2017 10:57:09 +0200 Subject: [PATCH] [FIX] sale_stock: delivered quantity blocked by expense policy Use case to reproduce - Set a product to be expensed - set the expense_policy to something else than no - Do a delivery order with a picking - Validate the picking -> Delivered quantity to 0 and impossible to create an invoice if the invoice_policy is delivered_quantity It happens due to this commit 48ea59d46e26b7b5a8eebfe06740482f1a263d72 What does it do: - The move could be generated by an expense. - If the move has 'no' as expense policy thus we won't add it in the invoice Problem we can't guess if the move come from an expense or not (limitation). This commit increments the delivered quanity if the product can not be expense anymore opw-777139 --- addons/sale_stock/models/stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale_stock/models/stock.py b/addons/sale_stock/models/stock.py index 054b070b152..4f56b148a33 100644 --- a/addons/sale_stock/models/stock.py +++ b/addons/sale_stock/models/stock.py @@ -22,7 +22,7 @@ class StockMove(models.Model): result = super(StockMove, self).action_done() # Update delivered quantities on sale order lines - sale_order_lines = self.filtered(lambda move: move.procurement_id.sale_line_id and move.product_id.expense_policy == 'no').mapped('procurement_id.sale_line_id') + sale_order_lines = self.filtered(lambda move: move.procurement_id.sale_line_id and (not move.product_id.can_be_expensed or move.product_id.expense_policy=='no')).mapped('procurement_id.sale_line_id') for line in sale_order_lines: line.qty_delivered = line._get_delivered_qty() return result