|
25 | 25 |
|
26 | 26 | try:
|
27 | 27 | from odoo import release
|
28 |
| - from odoo.tools.misc import mute_logger |
29 | 28 | except ImportError:
|
30 | 29 | from openerp import release
|
31 |
| - from openerp.tools.misc import mute_logger |
32 | 30 |
|
33 | 31 | from .domains import FALSE_LEAF, TRUE_LEAF
|
34 | 32 |
|
@@ -56,6 +54,7 @@ def make_index_name(table_name, column_name):
|
56 | 54 | explode_execute,
|
57 | 55 | explode_query_range,
|
58 | 56 | format_query,
|
| 57 | + get_columns, |
59 | 58 | get_value_or_en_translation,
|
60 | 59 | parallel_execute,
|
61 | 60 | pg_text2html,
|
@@ -455,23 +454,25 @@ def move_field_to_module(cr, model, fieldname, old_module, new_module, skip_inhe
|
455 | 454 | """
|
456 | 455 | _validate_model(model)
|
457 | 456 | name = IMD_FIELD_PATTERN % (model.replace(".", "_"), fieldname)
|
458 |
| - try: |
459 |
| - with savepoint(cr), mute_logger("openerp.sql_db", "odoo.sql_db"): |
460 |
| - cr.execute( |
461 |
| - """ |
462 |
| - UPDATE ir_model_data |
463 |
| - SET module = %s |
464 |
| - WHERE model = 'ir.model.fields' |
465 |
| - AND name = %s |
466 |
| - AND module = %s |
467 |
| - """, |
468 |
| - [new_module, name, old_module], |
469 |
| - ) |
470 |
| - except psycopg2.IntegrityError: |
471 |
| - cr.execute( |
472 |
| - "DELETE FROM ir_model_data WHERE model = 'ir.model.fields' AND name = %s AND module = %s", |
473 |
| - [name, old_module], |
474 |
| - ) |
| 457 | + columns = get_columns(cr, "ir_model_data", ignore=["id", "module"]) |
| 458 | + query = format_query( |
| 459 | + cr, |
| 460 | + """ |
| 461 | + INSERT INTO ir_model_data({0}, module) |
| 462 | + SELECT {0}, %s |
| 463 | + FROM ir_model_data |
| 464 | + WHERE model = 'ir.model.fields' |
| 465 | + AND name = %s |
| 466 | + AND module = %s |
| 467 | + ON CONFLICT DO NOTHING |
| 468 | + """, |
| 469 | + columns, |
| 470 | + ) |
| 471 | + cr.execute(query, [new_module, name, old_module]) |
| 472 | + cr.execute( |
| 473 | + "DELETE FROM ir_model_data WHERE model = 'ir.model.fields' AND name = %s AND module = %s", |
| 474 | + [name, old_module], |
| 475 | + ) |
475 | 476 | # move field on inherits
|
476 | 477 | for inh in for_each_inherit(cr, model, skip_inherit):
|
477 | 478 | move_field_to_module(cr, inh.model, fieldname, old_module, new_module, skip_inherit=skip_inherit)
|
|
0 commit comments