Skip to content

Commit 5e4b032

Browse files
committed
Merge PR #3746 into 18.0
Signed-off-by rousseldenis
2 parents 8b42f0b + 75939d9 commit 5e4b032

5 files changed

Lines changed: 32 additions & 1 deletion

File tree

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# generated from manifests external_dependencies
2+
openupgradelib

sale_invoice_policy/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"version": "18.0.1.0.0",
1212
"license": "AGPL-3",
1313
"depends": ["sale_stock", "base_partition"],
14+
"external_dependencies": {"python": ["openupgradelib"]},
1415
"data": [
1516
"views/res_config_settings_view.xml",
1617
"views/sale_view.xml",

sale_invoice_policy/models/sale_order.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright 2017 ACSONE SA/NV (<http://acsone.eu>)
2+
# Copyright 2025 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
34

45
from odoo import api, fields, models
@@ -31,3 +32,10 @@ def _compute_invoice_policy(self) -> None:
3132
"""
3233
for company, sale_orders in self.partition("company_id").items():
3334
sale_orders.invoice_policy = company.sale_default_invoice_policy
35+
36+
def _force_lines_to_invoice_policy_order(self):
37+
# When a SO is fully paid by a payment transaction and the automatic
38+
# invoicing is enabled, the lines are forced to policy on order.
39+
# Reflect this on the SO policy.
40+
self.invoice_policy = "order"
41+
return super()._force_lines_to_invoice_policy_order()

sale_invoice_policy/readme/CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
- Ioan Galan \<<ioan@studio73.es>\>
88
- Laurent Mignon \<<laurent.mignon@acsone.eu>\>
99
- Marie Lejeune \<<marie.lejeune@acsone.eu>\>
10+
- Jacques-Etienne Baudoux (BCIM) \<<je.bcim.be>\>

sale_invoice_policy/tests/test_sale_invoice_policy.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# © 2017 Acsone SA/NV (http://www.acsone.eu)
1+
# Copyright 2017 Acsone SA/NV (http://www.acsone.eu)
2+
# Copyright 2025 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
34
import odoo.tests.common as common
45

@@ -167,3 +168,21 @@ def test_context_manager_exception(self):
167168
"the same invoice policy",
168169
exc.exception.args[0],
169170
)
171+
172+
def test_force_lines_to_invoice_policy_order(self):
173+
"""Check when a SO is fully paid by a payment transaction and the automatic
174+
invoicing is enabled, that the policy is changed on order."""
175+
so = self.env["sale.order"].create(
176+
{
177+
"partner_id": self.env.ref("base.res_partner_2").id,
178+
"order_line": [
179+
(0, 0, {"product_id": self.product.id, "product_uom_qty": 2.0}),
180+
(0, 0, {"product_id": self.product2.id, "product_uom_qty": 3.0}),
181+
],
182+
"invoice_policy": "delivery",
183+
}
184+
)
185+
so.action_confirm()
186+
self.assertEqual(so.invoice_policy, "delivery")
187+
so._force_lines_to_invoice_policy_order()
188+
self.assertEqual(so.invoice_policy, "order")

0 commit comments

Comments
 (0)