diff --git a/addons/sale/sale.py b/addons/sale/sale.py index f5072a8cacf..b2f66015d86 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -421,11 +421,8 @@ class SaleOrderLine(models.Model): for line in self: qty_invoiced = 0.0 for invoice_line in line.invoice_lines: - if invoice_line.invoice_id.state != 'cancel': - if invoice_line.invoice_id.type == 'out_invoice': - qty_invoiced += invoice_line.quantity - elif invoice_line.invoice_id.type == 'out_refund': - qty_invoiced -= invoice_line.quantity + if invoice_line.invoice_id.state != 'cancel' and invoice_line.invoice_id.type == 'out_invoice': + qty_invoiced += invoice_line.quantity line.qty_invoiced = qty_invoiced @api.depends('price_subtotal', 'product_uom_qty') diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index 1dc2718634e..549dcacf4e7 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -166,8 +166,6 @@ class SaleOrderLine(models.Model): for move in self.procurement_ids.mapped('move_ids').filtered(lambda r: r.state == 'done' and not r.scrapped): if move.location_dest_id.usage == "customer": qty += self.env['product.uom']._compute_qty_obj(move.product_uom, move.product_uom_qty, self.product_uom) - elif move.location_id.usage == "customer": - qty -= self.env['product.uom']._compute_qty_obj(move.product_uom, move.product_uom_qty, self.product_uom) return qty @api.multi diff --git a/addons/sale_stock/tests/test_sale_stock.py b/addons/sale_stock/tests/test_sale_stock.py index 8fc0ccc0b38..95874b67d7b 100644 --- a/addons/sale_stock/tests/test_sale_stock.py +++ b/addons/sale_stock/tests/test_sale_stock.py @@ -164,12 +164,4 @@ class TestSaleStock(TestSale): return_pick.do_new_transfer() # Check invoice - self.assertEqual(self.so.invoice_status, 'to invoice', 'Sale Stock: so invoice_status should be "to invoice" before invoicing') - # let's do an invoice with refunds - adv_wiz = self.env['sale.advance.payment.inv'].with_context(active_ids=[self.so.id]).create({ - 'advance_payment_method': 'all', - }) - adv_wiz.with_context(open_invoices=True).create_invoices() - self.inv_2 = self.so.invoice_ids[1] - self.assertEqual(self.so.invoice_status, 'no', 'Sale Stock: so invoice_status should be "no" after invoicing the return') - self.assertEqual(self.inv_2.amount_untaxed, self.inv_2.amount_untaxed, 'Sale Stock: amount in SO and invoice should be the same') + self.assertEqual(self.so.invoice_status, 'invoiced', 'Sale Stock: so invoice_status should be "invoiced" after picking return')