Skip to content

Commit ead2be7

Browse files
odooNextevBorruso
authored andcommitted
[FIX] l10n_it_edi_extension: fix migration script for fc, rea and rd
1 parent 3fe960b commit ead2be7

1 file changed

Lines changed: 12 additions & 72 deletions

File tree

l10n_it_edi_extension/__init__.py

Lines changed: 12 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -343,77 +343,6 @@ def _l10n_it_fatturapa_post_migration_payment_data(env):
343343
move.sudo().message_post(body=message)
344344

345345

346-
def _l10n_it_fatturapa_post_migration_related_document_type(env):
347-
env.cr.execute("""
348-
SELECT invoice_id, invoice_line_id, type, name, date, code, cig, cup
349-
FROM fatturapa_related_document_type
350-
WHERE invoice_id IS NOT NULL OR invoice_line_id IS NOT NULL
351-
""")
352-
rows = env.cr.fetchall()
353-
invoice_map = {}
354-
for row in rows:
355-
invoice_id, invoice_line_id, document_type, name, date, code, cig, cup = row
356-
move_id = (
357-
invoice_id or env["account.move.line"].browse(invoice_line_id).move_id.id
358-
)
359-
if move_id:
360-
invoice_map.setdefault(move_id, []).append(
361-
(document_type, name, date, code, cig, cup)
362-
)
363-
364-
moves = env["account.move"].browse(invoice_map.keys())
365-
out_moves = moves.filtered(lambda m: m.is_sale_document())
366-
for move in out_moves:
367-
for index, (document_type, name, date, code, cig, cup) in enumerate(
368-
invoice_map[move.id], start=1
369-
):
370-
if index == 1:
371-
if document_type == "order":
372-
document_type = "purchase_order"
373-
elif document_type not in ["contract", "agreement"]:
374-
document_type = ""
375-
move.l10n_it_origin_document_type = document_type
376-
move.l10n_it_origin_document_name = name
377-
move.l10n_it_origin_document_date = date
378-
move.l10n_it_cig = cig
379-
move.l10n_it_cup = cup
380-
else:
381-
document_type_tags = Markup('<ul class="mb-0">{}</ul>').format(
382-
Markup().join(
383-
nl2br_enclose(" ".join(tag.split()), "li")
384-
for tag in [
385-
f"IdDocumento: {name}",
386-
f'Data: {date or "N/A"}',
387-
f'CodiceCommessaConvenzione: {code or "N/A"}',
388-
f'CodiceCIG: {cig or "N/A"}',
389-
f'CodiceCUP: {cup or "N/A"}',
390-
]
391-
)
392-
)
393-
message = Markup("{} {}<br/>{}").format(
394-
document_type, env._("from XML file:"), document_type_tags
395-
)
396-
move.sudo().message_post(body=message)
397-
for move in moves - out_moves:
398-
for document_type, name, date, code, cig, cup in invoice_map[move.id]:
399-
document_type_tags = Markup('<ul class="mb-0">{}</ul>').format(
400-
Markup().join(
401-
nl2br_enclose(" ".join(tag.split()), "li")
402-
for tag in [
403-
f"IdDocumento: {name}",
404-
f'Data: {date or "N/A"}',
405-
f'CodiceCommessaConvenzione: {code or "N/A"}',
406-
f'CodiceCIG: {cig or "N/A"}',
407-
f'CodiceCUP: {cup or "N/A"}',
408-
]
409-
)
410-
)
411-
message = Markup("{} {}<br/>{}").format(
412-
document_type, env._("from XML file:"), document_type_tags
413-
)
414-
move.sudo().message_post(body=message)
415-
416-
417346
def _l10n_it_fatturapa_post_migration_rename_fields(env):
418347
RENAMED_MODELS = [
419348
("fatturapa.activity.progress", "l10n_it_edi.activity_progress"),
@@ -797,7 +726,6 @@ def _l10n_it_fatturapa_post_migration(env):
797726
_l10n_it_fatturapa_post_migration_delivery_data(env)
798727
_l10n_it_fatturapa_post_migration_vehicle_data(env)
799728
_l10n_it_fatturapa_post_migration_payment_data(env)
800-
_l10n_it_fatturapa_post_migration_related_document_type(env)
801729
_l10n_it_fatturapa_post_migration_rename_fields(env)
802730

803731

@@ -1024,6 +952,10 @@ def _l10n_it_fiscalcode_post_migration(env):
1024952
rename_fields(
1025953
env, table, {"l10n_it_codice_fiscale": "fiscalcode"}, condition=condition
1026954
)
955+
table = "res_company"
956+
rename_fields(
957+
env, table, {"l10n_it_codice_fiscale": "fiscalcode"}, condition=condition
958+
)
1027959

1028960

1029961
def _l10n_it_ipa_post_migration(env):
@@ -1055,6 +987,14 @@ def _l10n_it_rea_post_migration(env):
1055987
},
1056988
condition,
1057989
)
990+
openupgrade.logged_query(
991+
env.cr,
992+
"""
993+
UPDATE res_company
994+
SET l10n_it_has_eco_index = 't'
995+
WHERE l10n_it_eco_index_number IS NOT NULL
996+
""",
997+
)
1058998

1059999

10601000
def _l10n_it_vat_payability_pre_migration(env):

0 commit comments

Comments
 (0)