Skip to content

Commit 98bc2da

Browse files
authored
Merge pull request OCA#4899 from Tecnativa/15.0-ou-imp-point_of_sale-bank-payment-method-journal
[15.0][OU][FIX] point_of_sale: empty journal in bank payment method
2 parents af2fabe + bde6c18 commit 98bc2da

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2025 Tecnativa
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
3+
from openupgradelib import openupgrade
4+
5+
6+
def _update_pos_payment_method_journal(env):
7+
"""From now on, a journal is required when the transactions aren't splitted. If we
8+
don't set a journal in these cases, the session closing won't be made properly for
9+
these methods. Cash payment methos already had a jornal set, but bank ones didn't."""
10+
payment_methods = env["pos.payment.method"].search(
11+
[
12+
("journal_id", "=", False),
13+
("split_transactions", "=", False),
14+
("type", "=", "bank"),
15+
]
16+
)
17+
for method in payment_methods:
18+
method.journal_id = env["account.journal"].create(
19+
{
20+
"type": "bank",
21+
"name": f"[openupgrade] Journal for {method.name}",
22+
"code": "POS_BANK",
23+
"company_id": method.company_id.id,
24+
"sequence": 99,
25+
}
26+
)
27+
28+
29+
@openupgrade.migrate()
30+
def migrate(env, version):
31+
_update_pos_payment_method_journal(env)

0 commit comments

Comments
 (0)