mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[MIG+FIX] contract: Missing pieces for moving info from analytic account to contract
This commit is contained in:
committed by
Francisco Ivan Anton Prieto
parent
2baecc368c
commit
ac5af54614
@@ -101,6 +101,26 @@ def create_contract_records(cr):
|
|||||||
sql.Identifier(contract_field_name),
|
sql.Identifier(contract_field_name),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
mapping = [
|
||||||
|
('ir_attachment', 'res_model', 'res_id'),
|
||||||
|
('mail_message', 'model', 'res_id'),
|
||||||
|
('mail_activity', 'res_model', 'res_id'),
|
||||||
|
('mail_followers', 'res_model', 'res_id'),
|
||||||
|
]
|
||||||
|
for table, model_column, id_column in mapping:
|
||||||
|
# Move common stuff from one table to the other
|
||||||
|
openupgrade.logged_query(
|
||||||
|
cr, sql.SQL("""
|
||||||
|
UPDATE {table} SET {model_column}='contract.contract'
|
||||||
|
WHERE {model_column}='account.analytic.account'
|
||||||
|
AND {id_column} IN (SELECT DISTINCT {col} FROM contract_line)
|
||||||
|
""").format(
|
||||||
|
table=sql.Identifier(table),
|
||||||
|
model_column=sql.Identifier(model_column),
|
||||||
|
id_column=sql.Identifier(id_column),
|
||||||
|
col=sql.Identifier(contract_field_name),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@openupgrade.migrate()
|
@openupgrade.migrate()
|
||||||
|
|||||||
Reference in New Issue
Block a user