-
-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84f2c62
commit fec556f
Showing
3 changed files
with
34 additions
and
10 deletions.
There are no files selected for viewing
10 changes: 0 additions & 10 deletions
10
l10n_it_intrastat_statement/migration/14.0.1.0.0/post-migration.py
This file was deleted.
Oops, something went wrong.
File renamed without changes.
34 changes: 34 additions & 0 deletions
34
l10n_it_intrastat_statement/migrations/13.0.1.0.0/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from openupgradelib import openupgrade | ||
from psycopg2 import sql | ||
|
||
|
||
def migrate(cr, installed_version): | ||
openupgrade.load_data( | ||
cr, "l10n_it_intrastat_statement", "migrations/13.0.1.0.0/noupdate_changes.xml" | ||
) | ||
|
||
to_be_updated = ( | ||
("account_intrastat_statement_sale_section1", "invoice_id"), | ||
("account_intrastat_statement_sale_section2", "invoice_id"), | ||
("account_intrastat_statement_sale_section3", "invoice_id"), | ||
("account_intrastat_statement_sale_section4", "invoice_id"), | ||
("account_intrastat_statement_purchase_section1", "invoice_id"), | ||
("account_intrastat_statement_purchase_section2", "invoice_id"), | ||
("account_intrastat_statement_purchase_section3", "invoice_id"), | ||
("account_intrastat_statement_purchase_section4", "invoice_id"), | ||
) | ||
|
||
if openupgrade.table_exists(cr, "account_invoice"): | ||
for table, column in to_be_updated: | ||
openupgrade.logged_query( | ||
cr, | ||
sql.SQL( | ||
"""UPDATE {table} t | ||
SET {column} = ai.move_id | ||
FROM account_invoice ai | ||
WHERE t.{column} = ai.id and ai.move_id is NOT NULL""" | ||
).format( | ||
table=sql.Identifier(table), | ||
column=sql.Identifier(column), | ||
), | ||
) |