Skip to content

Commit 49f28dd

Browse files
authored
Merge pull request #5447 from dixmit/18.0-imp-account
[18.0][IMP] account: Pre-compute fields in order to make it faster
2 parents fe5988a + a391fa2 commit 49f28dd

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
("account.payment", "memo", "char"),
4040
("account.payment", "state", "selection"),
4141
("account.payment", "is_sent", "boolean"),
42+
("account.move", "made_sequence_gap", "boolean", True),
4243
]
4344

4445

@@ -197,6 +198,21 @@ def fill_statement_line_fields(env):
197198
)
198199

199200

201+
def fill_account_move_made_sequence_gap(env):
202+
openupgrade.logged_query(
203+
env.cr,
204+
"""
205+
UPDATE account_move am
206+
SET made_sequence_gap = False
207+
FROM account_move am2
208+
WHERE am.journal_id = am2.journal_id
209+
AND am.sequence_prefix = am2.sequence_prefix
210+
AND am.sequence_number = am2.sequence_number + 1
211+
AND am.sequence_number > 1
212+
""",
213+
)
214+
215+
200216
@openupgrade.migrate()
201217
def migrate(env, version):
202218
if openupgrade.column_exists(env.cr, "account_cash_rounding", "profit_account_id"):
@@ -249,3 +265,4 @@ def migrate(env, version):
249265
"account.action_account_unreconcile",
250266
],
251267
)
268+
fill_account_move_made_sequence_gap(env)

openupgrade_scripts/scripts/account/18.0.1.3/upgrade_analysis_work.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ account / account.move / journal_group_id (many2one) : NEW re
104104
# NOTHING TO DO: store = False
105105

106106
account / account.move / made_sequence_gap (boolean) : NEW isfunction: function, stored
107-
# NOTHING TO DO: will be computed by ORM
107+
# NOTHING TO DO: Created and filled pre-migration
108108

109109
account / account.move / origin_payment_id (many2one) : NEW relation: account.payment
110110
account / account.move / payment_id (many2one) : DEL relation: account.payment

0 commit comments

Comments
 (0)