Skip to content

Commit ffc0601

Browse files
authored
Merge pull request #5426 from Tecnativa/18.0-ou-fix-outstanding-2
[18.0][OU-FIX] account: Generate accounting entries from payments
2 parents 4af0c61 + be6c105 commit ffc0601

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

openupgrade_scripts/scripts/account/18.0.1.3/post-migration.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ def _handle_outstanding_accounts(env):
159159
160160
Now, they are handled putting specific XML-IDs on them, so we should create that
161161
identifiers on the previous referenced accounts.
162+
163+
Besides, now Odoo doesn't generate journal entries by default, unless there's an
164+
outstanding account put on the payment method line on the journals, so let's keep
165+
the previous behavior setting the same outstanding accounts on the lines that have
166+
it empty.
162167
"""
163168
IMD = env["ir.model.data"]
164169
for column in [
@@ -180,6 +185,25 @@ def _handle_outstanding_accounts(env):
180185
"noupdate": True,
181186
}
182187
)
188+
# Fill the outstanding account on journals
189+
payment_type = (
190+
"inbound"
191+
if column == "account_journal_payment_debit_account_id"
192+
else "outbound"
193+
)
194+
openupgrade.logged_query(
195+
env.cr,
196+
f"""UPDATE account_payment_method_line apml
197+
SET payment_account_id = {account_id}
198+
FROM account_journal aj, account_payment_method apm
199+
WHERE aj.id = apml.journal_id
200+
AND apm.id = apml.payment_method_id
201+
AND aj.type IN ('bank', 'cash')
202+
AND apm.payment_type = '{payment_type}'
203+
AND apml.payment_account_id IS NULL
204+
AND aj.company_id = {company_id}
205+
""",
206+
)
183207

184208

185209
@openupgrade.migrate()

0 commit comments

Comments
 (0)