From 5b206c1c570017a05f8f364b9e8949869afc5ce3 Mon Sep 17 00:00:00 2001 From: "Matheus Leal Viana (malv)" Date: Mon, 8 May 2023 14:30:38 +0000 Subject: [PATCH] [IMP] sale_stock: test propagation of incoterm on down-payment Ensure that, when creating a down-payment invoice for a SO with an incoterm, this invoice should have the same incoterm as the SO. Steps: 1. Create a SO with an incoterm 2. Create a down-payment invoice for this SO 3. The new invoice should have the same incoterm as the SO closes odoo/odoo#122770 Opw: 3284556 X-original-commit: d854045c4d25216394a834e44f9948303529c302 Signed-off-by: malv-odoo Signed-off-by: Adrien Widart (awt) --- addons/sale_stock/tests/test_sale_stock.py | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/addons/sale_stock/tests/test_sale_stock.py b/addons/sale_stock/tests/test_sale_stock.py index 2b6679a2868..ba16938dec9 100644 --- a/addons/sale_stock/tests/test_sale_stock.py +++ b/addons/sale_stock/tests/test_sale_stock.py @@ -1413,6 +1413,44 @@ class TestSaleStock(TestSaleCommon, ValuationReconciliationTestCommon): self.assertEqual(ship01.move_ids.move_orig_ids, (pick01 | pick02).move_ids) self.assertEqual(ship02.move_ids.move_orig_ids, (pick01 | pick02).move_ids) + def test_incoterm_in_advance_payment(self): + """When generating a advance payment invoice from a SO, this invoice incoterm should be the same as the SO""" + + incoterm = self.env['account.incoterms'].create({ + 'name': 'Test Incoterm', + 'code': 'TEST', + }) + + so = self.env['sale.order'].create({ + 'partner_id': self.partner_a.id, + 'incoterm': incoterm.id, + 'order_line': [(0, 0, { + 'name': self.product_a.name, + 'product_id': self.product_a.id, + 'product_uom_qty': 10, + 'product_uom': self.product_a.uom_id.id, + 'price_unit': 1, + })], + }) + so.action_confirm() + + advance_product = self.env['product.product'].create({ + 'name': 'Deposit', + 'type': 'service', + 'invoice_policy': 'order', + }) + + adv_wiz = self.env['sale.advance.payment.inv'].with_context(active_ids=[so.id]).create({ + 'advance_payment_method': 'percentage', + 'amount': 5.0, + 'product_id': advance_product.id, + }) + + act = adv_wiz.with_context(open_invoices=True).create_invoices() + invoice = self.env['account.move'].browse(act['res_id']) + + self.assertEqual(invoice.invoice_incoterm_id.id, incoterm.id) + def test_exception_delivery_partial_multi(self): """ When a backorder is cancelled for a picking in multi-picking,