Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions openupgrade_scripts/scripts/account/16.0.1.2/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,27 +224,27 @@ def _account_move_fast_fill_display_type(env):
openupgrade.logged_query(
env.cr,
"""
WITH sub AS (
SELECT
aml.id,
CASE
WHEN am.move_type NOT IN
('out_invoice', 'out_refund', 'in_invoice', 'in_refund')
THEN 'product'
WHEN aml.tax_line_id IS NOT NULL THEN 'tax'
WHEN aa.account_type IN
('asset_receivable', 'liability_payable') THEN 'payment_term'
ELSE 'product'
END AS display_type
FROM account_move_line AS aml
LEFT JOIN account_move AS am ON am.id = aml.move_id
LEFT JOIN account_account AS aa ON aa.id = aml.account_id
WHERE aml.display_type IS NULL AND am.id = aml.move_id
)
UPDATE account_move_line AS aml
SET display_type = sub.display_type
FROM sub
WHERE aml.id = sub.id;
UPDATE
account_move_line AS aml2
SET
display_type = COALESCE((
SELECT
CASE WHEN am.move_type NOT IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund') THEN
'product'
WHEN aml.tax_line_id IS NOT NULL THEN
'tax'
WHEN aa.account_type IN ('asset_receivable', 'liability_payable') THEN
'payment_term'
ELSE
'product'
END AS display_type
FROM account_move_line AS aml
INNER JOIN account_move AS am ON am.id = aml.move_id
INNER JOIN account_account AS aa ON aa.id = aml.account_id
WHERE
aml.id = aml2.id), 'product')
WHERE
aml2.display_type IS NULL;
""",
)
# Extra actions: set quantity = 0 for lines of type tax or payment_term according
Expand Down