From 76088202ae12d493544fd59a68e89e1749a921bd Mon Sep 17 00:00:00 2001 From: momegahed Date: Thu, 4 Aug 2022 09:28:51 +0000 Subject: [PATCH] [FIX] sale_stock: duplicate SN/LN for rental products Steps to reproduce: 1. Go to Inventory-->Settings-->Check option to "Display Lots & Serial Numbers on Invoices" 2. Go to Rental App 3. Create a new Rental Order for a product that is tracked by Serial Number. Pop up shows up. Also something to note here, though not necessarily related to this ticket, but you cannot select available serial number from this pop-up. It doesn't let you choose anything even when there are multiple serial number available/in stock. 4. Confirm the order. 5. Validate the Pickup and set the Serial Number in the popup. 6. Create the invoice. 7. Confirm the invoice. 8. Print "Invoices without payment" Bug: in https://github.com/odoo/odoo/commit/7a030f616f7e04b3994fc718840d265b1dd21068 the filter functions were removed. They had the effect of making sure that the sml is either a delivery or a return by filtering on `sml.location_id.usage` and `sml.location_dest_id.usage` Fix: check if the product is a delivery or a return by making sure that either of `sml.location_id.usage` and `sml.location_dest_id.usage` is `customer` OPW-2936505 closes odoo/odoo#97532 X-original-commit: 953fefe736bab1cbfa3ecacd33cd1662a4dcf580 Signed-off-by: Adrien Widart --- addons/sale_stock/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale_stock/models/account_move.py b/addons/sale_stock/models/account_move.py index 83867347393..f6eb02b4a7e 100644 --- a/addons/sale_stock/models/account_move.py +++ b/addons/sale_stock/models/account_move.py @@ -45,7 +45,7 @@ class AccountMove(models.Model): previous_qties_delivered = defaultdict(float) stock_move_lines = current_invoice_amls.sale_line_ids.move_ids.move_line_ids.filtered(lambda sml: sml.state == 'done' and sml.lot_id).sorted(lambda sml: (sml.date, sml.id)) for sml in stock_move_lines: - if sml.product_id not in invoiced_products: + if sml.product_id not in invoiced_products or 'customer' not in {sml.location_id.usage, sml.location_dest_id.usage}: continue product = sml.product_id product_uom = product.uom_id